workspace

package
v3.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2018 License: MIT Imports: 10 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotExist

func IsNotExist(err error) bool

IsNotExist checks if this is an ErrNotExist error.

func IsNotInWorkspace

func IsNotInWorkspace(err error) bool

IsNotInWorkspace checks if this is an ErrNotInWorkspace error.

func IsSolutionPath

func IsSolutionPath(solutionID, path string) (bool, error)

IsSolutionPath checks whether the given path contains the solution with the given ID.

Types

type ErrNotExist

type ErrNotExist string

ErrNotExist signals that the target directory could not be located.

func (ErrNotExist) Error

func (err ErrNotExist) Error() string

type ErrNotInWorkspace

type ErrNotInWorkspace string

ErrNotInWorkspace signals that the target directory is outside the configured workspace.

func (ErrNotInWorkspace) Error

func (err ErrNotInWorkspace) Error() string

type PathType

type PathType int

PathType is either a path to a dir or file, or the name of an exercise.

const (
	// TypeExerciseID is the name of an exercise.
	TypeExerciseID PathType = iota
	// TypeDir is a relative or absolute path to a directory.
	TypeDir
	// TypeFile is a relative or absolute path to a file.
	TypeFile
)

func DetectPathType

func DetectPathType(path string) (PathType, error)

DetectPathType determines whether the given path is a directory, a file, or the name of an exercise.

type Solution

type Solution struct {
	Track       string     `json:"track"`
	Exercise    string     `json:"exercise"`
	ID          string     `json:"id"`
	URL         string     `json:"url"`
	Handle      string     `json:"handle"`
	IsRequester bool       `json:"is_requester"`
	SubmittedAt *time.Time `json:"submitted_at,omitempty"`
	Dir         string     `json:"-"`
	AutoApprove bool       `json:"auto_approve"`
}

Solution contains metadata about a user's solution.

func NewSolution

func NewSolution(dir string) (*Solution, error)

NewSolution reads solution metadata from a file in the given directory.

func (*Solution) PathToParent

func (s *Solution) PathToParent() string

PathToParent is the relative path from the workspace to the parent dir.

func (*Solution) String

func (s *Solution) String() string

func (*Solution) Suffix

func (s *Solution) Suffix() string

Suffix is the serial numeric value appended to an exercise directory. This is appended to avoid name conflicts, and does not indicate a particular iteration.

func (*Solution) Write

func (s *Solution) Write(dir string) error

Write stores solution metadata to a file.

type Solutions

type Solutions []*Solution

Solutions is a collection of solutions to interactively choose from.

func NewSolutions

func NewSolutions(paths []string) (Solutions, error)

NewSolutions loads up the solution metadata for each of the provided paths.

type Workspace

type Workspace struct {
	Dir string
}

Workspace represents a user's Exercism workspace. It may contain a user's own exercises, and other people's exercises that they've downloaded to look at or run locally.

func New

func New(dir string) (Workspace, error)

New returns a configured workspace.

func (Workspace) Locate

func (ws Workspace) Locate(exercise string) ([]string, error)

Locate the matching directories within the workspace. This will look for an exact match on absolute or relative paths. If given the base name of a directory with no path information it It will look for all directories with that name, or that are named with a numerical suffix.

func (Workspace) ResolveSolutionPath

func (ws Workspace) ResolveSolutionPath(paths []string, exercise, solutionID string, existsFn func(string, string) (bool, error)) (string, error)

ResolveSolutionPath determines the path for the given exercise solution. It will locate an existing path, or indicate the name of a new path, if this is a new solution.

func (Workspace) SolutionDir

func (ws Workspace) SolutionDir(s string) (string, error)

SolutionDir determines the root directory of a solution. This is the directory that contains the solution metadata file.

func (Workspace) SolutionPath

func (ws Workspace) SolutionPath(exercise, solutionID string) (string, error)

SolutionPath returns the full path where the exercise will be stored. By default this the directory name matches that of the exercise, but if a different solution already exists, then a numeric suffix will be added to the name.

Jump to

Keyboard shortcuts

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