pack

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

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

Go to latest
Published: Nov 1, 2013 License: MIT Imports: 13 Imported by: 1

README

pack

Build Status

Facilitates the reading, writing and comparison of package metadata.

Documentation

Overview

Package pack provides low level types, parsing, and semantic versioning tools to facilitate the reading, writing, and comparison of package metadata.

Index

Constants

View Source
const (
	GOPATH       = "GOPATH"
	GOPACKFOLDER = "gopack"
	SRCFOLDER    = "src"
)

Variables

This section is empty.

Functions

func DirExists

func DirExists(dir string) (bool, error)

DirExists checks to see if a directory exists.

func EnsureDirectory

func EnsureDirectory(dir string) (bool, error)

EnsureDirectory ensures a directory exists, or it creates it. Returns true if the directory had to be created.

func FileExists

func FileExists(file string) (bool, error)

FileExists checks to see if a directory exists.

func TryUriParse

func TryUriParse(pathOrUrl string) (*url.URL, error)

TryUriParse tries to parse the given string into a uri.

Types

type Author

type Author struct {
	Name     string   `yaml:",omitempty"`
	Emails   []string `yaml:",omitempty"`
	Homepage string   `yaml:",omitempty"`
}

Author is metadata about an author.

type Bzr

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

Bzr uses the bazaar toolset to implement the dvcs interface.

func (*Bzr) Checkout

func (b *Bzr) Checkout(version string) error

Checkout checks out a version of the repository.

func (*Bzr) Clone

func (b *Bzr) Clone(url string) error

Clone downloads a repository if it doesn't exist on disk.

func (*Bzr) CurrentTag

func (b *Bzr) CurrentTag() (string, error)

CurrentTag retrieves the current tag of the repository, or empty string if no tag exists.

func (*Bzr) SetRepoPath

func (d *Bzr) SetRepoPath(path string)

SetRepoPath allows overriding of the path that was set on creation.

func (*Bzr) Status

func (b *Bzr) Status() error

Status performs a status check on the repository to see if it's actually a bzr repository.

func (*Bzr) Tags

func (b *Bzr) Tags() ([]string, error)

Tags gets the list of all tags for the repository.

func (*Bzr) Update

func (b *Bzr) Update() error

Update updates a repository from the default remote.

type ComparisonOp

type ComparisonOp int

ComparisonOp represents a boolean operator.

const (
	// Equal is the = operator.
	Equal ComparisonOp = iota + 1
	// NotEqual is the != operator.
	NotEqual
	// GreaterThan is the > operator.
	GreaterThan
	// LessThan is the < operator.
	LessThan
	// GreaterEqual is the >= operator.
	GreaterEqual
	// LessEqual is the <= operator.
	LessEqual
	// ApproxGreater is the ~ operator.
	// This operator means "greater than or equal to so long as the major
	// version is not incremented".
	ApproxGreater
)

Defines the comparison operator types.

func ParseOp

func ParseOp(str string) (op ComparisonOp, err error)

ParseOp parses an operation string into a comparison operator type.

func (ComparisonOp) String

func (op ComparisonOp) String() (str string)

String turns a comparison operator back into a string.

type Constraint

type Constraint struct {
	Operator ComparisonOp
	Version  *Version
}

Constraint is a constraint on a dependency.

type DVCS

type DVCS interface {
	// Status runs a status command to see if there's actually a usable dvcs
	// at this location.
	Status() error
	// Close creates a command used to clone with this engine.
	Clone(url string) error
	// Update creates a command to update the repository from a source.
	Update() error
	// Checkout creates a command to change the working copy to a specified
	// version.
	Checkout(version string) error
	// Tags creates a command to retrieve the list of tags.
	Tags() ([]string, error)
	// CurrentTag retrieves the current tag if there is one.
	CurrentTag() (string, error)
	// SetRepoPath allows overriding of the path that was set on creation.
	SetRepoPath(path string)
}

DVCS represents a distributed version control system.

