cask

package module
v0.0.0-...-dc424ca Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2018 License: MIT Imports: 7 Imported by: 0

README

go-cask

Build Status Coverage Status Report Card GoDoc

NOTICE: Currently in development.

This library provides functionality for working with Homebrew-Cask casks.

What "cask" means?

The "cask" is a small Ruby block in a separate file that is used to describe the application in Homebrew-Cask project. You can learn more about them by reading through the Homebrew-Cask "Synopsis".

Why is this library needed and what it does?

This library attempts to provide a way of parsing and extracting basic information from casks for later use in Go. It parses the cask Ruby block and creates the corresponding cask.Cask struct.

Features
  • Conditional statements
    • MacOS.version
  • Language blocks
  • String interpolations
    • #{version}
    • #{language}

Supported stanzas

Below you can find a list of all supported cask stanzas that this library can understand and recognize during the parsing phase. If the checkbox next to the stanza is not ticked, that stanza is not supported yet.

To learn more about all available cask stanzas check out the Homebrew-Cask "All stanzas".

Required
  • version
  • sha256
  • url
  • name
  • homepage
Artifacts
  • app
    • target:
  • pkg
    • allow_untrusted:
  • binary
    • target:
  • colorpicker
  • dictionary
  • font
  • input_method
  • internet_plugin
  • prefpane
  • qlplugin
  • screen_saver
  • service
  • audio_unit_plugin
  • vst_plugin
  • vst3_plugin
  • suite
  • artifact
  • installer
  • stage_only
Optional
  • uninstall
  • zap
  • appcast
  • depends_on
  • conflicts_with
  • caveats
    • indented heredoc (<<-EOS)
    • "squiggly" heredoc (<<~EOS)
  • preflight
  • postflight
  • uninstall_preflight
  • uninstall_postflight
  • language
  • accessibility_access
  • container nested:
  • container type:
  • gpg
  • auto_updates

Examples

First example

For the first example we will parse the example-one.rb cask from our testdata directory.

package main

import (
	"fmt"

	"github.com/victorpopkov/go-cask"
)

func main() {
	// for this example we will load the cask from our testdata directory
	content := string(getTestdata("example-one.rb"))

	// example
	c := cask.NewCask(content)
	err := c.Parse()

	if err == nil {
		fmt.Println("Token:", c.Token)
		for i, v := range c.Variants {
			fmt.Printf("Variant #%d:\n", i+1)
			fmt.Printf("%10s: %s\n", "version", v.GetVersion())
			fmt.Printf("%10s: %s\n", "sha256", v.GetSHA256())
			fmt.Printf("%10s: %s\n", "url", v.GetURL())
			fmt.Printf("%10s: %s\n", "appcast", v.GetAppcast().URL)
			fmt.Printf("%10s: %v\n", "names", v.GetNames())
			fmt.Printf("%10s: %s\n", "homepage", v.GetHomepage())

			// artifacts
			fmt.Printf("%10s: ", "artifacts")
			if len(v.GetArtifacts()) > 0 {
				for i, a := range v.GetArtifacts() {
					if i == 0 {
						fmt.Printf("%s\n", a.String())
					} else {
						fmt.Printf("%12s%s\n", "", a.String())
					}
				}
			} else {
				fmt.Printf("%v\n", v.GetArtifacts())
			}

			// macOS
			fmt.Printf("%10s: %s [minimum]\n", "macOS", v.MinimumSupportedMacOS)
			fmt.Printf("%12s%s [maximum]\n", "", v.MaximumSupportedMacOS)
		}
	}

	// Output:
	// Token: example-one
	// Variant #1:
	//    version: 2.0.0
	//     sha256: f22abd6773ab232869321ad4b1e47ac0c908febf4f3a2bd10c8066140f741261
	//        url: https://example.com/app_2.0.0.dmg
	//    appcast: https://example.com/sparkle/2/appcast.xml
	//      names: [Example Example One]
	//   homepage: https://example.com/
	//  artifacts: app, Example 2.0.app => Example.app
	//             app, Example 2.0 Uninstaller.app
	//             binary, #{appdir}/Example 2.0.app/Contents/MacOS/example-one => example
	//      macOS: macOS High Sierra (10.13) [minimum]
	//             macOS High Sierra (10.13) [maximum]
}
Second example

For the second example we will parse the example-two.rb cask from our testdata directory.

package main

import (
	"fmt"

	"github.com/victorpopkov/go-cask"
)

