Documentation ¶
Index ¶
- func IsMissingMetadata(err error) bool
- func IsNotExist(err error) bool
- func IsNotInWorkspace(err error) bool
- type Document
- type ErrNotExist
- type ErrNotInWorkspace
- type Exercise
- func (e Exercise) Filepath() string
- func (e Exercise) HasLegacyMetadata() (bool, error)
- func (e Exercise) HasMetadata() (bool, error)
- func (e Exercise) LegacyMetadataFilepath() string
- func (e Exercise) MetadataDir() string
- func (e Exercise) MetadataFilepath() string
- func (e Exercise) MigrateLegacyMetadataFile() (MigrationStatus, error)
- func (e Exercise) Path() string
- type ExerciseMetadata
- type MigrationStatus
- type PathType
- type Workspace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsMissingMetadata ¶
IsMissingMetadata verifies the type of error.
func IsNotExist ¶
IsNotExist checks if this is an ErrNotExist error.
func IsNotInWorkspace ¶
IsNotInWorkspace checks if this is an ErrNotInWorkspace error.
Types ¶
type Document ¶
Document is a file in a directory.
func NewDocument ¶
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.
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 ¶
Exercise is an implementation of a problem in a track.
func NewExerciseFromDir ¶
NewExerciseFromDir constructs an exercise given the exercise directory.
func (Exercise) HasLegacyMetadata ¶
HasLegacyMetadata checks for the presence of a legacy exercise metadata file. If there is no such file, it could also be an unrelated directory.
func (Exercise) HasMetadata ¶
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) LegacyMetadataFilepath ¶
LegacyMetadataFilepath is the absolute path to the legacy exercise metadata.
func (Exercise) MetadataDir ¶
MetadataDir returns the directory that the exercise metadata lives in. For now this is the exercise directory.
func (Exercise) MetadataFilepath ¶
MetadataFilepath is the absolute path to the exercise metadata.
func (Exercise) MigrateLegacyMetadataFile ¶
func (e Exercise) MigrateLegacyMetadataFile() (MigrationStatus, error)
MigrateLegacyMetadataFile migrates a legacy metadata file to the modern location. This is a noop if the metadata file isn't legacy. If both legacy and modern metadata files exist, the legacy file will be deleted.
type ExerciseMetadata ¶
type ExerciseMetadata 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"` }
ExerciseMetadata contains metadata about a user's exercise.
func NewExerciseMetadata ¶
func NewExerciseMetadata(dir string) (*ExerciseMetadata, error)
NewExerciseMetadata reads exercise metadata from a file in the given directory.
func (*ExerciseMetadata) PathToParent ¶
func (em *ExerciseMetadata) PathToParent() string
PathToParent is the relative path from the workspace to the parent dir.
func (*ExerciseMetadata) String ¶
func (em *ExerciseMetadata) String() string
func (*ExerciseMetadata) Suffix ¶
func (em *ExerciseMetadata) 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 (*ExerciseMetadata) Write ¶
func (em *ExerciseMetadata) Write(dir string) error
Write stores exercise metadata to a file.
type MigrationStatus ¶
type MigrationStatus int
MigrationStatus represents the result of migrating a legacy metadata file.
const ( MigrationStatusNoop MigrationStatus = iota MigrationStatusMigrated MigrationStatusRemoved )
MigrationStatus
func (MigrationStatus) String ¶
func (m MigrationStatus) String() string
type PathType ¶
type PathType int
PathType is either a path to a dir or file, or the name of an exercise.
func DetectPathType ¶
DetectPathType determines whether the given path is a directory, a file, or the name of an exercise.
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 (Workspace) ExerciseDir ¶
ExerciseDir determines the root directory of an exercise. This is the directory that contains the exercise metadata file.
func (Workspace) Exercises ¶
Exercises returns the user's exercises within the workspace. This doesn't find legacy exercises where the metadata is missing.
func (Workspace) PotentialExercises ¶
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.