func NewBzr

func NewBzr(repo string) DVCS

NewBzr returns a new instance of the bzr dvcs.

func NewGit

func NewGit(repo string) DVCS

NewGit returns a new instance of the git dvcs.

func NewHg

func NewHg(repo string) DVCS

NewHg returns a new instance of the hg dvcs.

type Dependency

type Dependency struct {
	Name        string
	Constraints []*Constraint
	URL         string
}

Dependency is a package dependency.

func ParseDependency

func ParseDependency(str string) (*Dependency, error)

ParseDependency parses a string into a Dependency.

func (*Dependency) GetYAML

func (v *Dependency) GetYAML() (_ string, value interface{})

GetYAML implements the goyaml Getter interface.

func (*Dependency) SetYAML

func (d *Dependency) SetYAML(_ string, value interface{}) (ok bool)

SetYAML implements the goyaml Setter interface.

func (*Dependency) String

func (d *Dependency) String() (str string)

String turns a Dependency into a String.

type Git

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

Git uses the git toolset to implement the dvcs interface.

func (*Git) Checkout

func (g *Git) Checkout(version string) error

Checkout checks out a version of the repository.

func (*Git) Clone

func (g *Git) Clone(url string) error

Clone downloads a repository if it doesn't exist on disk.

func (*Git) CurrentTag

func (g *Git) CurrentTag() (string, error)

CurrentTag retrieves the current tag of the repository, or empty string if no tag exists.

func (*Git) SetRepoPath

func (d *Git) SetRepoPath(path string)

SetRepoPath allows overriding of the path that was set on creation.

func (*Git) Status

func (g *Git) Status() error

Status performs a status check on the repository to see if it's actually a git repository.

func (*Git) Tags

func (g *Git) Tags() ([]string, error)

Tags gets the list of all tags for the repository.

func (*Git) Update

func (g *Git) Update() error

Update updates a repository from the default remote.

type Hg

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

Hg uses the mercurial toolset to implement the dvcs interface.

func (*Hg) Checkout

func (h *Hg) Checkout(version string) error

Checkout checks out a version of the repository.

func (*Hg) Clone

func (h *Hg) Clone(url string) error

Clone downloads a repository if it doesn't exist on disk.

func (*Hg) CurrentTag

func (h *Hg) CurrentTag() (string, error)

CurrentTag retrieves the current tag of the repository, or empty string if no tag exists.

func (*Hg) SetRepoPath

func (d *Hg) SetRepoPath(path string)

SetRepoPath allows overriding of the path that was set on creation.

func (*Hg) Status

func (h *Hg) Status() error

Status performs a status check on the repository to see if it's actually an hg repository.

func (*Hg) Tags

func (h *Hg) Tags() ([]string, error)

Tags gets the list of all tags for the repository.

func (*Hg) Update

func (h *Hg) Update() error

Update updates a repository from the default remote.

type Pack

type Pack struct {
	// Display name for the package, ImportPath's trailing name if not provided.
	Name string `yaml:",omitempty"`
	// The import path of the package.
	ImportPath string `yaml:",omitempty"`
	// Version
	Version *Version `yaml:",omitempty"`
	// Short description of the package.
	Summary string `yaml:",omitempty"`
	// Longer description of the package.
	Description string `yaml:",omitempty"`
	// Homepage
	Homepage string `yaml:",omitempty"`
	// Repository
	Repository *Repository `yaml:",omitempty"`
	// License type ie. MIT, LGPL-3.0+, GPL-3.0+, Apache-2.0
	License string `yaml:",omitempty"`
	// Authors
	Authors []*Author `yaml:",omitempty"`
	// Contributors
	Contributors []*Author `yaml:",omitempty"`
	// Support
	Support *Support `yaml:",omitempty"`
	// Dependencies of the package.
	Dependencies []*Dependency `yaml:",omitempty"`
	// Environments of the package.
	Environments map[string][]*Dependency `yaml:",omitempty"`
	// Subpackages are used to mark packages that should be tagged with this
	// same metadata. They must be subdirectories. This is useful for
	// having subpackages within the same vcs repository.
	Subpackages []string `yaml:",omitempty"`
}