func main() {
	// for this example we will load the cask from our testdata directory
	content := string(getTestdata("example-two.rb"))

	// example
	c := cask.NewCask(content)
	err := c.Parse()

	if err == nil {
		fmt.Println("Token:", c.Token)
		for i, v := range c.Variants {
			fmt.Printf("Variant #%d:\n", i+1)
			fmt.Printf("%10s: %s\n", "version", v.GetVersion())
			fmt.Printf("%10s: %s\n", "sha256", v.GetSHA256())
			fmt.Printf("%10s: %s\n", "url", v.GetURL())
			fmt.Printf("%10s: %s\n", "appcast", v.GetAppcast().URL)
			fmt.Printf("%10s: %v\n", "names", v.GetNames())
			fmt.Printf("%10s: %s\n", "homepage", v.GetHomepage())

			// artifacts
			fmt.Printf("%10s: ", "artifacts")
			if len(v.GetArtifacts()) > 0 {
				for i, a := range v.GetArtifacts() {
					if i == 0 {
						fmt.Printf("%s\n", a.String())
					} else {
						fmt.Printf("%12s%s\n", "", a.String())
					}
				}
			} else {
				fmt.Printf("%v\n", v.GetArtifacts())
			}

			// macOS
			fmt.Printf("%10s: %s [minimum]\n", "macOS", v.MinimumSupportedMacOS)
			fmt.Printf("%12s%s [maximum]\n", "", v.MaximumSupportedMacOS)
		}
	}

	// Output:
	// Token: example-two
	// Variant #1:
	//    version: 1.5.0
	//     sha256: 1f4dc096d58f7d21e3875671aee6f29b120ab84218fa47db2cb53bc9eb5b4dac
	//        url: https://example.com/app_1.5.0.pkg
	//    appcast: https://example.com/sparkle/1/el_capitan.xml
	//      names: [Example Example Two]
	//   homepage: https://example.com/
	//  artifacts: pkg, app_1.5.0.pkg, allow_untrusted: true
	//      macOS: Mac OS X Tiger (10.4) [minimum]
	//             OS X El Capitan (10.11) [maximum]
	// Variant #2:
	//    version: 2.0.0
	//     sha256: f22abd6773ab232869321ad4b1e47ac0c908febf4f3a2bd10c8066140f741261
	//        url: https://example.com/app_2.0.0.pkg
	//    appcast: https://example.com/sparkle/2/appcast.xml
	//      names: [Example Example Two]
	//   homepage: https://example.com/
	//  artifacts: pkg, app_2.0.0.pkg, allow_untrusted: true
	//      macOS: macOS High Sierra (10.13) [minimum]
	//             macOS High Sierra (10.13) [maximum]
}

License

Released under the MIT License.

Documentation

Overview

Example (One)
// for this example we will load the cask from our testdata directory
content := string(getTestdata("example-one.rb"))

// example
c := NewCask(content)
err := c.Parse()

if err == nil {
	fmt.Println("Token:", c.Token)
	for i, v := range c.Variants {
		fmt.Printf("Variant #%d:\n", i+1)
		fmt.Printf("%10s: %s\n", "version", v.GetVersion())
		fmt.Printf("%10s: %s\n", "sha256", v.GetSHA256())
		fmt.Printf("%10s: %s\n", "url", v.GetURL())
		fmt.Printf("%10s: %s\n", "appcast", v.GetAppcast().URL)
		fmt.Printf("%10s: %v\n", "names", v.GetNames())
		fmt.Printf("%10s: %s\n", "homepage", v.GetHomepage())

		// artifacts
		fmt.Printf("%10s: ", "artifacts")
		if len(v.GetArtifacts()) > 0 {
			for i, a := range v.GetArtifacts() {
				if i == 0 {
					fmt.Printf("%s\n", a.String())
				} else {
					fmt.Printf("%12s%s\n", "", a.String())
				}
			}
		} else {
			fmt.Printf("%v\n", v.GetArtifacts())
		}

		// macOS
		fmt.Printf("%10s: %s [minimum]\n", "macOS", v.MinimumSupportedMacOS)
		fmt.Printf("%12s%s [maximum]\n", "", v.MaximumSupportedMacOS)
	}
}
Output:

Token: example-one
Variant #1:
   version: 2.0.0
    sha256: f22abd6773ab232869321ad4b1e47ac0c908febf4f3a2bd10c8066140f741261
       url: https://example.com/app_2.0.0.dmg
   appcast: https://example.com/sparkle/2/appcast.xml
     names: [Example Example One]
  homepage: https://example.com/
 artifacts: app, Example 2.0.app => Example.app
            app, Example 2.0 Uninstaller.app
            binary, #{appdir}/Example 2.0.app/Contents/MacOS/example-one => example
     macOS: macOS High Sierra (10.13) [minimum]
            macOS High Sierra (10.13) [maximum]
