track

package
v3.9.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2018 License: MIT Imports: 11 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// ProblemSpecificationsDir is the default name of the cloned problem-specifications repository.
	ProblemSpecificationsDir = "problem-specifications"
)

Variables

View Source
var (
	// ProblemSpecificationsPath is the location of the cloned problem-specifications repository.
	ProblemSpecificationsPath string
)

Functions

This section is empty.

Types

type Config

type Config struct {
	TrackID        string `json:"track_id,omitempty"`
	Language       string `json:"language"`
	Active         bool   `json:"active"`
	Blurb          string `json:"blurb"`
	Gitter         string `json:"gitter,omitempty"`
	ChecklistIssue int    `json:"checklist_issue,omitempty"`
	PatternGroup
	ForegoneSlugs   []string           `json:"foregone,omitempty"`
	Exercises       []ExerciseMetadata `json:"exercises"`
	DeprecatedSlugs []string           `json:"deprecated,omitempty"`
}

Config is an Exercism track configuration.

func NewConfig

func NewConfig(path string) (Config, error)

NewConfig loads a track configuration file. The config has a default solution and test pattern if not provided in the file. The solution pattern is used to determine if an exercise has a sample solution. The test pattern is used to determine if an exercise has a test suite. The ignore pattern is used to exclude files from the 'exercism fetch' command.

func (*Config) LoadFromFile

func (cfg *Config) LoadFromFile(path string) error

LoadFromFile loads a config from file given the path to the file.

func (*Config) ToJSON

func (cfg *Config) ToJSON() ([]byte, error)

ToJSON marshals the Config to normalized JSON.

type Exercise

type Exercise struct {
	Slug          string
	ReadmePath    string
	SolutionPath  string
	TestSuitePath string
}

Exercise is an implementation of an Exercism exercise.

func NewExercise

func NewExercise(root string, pg PatternGroup) (Exercise, error)

NewExercise loads an exercise.

func (Exercise) HasReadme

func (ex Exercise) HasReadme() bool

HasReadme checks that an exercise has a README.

func (Exercise) HasTestSuite

func (ex Exercise) HasTestSuite() bool

HasTestSuite checks that an exercise has a test suite.

func (Exercise) IsValid

func (ex Exercise) IsValid() bool

IsValid checks that an exercise has a sample solution.

type ExerciseMetadata

type ExerciseMetadata struct {
	Slug         string   `json:"slug"`
	UUID         string   `json:"uuid"`
	IsCore       bool     `json:"core"`
	AutoApprove  bool     `json:"auto_approve,omitempty"`
	UnlockedBy   *string  `json:"unlocked_by"`
	Difficulty   int      `json:"difficulty"`
	Topics       []string `json:"topics"`
	IsDeprecated bool     `json:"deprecated,omitempty"`
}

ExerciseMetadata contains metadata about an implemented exercise. It's listed in the config in the order that the exercise will be delivered by the API.

type ExerciseReadme

type ExerciseReadme struct {
	Spec        *ProblemSpecification
	Hints       string
	TrackInsert string
	// contains filtered or unexported fields
}

ExerciseReadme contains the data necessary to generate a README for an Exercism exercise.

func NewExerciseReadme

func NewExerciseReadme(root, trackID, slug string) (ExerciseReadme, error)

NewExerciseReadme locates and reads all the data to create an ExerciseReadme.

func (ExerciseReadme) Generate

func (readme ExerciseReadme) Generate() (string, error)

Generate produces a README from the template and data.

func (ExerciseReadme) Write

func (readme ExerciseReadme) Write() error

Write generates and writes the README to a file.

type Maintainer

type Maintainer struct {
	Username      string  `json:"github_username"`
	Alumnus       bool    `json:"alumnus"`
	ShowOnWebsite bool    `json:"show_on_website"`
	Name          *string `json:"name"`
	LinkText      *string `json:"link_text"`
	LinkURL       *string `json:"link_url"`
	AvatarURL     *string `json:"avatar_url"`
	Bio           *string `json:"bio"`
}

Maintainer contains data about a track maintainer.

type MaintainerConfig

type MaintainerConfig struct {
	DocsURL     string       `json:"docs_url"`
	Maintainers []Maintainer `json:"maintainers"`
}

MaintainerConfig contains the list of current and previous maintainers. The files is used both to manage the GitHub maintainer team, as well as to configure the display values for each maintainer on the Exercism website.

func NewMaintainerConfig

func NewMaintainerConfig(path string) (MaintainerConfig, error)

NewMaintainerConfig reads the maintainer config file, if present.

func (*MaintainerConfig) LoadFromFile

func (mCfg *MaintainerConfig) LoadFromFile(path string) error

LoadFromFile loads a config from file given the path to the file.

func (MaintainerConfig) ToJSON

func (mCfg MaintainerConfig) ToJSON() ([]byte, error)

ToJSON marshals the Config to normalized JSON.

type PatternGroup

type PatternGroup struct {
	IgnorePattern   string `json:"ignore_pattern,omitempty"`
	SolutionPattern string `json:"solution_pattern,omitempty"`
	TestPattern     string `json:"test_pattern,omitempty"`
}

PatternGroup holds matching patterns defined in an Exercism track configuration.

type ProblemSpecification

type ProblemSpecification struct {
	Slug        string
	Description string
	Title       string `yaml:"title"`
	Source      string `yaml:"source"`
	SourceURL   string `yaml:"source_url"`
	// contains filtered or unexported fields
}

ProblemSpecification contains metadata describing an exercise.

func NewProblemSpecification

func NewProblemSpecification(root, trackID, slug string) (*ProblemSpecification, error)

NewProblemSpecification loads the specification from files on disk. It will default to a custom specification, falling back to the generic specification if no custom one is found.

func (*ProblemSpecification) Credits

func (spec *ProblemSpecification) Credits() string

Credits are a markdown-formatted version of the source of the exercise.

func (*ProblemSpecification) MixedCaseName

func (spec *ProblemSpecification) MixedCaseName() string

MixedCaseName returns the name with all spaces removed.

func (*ProblemSpecification) Name

func (spec *ProblemSpecification) Name() string

Name is a readable version of the slug.

func (*ProblemSpecification) SnakeCaseName

func (spec *ProblemSpecification) SnakeCaseName() string

SnakeCaseName converts the slug to snake case.

type Track

type Track struct {
	ID               string
	Config           Config
	MaintainerConfig MaintainerConfig
	Exercises        []Exercise
	// contains filtered or unexported fields
}

Track is a collection of Exercism exercises for a programming language.

func New

func New(path string) (Track, error)

New loads a track.

Jump to

Keyboard shortcuts

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