env

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2018 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName    = `uru`
	AppVersion = `0.8.5`
)
View Source
const (
	RubyRegistryVersion = `1.0.0`
)

Variables

View Source
var (
	RbMajMinRegex, SysRbRegex *regexp.Regexp
	KnownRubies               []string
)
View Source
var BashWrapper = `` /* 301-byte string literal not displayed */
View Source
var FishWrapper = `` /* 317-byte string literal not displayed */

Functions

func CopyFile

func CopyFile(dst, src string) (written int64, err error)

CopyFile copies a source file to a destination file.

func CreateSwitcherScript

func CreateSwitcherScript(ctx *Context, path *[]string, gemHome string) (scriptName string, err error)

CreateSwitcherScript creates an environment switcher script customized to the type of shell calling the uru runtime.

func DelUruChunk added in v0.8.1

func DelUruChunk(uruChunk, basePath string) (cleanPath []string)

DelUruChunk returns a PATH string list purged of the uru chunk described in GetUruChunk. This func assumes the provided base PATH string contains a valid uru chunk.

func GetUruChunk added in v0.8.1

func GetUruChunk(path string) (string, bool)

GetUruChunk analyzes a PATH string and returns everything between uru's two canaries, inclusive, and a success/failure indicator. The uru chunk string is returned upon success, and an empty string is returned upon failure to find a valid uru chunk.

A uru enhanced PATH containing the uru chunk looks like

[USER_PREFIX];canary[0];[GEM_HOME_BIN_DIR];RUBY_BIN_DIR;canary[1];...  (Windows)

                         -or-

[USER_PREFIX]:canary[0]:[GEM_HOME_BIN_DIR]:RUBY_BIN_DIR:canary[1]:...  (Linux, OSX)

where the GEM_HOME_BIN_DIR and USER_PREFIX elements are optional. USER_PREFIX can be zero or more PATH components added by the user after the user activates a registered ruby with uru.

The uru chunk attempts to sandbox uru's PATH infection tactics. It has the following format

canary[0]:[GEM_HOME_BIN_DIR]:RUBY_BIN_DIR:canary[1]

For example

_U1_:/home/foo/.gem/ruby/2.2.0/bin:/home/foo/.rubies/ruby-2.2/bin:_U2_

The uru chunk enables uru to modify the PATH in a more controllable way while minimizing the number of scenarios where uru clobbers user PATH mods made after using uru to activate a registered ruby.

func NewTag

func NewTag(ctx *Context, rb Ruby) (tagHash string, err error)

NewTag generates a new tag hash value used to identify a specific ruby.

func PathListForTagHash added in v0.8.1

func PathListForTagHash(ctx *Context, tagHash string) (newPath []string, err error)

PathListForTagHash returns a PATH list appropriate for a given registered ruby's tag hash. A tag hash is an uru internal indentifier used for indexing a user's registered rubies.

func SelectRubyFromList

func SelectRubyFromList(tags RubyMap, label, verb string) (tagHash string, err error)

SelectRubyFromList presents a list of registered rubies and asks the user to select one. It returns the internal identifying tag hash for the selected ruby, or an error if unable to get the users selection.

func SortTagsByTagLabel

func SortTagsByTagLabel(rubyMap *RubyMap) (sortedTagHashes []string, err error)

SortTagsByTagLabel returns a string slice of tag hashes sorted by tag label.

func UIYesConfirm

func UIYesConfirm(prompt string) (resp string, err error)

UIYesConfirm asks the user a question and returns Y or N with Y being the default.

Types

type Context

type Context struct {
	Registry RubyRegistry
	// contains filtered or unexported fields
}

func NewContext

func NewContext() *Context

func (*Context) Cmd

func (c *Context) Cmd() string

func (*Context) CmdArgs

func (c *Context) CmdArgs() []string

func (*Context) Home

func (c *Context) Home() string

func (*Context) SetCmd

func (c *Context) SetCmd(cmd string)

func (*Context) SetCmdAndArgs

func (c *Context) SetCmdAndArgs(cmd string, args []string)

func (*Context) SetCmdArgs

func (c *Context) SetCmdArgs(args []string)

func (*Context) SetHome

func (c *Context) SetHome(h string)

type MarshalFunc

type MarshalFunc func(ctx *Context) error

type Ruby

type Ruby struct {
	ID          string // ruby version including patch number
	TagLabel    string // user friendly ruby tag value
	Exe         string // ruby executable name
	Home        string // full path to ruby executable directory
	GemHome     string // full path to a ruby's gem home directory
	Description string // full ruby description
}

func CurrentRubyInfo

func CurrentRubyInfo(ctx *Context) (tagHash string, info Ruby, err error)

CurrentRubyInfo returns the internal identifying tag hash and metadata info for the currently activated, registered ruby.

func RubyInfo

func RubyInfo(ctx *Context, ruby string) (tagHash string, info Ruby, err error)

RubyInfo returns an internal identifying tag hash and metadata information about a specific ruby. It accepts a string of either the simple name of the ruby executable, or the ruby executable's absolute path.

type RubyMap

type RubyMap map[string]Ruby

The string uru uses to identify a particular Ruby is known as the ruby's "tag hash". The tag hash is a non-user, internal token generated when the user registers a ruby with uru.

func TagLabelToTag

func TagLabelToTag(ctx *Context, label string) (tags RubyMap, err error)

TagLabelToTag returns a map of registered ruby tags whose TagLabel's match that of the specified tag label string.

TODO review for refactoring with VersionFragmentToTag

func VersionFragmentToTag added in v0.8.5

func VersionFragmentToTag(ctx *Context, fragment string) (tags RubyMap, err error)

VersionFragmentToTag returns a map of registered ruby tag's whose TagLabel or Description fields fuzzy that match the given version fragment string.

VersionFragmentToTag is less strict than its related TagLabelToTag function in that it fuzzy matches first against TagLabel and then against Description.

type RubyRegistry

type RubyRegistry struct {
	Version string
	Rubies  RubyMap
	// contains filtered or unexported fields
}

func (*RubyRegistry) Marshal

func (rr *RubyRegistry) Marshal(ctx *Context) (err error)

Jump to

Keyboard shortcuts

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