Example (Two)
// for this example we will load the cask from our testdata directory
content := string(getTestdata("example-two.rb"))

// example
c := NewCask(content)
err := c.Parse()

if err == nil {
	fmt.Println("Token:", c.Token)
	for i, v := range c.Variants {
		fmt.Printf("Variant #%d:\n", i+1)
		fmt.Printf("%10s: %s\n", "version", v.GetVersion())
		fmt.Printf("%10s: %s\n", "sha256", v.GetSHA256())
		fmt.Printf("%10s: %s\n", "url", v.GetURL())
		fmt.Printf("%10s: %s\n", "appcast", v.GetAppcast().URL)
		fmt.Printf("%10s: %v\n", "names", v.GetNames())
		fmt.Printf("%10s: %s\n", "homepage", v.GetHomepage())

		// artifacts
		fmt.Printf("%10s: ", "artifacts")
		if len(v.GetArtifacts()) > 0 {
			for i, a := range v.GetArtifacts() {
				if i == 0 {
					fmt.Printf("%s\n", a.String())
				} else {
					fmt.Printf("%12s%s\n", "", a.String())
				}
			}
		} else {
			fmt.Printf("%v\n", v.GetArtifacts())
		}

		// macOS
		fmt.Printf("%10s: %s [minimum]\n", "macOS", v.MinimumSupportedMacOS)
		fmt.Printf("%12s%s [maximum]\n", "", v.MaximumSupportedMacOS)
	}
}
Output:

Token: example-two
Variant #1:
   version: 1.5.0
    sha256: 1f4dc096d58f7d21e3875671aee6f29b120ab84218fa47db2cb53bc9eb5b4dac
       url: https://example.com/app_1.5.0.pkg
   appcast: https://example.com/sparkle/1/el_capitan.xml
     names: [Example Example Two]
  homepage: https://example.com/
 artifacts: pkg, app_1.5.0.pkg, allow_untrusted: true
     macOS: Mac OS X Tiger (10.4) [minimum]
            OS X El Capitan (10.11) [maximum]
Variant #2:
   version: 2.0.0
    sha256: f22abd6773ab232869321ad4b1e47ac0c908febf4f3a2bd10c8066140f741261
       url: https://example.com/app_2.0.0.pkg
   appcast: https://example.com/sparkle/2/appcast.xml
     names: [Example Example Two]
  homepage: https://example.com/
 artifacts: pkg, app_2.0.0.pkg, allow_untrusted: true
     macOS: macOS High Sierra (10.13) [minimum]
            macOS High Sierra (10.13) [maximum]

Index

Examples

Constants

This section is empty.

Variables

View Source
var LexStartFn = startLexer

LexStartFn represents the entrypoint the Lexer uses to start processing the input.

Functions

This section is empty.

Types

type Appcast

type Appcast struct {
	BaseStanza

	// URL specifies the appcast URL.
	URL string
}

An Appcast represents an appcast cask stanza.

func NewAppcast

func NewAppcast(url string, checkpoint string) *Appcast

NewAppcast creates a new Appcast instance and returns its pointer. Requires both Appcast.URL and Appcast.Checkpoint to be passed as arguments.

func (Appcast) String

func (a Appcast) String() string

String returns a string representation of the Appcast struct which is the Appcast.URL.

type Artifact

type Artifact struct {
	// Type specifies the artifact type.
	Type ArtifactType

	// Value specifies the artifact value.
	Value string

	// Target specifies the "target:" value. By default, it's empty string.
	Target string

	// AllowUntrusted specifies the "allow_untrusted:" value. By default, it's
	// false. This should be true only if the Artifact.Type is ArtifactPkg.
	AllowUntrusted bool
}

An Artifact represents the cask artifact stanza itself.

func NewArtifact

func NewArtifact(t ArtifactType, value string) *Artifact

NewArtifact creates a new Artifact instance and returns its pointer. Requires both Artifact.Type and Artifact.Value to be passed as arguments.

func (Artifact) String

func (a Artifact) String() (result string)

String returns the string representation of the Artifact.

type ArtifactType

type ArtifactType int

An ArtifactType represents a known artifact stanza type.

const (
	ArtifactApp ArtifactType = iota
	ArtifactPkg
	ArtifactBinary
)

