daydeal

package module
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2019 License: MIT Imports: 5 Imported by: 0

README

Go daydeal

CircleCI Go Report Card License

Fetch the current DayDeal.

Usage

$ daydeal

    Schweizer Armbanduhr
    Zizzo Classic-Serie

Für CHF 149.– statt CHF 219.– (2)
Noch 84% verfügbar
Nächster Deal am: Mon Mar 18 08:59:59 (in 11h50m0s)

Use the -w flag to fetch the "Deal of the Week" instead.

Installation

Homebrew tap (macOS)

brew install mhutter/tap/daydeal

go get (any OS)

go get -u github.com/mhutter/daydeal/...

Or download a pre-built binary.

License

MIT (see LICENSE)


Manuel Hutter - GitHub @mhutter

Documentation

Index

Constants

View Source
const (
	URLDaydealDay  = "https://www.daydeal.ch/"
	URLDaydealWeek = "https://www.daydeal.ch/deal-of-the-week"
)

URLs of the various daydeal sources

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Out io.Writer
	URL string
}

App parses arguments and calls the other components accordingly.

func NewApp

func NewApp(out io.Writer, url string) App

NewApp returns a new App instance with sensible defaults.

func (App) Run

func (a App) Run() error

Run the Daydeal app

type Daydeal

type Daydeal struct {
	*goquery.Document
}

Daydeal holds all information about the current deal and knows how to extract information from it.

func FetchDeal

func FetchDeal(url string) (deal Daydeal, err error)

FetchDeal fetches the daydeal with the url given.

func NewDaydeal

func NewDaydeal(doc *goquery.Document) Daydeal

NewDaydeal returns a new Daydeal instance with the given document.

func (Daydeal) NewPrice

func (d Daydeal) NewPrice() string

NewPrice displays the new (reduced) price

func (Daydeal) NextDeal

func (d Daydeal) NextDeal() time.Time

NextDeal returns the time & date of the next deal.

func (Daydeal) NextDealIn

func (d Daydeal) NextDealIn() time.Duration

NextDealIn returns the duration to the next deal.

func (Daydeal) OldPrice

func (d Daydeal) OldPrice() string

OldPrice displays the "original" price of the item

func (Daydeal) Percentage

func (d Daydeal) Percentage() string

Percentage displays how many items (in percent obviously) are left

func (Daydeal) PriceSource

func (d Daydeal) PriceSource() string

PriceSource displays the price source according to daydeal.ch: 1 Konkurrenzvergleich 2 Selbstvergleich BRACK.CH 3 Einführungspreis

func (Daydeal) Subtitle

func (d Daydeal) Subtitle() string

Subtitle displays the subtitle of the deal (ie a description of the item sold)

func (Daydeal) Title

func (d Daydeal) Title() string

Title displays the title of the deal (ie name of the item sold)

type Printable

type Printable interface {
	Title() string
	Subtitle() string
	NewPrice() string
	OldPrice() string
	PriceSource() string
	Percentage() string
	NextDeal() time.Time
	NextDealIn() time.Duration
}

Printable interface defines all methods required to print a deal

type Printer

type Printer struct {
	Out io.Writer
}

Printer is responsible to output a deal to various sources

func NewPrinter

func NewPrinter(out io.Writer) *Printer

NewPrinter returns a new Printer instance

func (Printer) Print added in v1.0.2

func (p Printer) Print(deal Printable)

Print writes the given deal to p.Out

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL