v2.0.2+incompatible Latest Latest

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

Go to latest
Published: Jul 8, 2017 License: MIT Imports: 7 Imported by: 0



Package configlet sanity-checks Exercism track configuration.

A track consists of a collection of exercises in a single programming language. Each problem has a test suite, a sample solution, and any supporting files that are necessary to solve the exercise.

The configuration serves two purposes:

1. It helps implementors ensure that all the exercises are valid.

2. It provides the API with a sort order for delivering exercises.



This section is empty.


This section is empty.


This section is empty.


type Config

type Config struct {
	Slug            string
	Language        string
	Active          bool
	Repository      string
	Exercises       []Exercise
	Deprecated      []string
	Foregone        []string
	SolutionPattern string `json:"solution_pattern"`
	// contains filtered or unexported fields

Config is an Exercism track configuration.

func Load

func Load(file string) (Config, error)

Load loads an Exercism track configuration.

func NewConfig added in v1.1.0

func NewConfig() Config

NewConfig creates a new Config with optional defaults set. Currently the only optional value is SolutionPattern which is used to work out if an exercise has a sample solution.

func (Config) Slugs added in v1.0.6

func (c Config) Slugs() []string

Slugs is the list of exercise identifiers for the track.

type Exercise added in v1.0.6

type Exercise struct {
	Slug       string
	Difficulty int
	Topics     []string

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

type Track

type Track struct {
	// contains filtered or unexported fields

Track is a collection of Exercism exercises in a given programming language.

func NewTrack

func NewTrack(path string) (Track, error)

NewTrack is an exercism language track that lives at path. It uses the config.json in the root of the track to figure out which exercises a track contains.

func (Track) Config

func (t Track) Config() (Config, error)

Config loads a track's configuration.

func (Track) Dirs

func (t Track) Dirs() (map[string]struct{}, error)

Dirs is a list of all the relevant directories.

func (Track) DuplicateSlugs

func (t Track) DuplicateSlugs() ([]string, error)

DuplicateSlugs detects slugs in multiple config categories. If a problem is deprecated, it means that we have the files for it, we're just not serving it in the default response. If a slug is foregone, it means that we've chosen not to implement it, and it should not have a directory.

func (Track) ForegoneViolations

func (t Track) ForegoneViolations() ([]string, error)

ForegoneViolations indentifies implementations that should not be included. This could be because the problem is too trivial, ridiculously non-trivial, or simply uninteresting.

func (Track) HasValidConfig

func (t Track) HasValidConfig() bool

HasValidConfig lints the JSON file.

func (Track) MissingProblems

func (t Track) MissingProblems() ([]string, error)

MissingProblems identify problems lacking an implementation. This will complain if the problem slug is listed in the configuration, but there is no corresponding directory for it.

func (Track) Problems

func (t Track) Problems() (map[string]struct{}, error)

Problems lists all the problem specifications that a track has implemented exercises for.

func (Track) ProblemsLackingExample

func (t Track) ProblemsLackingExample() ([]string, error)

ProblemsLackingExample identifies implementations without a solution. This will often be triggered because the implementation's sample solution is not named something with example. This is particularly critical since any file that is in a path not named /[Ee]xample/ will be served by the API, showing the user a possible solution before they have solved the problem themselves.

func (Track) Slugs

func (t Track) Slugs() (map[string]struct{}, error)

Slugs is a list of all problems mentioned in the config.

func (Track) UnconfiguredProblems

func (t Track) UnconfiguredProblems() ([]string, error)

UnconfiguredProblems identifies unlisted implementations. This will complain if a directory exists, but is not mentioned anywhere in the config file.

Jump to

Keyboard shortcuts

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