Different supported artifact types.

func (ArtifactType) String

func (t ArtifactType) String() string

String returns the string representation of the ArtifactType.

type BaseStanza

type BaseStanza struct {
	// IsGlobal specifies if the appcast belongs to all Cask.Variants. If the
	// stanza wasn't found inside if statement, the stanza should be considered as
	// global and this value should be true. By default, this value is "false".
	IsGlobal bool
}

A BaseStanza represents a base for all stanzas. Shouldn't be used as is, but inherited by type specific stanzas.

type Cask

type Cask struct {
	// Token specifies the cask token.
	Token string

	// Content specifies the string content of the loaded cask.
	Content string

	// Variants specifies all cask variants represented as a slice of Variant
	// pointers.
	Variants []*Variant
	// contains filtered or unexported fields
}

A Cask represents the cask used in Homebrew-Cask.

func NewCask

func NewCask(content string) *Cask

NewCask creates a new Cask instance and returns its pointer.

func (*Cask) AddVariant

func (c *Cask) AddVariant(variant *Variant)

AddVariant adds a new Variant pointer to the Cask.Variants slice.

func (*Cask) Parse

func (c *Cask) Parse() error

Parse parses the cask.

func (Cask) String

func (c Cask) String() string

String returns a string representation of the Cask struct which is the cask Token.

type Errors

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

Errors represents a group of errors and its context.

func NewErrors

func NewErrors(context string, errors ...error) *Errors

NewErrors creates a new Errors instance and returns its pointer. Requires both Errors.context and Errors.errors to be passed as arguments.

func (*Errors) Error

func (e *Errors) Error() string

Error returns all error messages represented as a single string. All errors include trailing newlines and prepended context.

type Homepage

type Homepage struct {
	BaseStanza

	// Value specifies the stanza value.
	Value string
}

A Homepage represents a homepage cask stanza.

func NewHomepage

func NewHomepage(value string) *Homepage

NewHomepage creates a new Homepage instance and returns its pointer. Requires Homepage.Value to be passed as argument.

func (Homepage) String

func (h Homepage) String() string

String returns a string representation of the Homepage struct which is the Homepage.Value.

type Lexer

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

Lexer is the engine to process input and emit Tokens.

func NewLexer

func NewLexer(input string) *Lexer

NewLexer creates a new Lexer instance and returns its pointer. Requires an input to be passed as an argument that is ready to be processed.

func (*Lexer) HasNext

func (l *Lexer) HasNext() bool

HasNext returns true if there are tokens left, false if EOF has reached.

func (*Lexer) NextToken

func (l *Lexer) NextToken() Token

NextToken will return the next token processed from the lexer.

type MacOS

type MacOS int

A MacOS represents the available macOS versions.

const (
	MacOSHighSierra MacOS = iota
	MacOSSierra
	MacOSElCapitan
	MacOSYosemite
	MacOSMavericks
	MacOSMountainLion
	MacOSLion
	MacOSSnowLeopard
	MacOSLeopard
	MacOSTiger
)

Different macOS releases.

func (MacOS) Name

func (m MacOS) Name() string

Name returns the MacOS release name.

func (MacOS) String

func (m MacOS) String() string

String returns the string representation of the MacOS release.

func (MacOS) Version

func (m MacOS) Version() string

Version returns the MacOS release version.

type Name

type Name struct {
	BaseStanza

	// Value specifies the stanza value.
	Value string
}

A Name represents a name cask stanza.

func NewName

func NewName(value string) *Name

NewName creates a new Name instance and returns its pointer. Requires Name.Value to be passed as argument.

func (Name) String

func (n Name) String() string

String returns a string representation of the Name struct which is the Name.Value.

type Parser

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

A Parser represents the parser that uses the emitted token provided by Lexer.

func NewParser

func NewParser(lexer *Lexer) *Parser

NewParser creates a new Parser instance and returns its pointer. Requires a Lexer and a Cask to be specified as arguments.

func (*Parser) Errors

func (p *Parser) Errors() []error

Errors returns all errors which happened during the Parser.input parsing.

func (*Parser) ParseArtifact

func (p *Parser) ParseArtifact() (*Artifact, error)

ParseArtifact parses the supported artifact if the Parser.currentToken literal value matches the supported one. It runs the corresponding artifact specific parsing function. Returns an "artifact not found" error if the Parser.currentToken literal value doesn't match any supported one.

func (*Parser) ParseCask

func (p *Parser) ParseCask(cask *Cask) error

