release

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package release provides an appcast release(s) that suits most appcast providers.

Officially, it supports 3 providers: "GitHub Atom Feed", "SourceForge RSS Feed" and "Sparkle RSS Feed". However, it can be extended to your own needs if necessary.

Index

Constants

This section is empty.

Variables

View Source
var PublishedDateTimeFormats = []string{
	time.RFC1123Z,
	time.RFC1123,
	time.RFC3339,
	"Monday, January 02, 2006 15:04:05 MST",
}

Functions

This section is empty.

Types

type ByVersion

type ByVersion []Releaser

ByVersion implements sort.Interface for the []Releaser based Version field.

func (ByVersion) Len

func (a ByVersion) Len() int

func (ByVersion) Less

func (a ByVersion) Less(i, j int) bool

func (ByVersion) Swap

func (a ByVersion) Swap(i, j int)

type Download

type Download struct {
	// contains filtered or unexported fields
}

Download holds a single release download data.

func NewDownload

func NewDownload(url string, a ...interface{}) *Download

NewDownload returns a new Download instance pointer. Requires an url to be passed as a parameter. Optionally, the filetype can be passed as a second parameter, the length as a third one, the dsaSignature as a fourth and the md5 as a fifth.

func (*Download) DsaSignature added in v0.4.0

func (d *Download) DsaSignature() string

DsaSignature is a Download.dsaSignature getter.

func (*Download) Filetype added in v0.4.0

func (d *Download) Filetype() string

Filetype is a Download.filetype filetype.

func (*Download) Length

func (d *Download) Length() int

Length is a Download.length getter.

func (*Download) Md5 added in v0.4.0

func (d *Download) Md5() string

Md5 is a Download.md5 getter.

func (*Download) SetDsaSignature added in v0.4.0

func (d *Download) SetDsaSignature(dsaSignature string)

SetDsaSignature is a Download.dsaSignature setter.

func (*Download) SetFiletype added in v0.4.0

func (d *Download) SetFiletype(filetype string)

SetFiletype is a Download.filetype setter.

func (*Download) SetLength added in v0.4.0

func (d *Download) SetLength(length int)

SetLength is a Download.length setter.

func (*Download) SetMd5 added in v0.4.0

func (d *Download) SetMd5(md5 string)

SetMd5 is a Download.md5 setter.

func (*Download) SetUrl added in v0.4.0

func (d *Download) SetUrl(url string)

SetUrl is a Download.url setter.

func (*Download) Url added in v0.4.0

func (d *Download) Url() string

Url is a Download.url getter.

type Downloader added in v0.4.0

type Downloader interface {
	Url() string
	SetUrl(url string)
	Filetype() string
	SetFiletype(filetype string)
	Length() int
	SetLength(length int)
	DsaSignature() string
	SetDsaSignature(dsaSignature string)
	Md5() string
	SetMd5(dsaSignature string)
}

Downloader is the interface that wraps the Download methods.

type PublishedDateTime

type PublishedDateTime struct {
	// contains filtered or unexported fields
}

PublishedDateTime represents a release published date and time.

func NewPublishedDateTime

func NewPublishedDateTime(a ...interface{}) *PublishedDateTime

NewPublishedDateTime returns a new PublishedDateTime instance pointer. Optionally, the time can be passed as a parameter.

func (*PublishedDateTime) Format

func (p *PublishedDateTime) Format() string

Format is a PublishedDateTime.format getter.

func (*PublishedDateTime) Parse

func (p *PublishedDateTime) Parse(dateTime string) (err error)

Parse parses the provided dateTime string using the predefined time formats in the PublishedDateTimeFormats global variable and sets the original string value as the PublishedDateTime.original value alongside with the PublishedDateTime.time and PublishedDateTime.format.

func (*PublishedDateTime) SetFormat

func (p *PublishedDateTime) SetFormat(format string)

SetFormat is a PublishedDateTime.format setter.

func (*PublishedDateTime) SetTime

func (p *PublishedDateTime) SetTime(time *time.Time)

SetTime is a PublishedDateTime.time setter.

func (*PublishedDateTime) String

