workspace

package
v3.0.8+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsMissingMetadata

func IsMissingMetadata(err error) bool

IsMissingMetadata verifies the type of error.

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.

Types

type Document

type Document struct {
	Root         string
	RelativePath string
}

Document is a file in a directory.

func NewDocument

func NewDocument(root, path string) (Document, error)

NewDocument creates a document from the filepath. The root is typically the root of the exercise, and path is the absolute path to the file.

func (Document) Filepath

func (doc Document) Filepath() string

Filepath is the absolute path to the document on the filesystem.

func (Document) Path

func (doc Document) Path() string

Path is the normalized path. It uses forward slashes regardless of the operating system.

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 Exercise

type Exercise struct {
	Root      string
	Track     string
	Slug      string
	Documents []Document
}

Exercise is an implementation of a problem in a track.

func NewExerciseFromDir

func NewExerciseFromDir(dir string) Exercise

NewExerciseFromDir constructs an exercise given the exercise directory.

func (Exercise) Filepath

func (e Exercise) Filepath() string

Filepath is the absolute path on the filesystem.

func (Exercise) HasMetadata

func (e Exercise) HasMetadata() (bool, error)

HasMetadata checks for the presence of an exercise metadata file. If there is no such file, this may be a legacy exercise. It could also be an unrelated directory.

func (Exercise) MetadataDir

func (e Exercise) MetadataDir() string

MetadataDir returns the directory that the exercise metadata lives in. For now this is the exercise directory.

func (Exercise) MetadataFilepath

func (e Exercise) MetadataFilepath() string

MetadataFilepath is the absolute path to the exercise metadata.

func (Exercise) Path

func (e Exercise) Path() string

Path is the normalized relative path. It always has forward slashes, regardless of the operating system.

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"`
	Team        string     `json:"team,omitempty"`
	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) Exercises

func (ws Workspace) Exercises() ([]Exercise, error)

Exercises returns the user's exercises within the workspace. This doesn't find legacy exercises where the metadata is missing.

func (Workspace) PotentialExercises

func (ws Workspace) PotentialExercises() ([]Exercise, error)

PotentialExercises are a first-level guess at the user's exercises. It looks at the workspace structurally, and guesses based on the location of the directory. E.g. any top level directory within the workspace (except 'users') is assumed to be a track, and any directory within there again is assumed to be an exercise.

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.

Jump to

Keyboard shortcuts

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