ParseCask parses the input from Parse.lexer into the Parse.cask.

func (*Parser) ParseConditionMacOS

func (p *Parser) ParseConditionMacOS() (min MacOS, max MacOS, err error)

ParseConditionMacOS parses the "MacOS.version" condition statement. Returns both the minimum and maximum macOS releases. By default, the minimum is MacOSTiger and the maximum matches the latest macOS release which is MacOSHighSierra.

type SHA256

type SHA256 struct {
	BaseStanza

	// Value specifies the stanza value.
	Value string
}

A SHA256 represents a sha256 cask stanza.

func NewSHA256

func NewSHA256(value string) *SHA256

NewSHA256 creates a new SHA256 instance and returns its pointer. Requires SHA256.Value to be passed as argument.

func (SHA256) String

func (s SHA256) String() string

String returns a string representation of the SHA256 struct which is the SHA256.Value.

type Stanza

type Stanza interface {
	String() string
}

A Stanza represents the interface that each stanza Type specific stanza should implement.

type StateFn

type StateFn func(*Lexer) StateFn

StateFn represents a function which is capable of lexing parts of the input. It returns another StateFn to proceed with.

Typically a state function would get called from LexStartFn and should return LexStartFn to go back to the decision loop. It also could return another non start state function if the partial input to parse is abiguous.

type Token

type Token struct {
	// Type specifies the recognized token type.
	Type TokenType

	// Literal specifies the literal representation of the token which is the
	// token value itself.
	Literal string

	// Position specifies the position where token is found.
	Position int
}

A Token represents a known token used in Lexer with its literal representation.

func NewToken

func NewToken(t TokenType, literal string, position int) *Token

NewToken returns a new Token.

type TokenType

type TokenType int

TokenType represents a known token type.

const (
	EOF     TokenType = iota // end of input
	ILLEGAL                  // an illegal/unknown character

	CONST
	GLOBAL
	IDENT
	INT
	STRING
	SYMBOL // :symbol

	// %r{}
	PNREGEXP // %r
	PNSTART  // left delimiter ('{' or other)
	PNEND    // right delimiter ('}' or other)

	HEREDOC
	HEREDOCSTART
	HEREDOCEND

	ASSIGN   // =
	ASTERISK // *
	BANG     // !
	MINUS    // -
	PLUS     // +
	SLASH    // /
	MODULUS  // %

	EQ    // ==
	GT    // >
	LT    // <
	NOTEQ // !=

	COMMA     // ,
	NEWLINE   // \n
	SEMICOLON // ;

	COLON    // :
	DOT      // .
	LBRACE   // {
	LBRACKET // [
	LPAREN   // (
	PIPE     // |
	RBRACE   // }
	RBRACKET // ]
	RPAREN   // )

	SCOPE // ::

	REGEXP

	CLASS
	DEF
	DO
	ELSE
	ELSEIF
	END
	FALSE
	IF
	MODULE
	NIL
	RETURN
	SELF
	THEN
	TRUE
	YIELD
)

Different token types that can be recognized.

func LookupIdent

func LookupIdent(ident string) TokenType

LookupIdent returns a TokenType keyword if ident is in the keywords map. If specified ident starts with an upper character it will return a CONST TokenType. Otherwise, it returns IDENT.

func (TokenType) String

func (i TokenType) String() string

type URL

type URL struct {
	BaseStanza

	// Value specifies the stanza value.
	Value string
}

An URL represents an url cask stanza.

func NewURL

func NewURL(value string) *URL

NewURL creates a new URL instance and returns its pointer. Requires URL.Value to be passed as argument.

func (URL) String

func (u URL) String() string

String returns a string representation of the URL struct which is the URL.Value.

type Variant

type Variant struct {
	// Version specifies the version stanza.
	Version *Version

	// SHA256 specifies the SHA256 checksum for the downloaded Variant.URL file.
	SHA256 *SHA256

	// URL specifies the url stanza.
	URL *URL

	// Appcast specifies the appcast stanza.
	Appcast *Appcast

	// Names specify the application names. Each cask can have multiple names.
	Names []*Name

	// Homepage specifies the application vendor homepage stanza.
	Homepage *Homepage

	// Artifacts specify artifact stanzas.
	Artifacts []*Artifact

	// MinimumSupportedMacOS specifies the minimum supported macOS release. By
	// default each cask uses the latest stable macOS release.
	MinimumSupportedMacOS MacOS

	// MaximumSupportedMacOS specifies the maximum supported macOS release. By
	// default each cask uses the latest stable macOS release.
	MaximumSupportedMacOS MacOS
}