Pack is the metadata of a package.

func ParsePack

func ParsePack(reader io.Reader) (*Pack, error)

ParsePack reads yaml from a reader and parses it into a pack object.

func ParsePackFile

func ParsePackFile(filename string) (p *Pack, err error)

ParsePackFile opens a file for reading and parses it into a Pack.

func (*Pack) WritePackFile

func (p *Pack) WritePackFile(filename string) (err error)

WritePackFile opens a file for writing and writes the Pack to it.

func (*Pack) WriteTo

func (p *Pack) WriteTo(writer io.Writer) error

WriteTo writes the pack object to the passed in writer.

type Paths

type Paths struct {
	Gopath        string
	Gopaths       []string
	GopackPath    string
	GopacksetPath string
	CombinedPath  string
	// contains filtered or unexported fields
}

Paths contains all the paths used by gopack.

func NewPaths

func NewPaths(gopath, packset string) (*Paths, error)

NewPaths uses the environment to locate all the paths to be used and returns them in a paths variable.

func NewPathsFromGopath

func NewPathsFromGopath(packset string) (*Paths, error)

NewPathsFromGopath creates a new paths based on the gopath from the env.

func (*Paths) GopathRestore

func (p *Paths) GopathRestore()

GopathRestore restores the original gopath variable.

func (*Paths) GopathSet

func (p *Paths) GopathSet()

GopathAppend adds the combined path to the current gopath.

func (*Paths) PackageExists

func (p *Paths) PackageExists(imp string) (string, bool, error)

PackageExists checks a packages existence. If it exists it will return a path, the boolean indicates if it was in the GOPACKPATH.

func (*Paths) Packset

func (p *Paths) Packset() string

Packset returns the current packset.

func (*Paths) SetPackset

func (p *Paths) SetPackset(packset string)

SetPackset updates the packset and all paths that include packset.

type Repository

type Repository struct {
	// Type can be one of: git/mercurial/bazaar
	Type string `yaml:",omitempty"`
	URL  string `yaml:",omitempty"`
}

Repository is a version control repository endpoint.

type Support

type Support struct {
	Website string `yaml:",omitempty"`
	Email   string `yaml:",omitempty"`
	Forum   string `yaml:",omitempty"`
	Wiki    string `yaml:",omitempty"`
	Issues  string `yaml:",omitempty"`
}

Support contains the locations at which to find support for the package.

type Version

type Version struct {
	// Major version of the package.
	Major uint
	// Minor version of the package.
	Minor uint
	// Patch version of the package.
	Patch uint
	// Release version of the package.
	Release string
}

Version is a semantic version number with an optional comparison operator. For example: 2.1.0-alpha.1 2 = Major, 1 = Minor, 0 = Patch, alpha.1 = Release For a more thorough explanation see: http://semver.org/

func ParseVersion

func ParseVersion(str string) (version *Version, err error)

ParseVersion parses a string into a version.

func (*Version) GetYAML

func (v *Version) GetYAML() (_ string, value interface{})

GetYAML implements the goyaml Getter interface.

func (*Version) Satisfies

func (b *Version) Satisfies(op ComparisonOp, c *Version) (ok bool)

Satisfies checks that the base version (lhs) satisfies the condition version (rhs). Example: 2.0.0 is the base version, and <=2.1.3 is the condition version will return true. Comparison is according to http://semver.org/

func (*Version) SetYAML

func (v *Version) SetYAML(_ string, value interface{}) (ok bool)

SetYAML implements the goyaml Setter interface.

func (Version) String

func (v Version) String() string

String changes the version into a string representation.

func (*Version) Zero

func (v *Version) Zero() bool

Zero checks to see if this is a completely zero'd Version.

Jump to

Keyboard shortcuts

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