func (p *PublishedDateTime) String() string

String returns the string representation of the PublishedDateTime.

func (*PublishedDateTime) Time

func (p *PublishedDateTime) Time() *time.Time

Time is a PublishedDateTime.time getter.

type PublishedDateTimer

type PublishedDateTimer interface {
	Parse(dateTime string) (err error)
	Time() *time.Time
	SetTime(time *time.Time)
	Format() string
	SetFormat(format string)
}

PublishedDateTimer is the interface that wraps the PublishedDateTime methods.

type Release

type Release struct {
	// contains filtered or unexported fields
}

Release represents a single application release.

func New

func New(version string, build string) (*Release, error)

New returns a new Release instance pointer. Requires both version and build strings. By default, Release.IsPrerelease is set to false, so the release will be considered as stable.

func (*Release) AddDownload

func (r *Release) AddDownload(d Download)

AddDownload appends the provided Download to the Release.downloads slice.

func (*Release) Build

func (r *Release) Build() string

Build is a Release.build getter.

func (*Release) Description

func (r *Release) Description() string

Description is a Release.description getter.

func (*Release) Downloads

func (r *Release) Downloads() []Download

Downloads is a Release.downloads getter.

func (*Release) IsPreRelease

func (r *Release) IsPreRelease() bool

IsPreRelease is a Release.isPreRelease getter.

func (*Release) MinimumSystemVersion added in v0.4.0

func (r *Release) MinimumSystemVersion() string

MinimumSystemVersion is a Release.minimumSystemVersion getter.

func (*Release) PublishedDateTime

func (r *Release) PublishedDateTime() *PublishedDateTime

PublishedDateTime is a Release.publishedDateTime getter.

func (r *Release) ReleaseNotesLink() string

ReleaseNotesLink is a Release.releaseNotesLink getter.

func (*Release) SetBuild

func (r *Release) SetBuild(build string)

SetBuild is a Release.build setter.

func (*Release) SetDescription

func (r *Release) SetDescription(description string)

SetDescription is a Release.description setter.

func (*Release) SetDownloads

func (r *Release) SetDownloads(downloads []Download)

SetDownloads is a Release.downloads setter.

func (*Release) SetIsPreRelease

func (r *Release) SetIsPreRelease(isPreRelease bool)

SetIsPreRelease is a Release.isPreRelease setter.

func (*Release) SetMinimumSystemVersion added in v0.4.0

func (r *Release) SetMinimumSystemVersion(minimumSystemVersion string)

SetMinimumSystemVersion is a Release.minimumSystemVersion setter.

func (*Release) SetPublishedDateTime

func (r *Release) SetPublishedDateTime(publishedDateTime *PublishedDateTime)

SetPublishedDateTime is a Release.publishedDateTime setter.

func (r *Release) SetReleaseNotesLink(releaseNotesLink string)

SetReleaseNotesLink is a Release.releaseNotesLink setter.

func (*Release) SetTitle

func (r *Release) SetTitle(title string)

SetTitle is a Release.title setter.

func (*Release) SetVersion

func (r *Release) SetVersion(version *version.Version)

SetVersion is a Release.version setter.

func (*Release) SetVersionString

func (r *Release) SetVersionString(value string) error

SetVersionString sets the Release.version from the provided version value string. Returns an error, if the provided version string value doesn't follow the SemVer specification.

func (*Release) Title

func (r *Release) Title() string

Title is a Release.title getter.

func (*Release) Version

func (r *Release) Version() *version.Version

Version is a Release.version getter.

func (*Release) VersionOrBuildString

func (r *Release) VersionOrBuildString() string

VersionOrBuildString retrieves the release version string if it's available. Otherwise, returns the release build string.

type Releaser

type Releaser interface {
	VersionOrBuildString() string
	Version() *version.Version
	SetVersion(version *version.Version)
	SetVersionString(value string) error
	Build() string
	SetBuild(build string)
	Title() string
	SetTitle(title string)
	Description() string
	SetDescription(description string)
	PublishedDateTime() *PublishedDateTime
	SetPublishedDateTime(publishedDateTime *PublishedDateTime)
	ReleaseNotesLink() string
	SetReleaseNotesLink(releaseNotesLink string)
	MinimumSystemVersion() string
	SetMinimumSystemVersion(minimumSystemVersion string)
	AddDownload(d Download)
	Downloads() []Download
	SetDownloads(downloads []Download)
	IsPreRelease() bool
	SetIsPreRelease(isPreRelease bool)
}