A Variant represents a single cask variant.

func NewVariant

func NewVariant() *Variant

NewVariant returns a new Variant instance pointer.

func (*Variant) AddArtifact

func (v *Variant) AddArtifact(artifact *Artifact)

AddArtifact adds a new Artifact pointer to the Variant.Artifacts slice.

func (*Variant) AddName

func (v *Variant) AddName(name *Name)

AddName adds a new *Name to the Variant.Names slice.

func (*Variant) GetAppcast

func (v *Variant) GetAppcast() (a Appcast)

GetAppcast returns the Appcast struct from the existing Variant.Appcast struct pointer and interpolates the version into the Variant.Appcast.URL if available.

func (*Variant) GetArtifacts

func (v *Variant) GetArtifacts() (a []Artifact)

GetArtifacts returns the []Artifacts slice from the existing []Variant.Artifacts slice pointer and interpolates the version into each artifact value if available.

func (*Variant) GetHomepage

func (v *Variant) GetHomepage() (h Homepage)

GetHomepage returns the Homepage struct from the existing Variant.Homepage struct pointer and interpolates the version into the Variant.Homepage.Value if available.

func (*Variant) GetNames

func (v *Variant) GetNames() (n []Name)

GetNames returns the []Name slice from the existing []Variant.Names slice pointer and interpolates the version into each name if available.

func (*Variant) GetSHA256

func (v *Variant) GetSHA256() SHA256

GetSHA256 returns the SHA256 struct from the existing Variant.SHA256 struct pointer.

func (*Variant) GetURL

func (v *Variant) GetURL() (u URL)

GetURL returns the URL struct from the existing Variant.URL struct pointer and interpolates the version into the Variant.URL.Value if available.

func (*Variant) GetVersion

func (v *Variant) GetVersion() Version

GetVersion returns the Version struct from the existing Variant.Version struct pointer.

type Version

type Version struct {
	BaseStanza

	// Value specifies the stanza value.
	Value string
}

A Version represents a version cask stanza.

func NewVersion

func NewVersion(value string) *Version

NewVersion creates a new Version instance and returns its pointer. Requires Version.Value to be passed as argument.

func (Version) AfterColon

func (v Version) AfterColon() (string, error)

AfterColon extracts the Version.Value part after colon and returns the result string.

func (Version) AfterComma

func (v Version) AfterComma() (string, error)

AfterComma extracts the Version.Value part after comma and returns the result string.

func (Version) BeforeColon

func (v Version) BeforeColon() (string, error)

BeforeColon extracts the Version.Value part before colon and returns the result string.

func (Version) BeforeComma

func (v Version) BeforeComma() (string, error)

BeforeComma extracts the Version.Value part before comma and returns the result string.

func (Version) DotsToHyphens

func (v Version) DotsToHyphens() (string, error)

DotsToHyphens converts all Version.Value dots to hyphens and returns the result string.

func (Version) DotsToUnderscores

func (v Version) DotsToUnderscores() (string, error)

DotsToUnderscores converts all Version.Value dots to underscores and returns the result string.

func (Version) HasVersionStringInterpolation

func (v Version) HasVersionStringInterpolation(str string) bool

HasVersionStringInterpolation check whether the provided string has a Ruby syntax version string interpolation.

func (Version) InterpolateIntoString

func (v Version) InterpolateIntoString(str string) (result string)

InterpolateIntoString interpolates existing version into the provided string with Ruby interpolation syntax.

func (Version) Major

func (v Version) Major() (string, error)

Major extracts the major semantic version part from Version.Value and returns the result string.

func (Version) MajorMinor

func (v Version) MajorMinor() (string, error)

MajorMinor extracts the major and minor semantic version parts from Version.Value and returns the result string.

func (Version) MajorMinorPatch

func (v Version) MajorMinorPatch() (string, error)

MajorMinorPatch extracts the major, minor and patch semantic version parts from Version.Value and returns the result string.

func (Version) Minor

func (v Version) Minor() (string, error)

Minor extracts the minor semantic version part from Version.Value and returns the result string.

func (Version) NoDots

func (v Version) NoDots() (string, error)

NoDots removes all Version.Value dots and returns the result string.

func (Version) Patch

func (v Version) Patch() (string, error)

Patch extracts the patch semantic version part from Version.Value and returns the result string.

func (Version) String

func (v Version) String() string

String returns a string representation of the Version struct which is the Version.Value.

Jump to

Keyboard shortcuts

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