Releaser is the interface that wraps the Release methods.

type Releases added in v0.5.0

type Releases struct {
	// contains filtered or unexported fields
}

Releases represents the appcast releases which holds both the filtered and the original ones.

func NewReleases added in v0.5.0

func NewReleases(releases []Releaser) *Releases

NewReleases returns a new Releases instance pointer. Requires []Releaser slice to be passed as a parameter which will be set to the Releases.filtered and the Releases.original.

func (*Releases) FilterByMediaType added in v0.5.0

func (r *Releases) FilterByMediaType(regexpStr string, inversed ...interface{})

FilterByMediaType filters all Releases.filtered by matching the downloads media type with the provided RegExp string.

When inversed bool is set to true, the unmatched releases will be used instead.

func (*Releases) FilterByPrerelease added in v0.5.0

func (r *Releases) FilterByPrerelease(inversed ...interface{})

FilterByPrerelease filters all Releases.filtered by matching only the pre-releases.

When inversed bool is set to true, the unmatched releases will be used instead.

func (*Releases) FilterByTitle added in v0.5.0

func (r *Releases) FilterByTitle(regexpStr string, inversed ...interface{})

FilterByTitle filters all Releases.filtered by matching the release title with the provided RegExp string.

When inversed bool is set to true, the unmatched releases will be used instead.

func (*Releases) FilterByUrl added in v0.5.0

func (r *Releases) FilterByUrl(regexpStr string, inversed ...interface{})

FilterByUrl filters all Releases.filtered by matching the release download URL with the provided RegExp string.

When inversed bool is set to true, the unmatched releases will be used instead.

func (*Releases) Filtered added in v0.5.0

func (r *Releases) Filtered() []Releaser

Filtered is a Releases.filtered getter.

func (*Releases) First added in v0.5.0

func (r *Releases) First() Releaser

First is a convenience method to get the first release from the Releases.filtered slice.

func (*Releases) Len added in v0.5.0

func (r *Releases) Len() int

Len is a convenience method to get the Releases.filtered slice length.

func (*Releases) Original added in v0.5.0

func (r *Releases) Original() []Releaser

Original is a Releases.original getter.

func (*Releases) ResetFilters added in v0.5.0

func (r *Releases) ResetFilters()

ResetFilters resets the Releases.filtered to their original state before applying any filters.

func (*Releases) SetFiltered added in v0.5.0

func (r *Releases) SetFiltered(filtered []Releaser)

SetFiltered is a Releases.filtered setter.

func (*Releases) SetOriginal added in v0.5.0

func (r *Releases) SetOriginal(original []Releaser)

SetOriginal is a Releases.original setter.

func (*Releases) SortByVersions added in v0.5.0

func (r *Releases) SortByVersions(s Sort)

SortByVersions sorts the Releases.filtered slice by versions. Can be useful if the versions order is inconsistent.

type Releaseser added in v0.5.0

type Releaseser interface {
	SortByVersions(s Sort)
	FilterByTitle(regexpStr string, inversed ...interface{})
	FilterByMediaType(regexpStr string, inversed ...interface{})
	FilterByUrl(regexpStr string, inversed ...interface{})
	FilterByPrerelease(inversed ...interface{})
	ResetFilters()
	Len() int
	First() Releaser
	Filtered() []Releaser
	SetFiltered(filtered []Releaser)
	Original() []Releaser
	SetOriginal(original []Releaser)
}

Releaseser is the interface that wraps the Releases methods.

TODO: Find a better Releaseser interface name.

type Sort added in v0.5.0

type Sort int

Sort holds different supported sorting behaviours.

const (
	// ASC represents the ascending order.
	ASC Sort = iota

	// DESC represents the descending order.
	DESC
)

Jump to

Keyboard shortcuts

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