Documentation ¶
Overview ¶
Package group defines the concept of a group which is an ordered list of playable items
Package index defines functionality for creating and manipulating a Tchaik music index.
Index ¶
- Constants
- func BuildWordIndex(c Collection, fields []string) *wordIndex
- func Convert(l Library, id string) *library
- func ParallelSort(s sort.Interface, w Swaper) sort.Interface
- func Sort(tracks []Track, f LessFn)
- func SortKeysByGroupName(c Collection)
- func Walk(g Group, p Path, f WalkFn)
- func WriteTo(l Library, w io.Writer) error
- type Attr
- type ByAttr
- type ByPrefix
- type Collection
- type Collector
- type Expander
- type FilterItem
- type FilterItemSlice
- type FlatSearcher
- type Group
- type Key
- type LessFn
- type Library
- type Path
- type PathSlice
- type PrefixMultiExpand
- type Searcher
- type Swaper
- type Track
- type Tracker
- type TransformFn
- type WalkFn
- type WordIndex
Constants ¶
const MinPrefix = 3
MinPrefix is the minimum number of characters that can be used in a prefix.
const PathSeparator string = ":"
Path separator is a string used to separate path components.
Variables ¶
This section is empty.
Functions ¶
func BuildWordIndex ¶
func BuildWordIndex(c Collection, fields []string) *wordIndex
BuildWordIndex creates a *wordIndex ()
func Convert ¶
Convert reads all the data exported by the Library and writes into the standard tchaik Library implementation. NB: The identifier field is set to be the value of TrackID on every track, regardless of whether this value has already been set in the input Library.
func ParallelSort ¶
ParallelSort combines a sort.Interface implementation with a Swaper, and performs the same swap operations to w as they are applied to s.
func SortKeysByGroupName ¶
func SortKeysByGroupName(c Collection)
SorkKeysByGroupName sorts the names of the given collection (in place). In particular, this assumes that g.Names() returns the actual internal representation of the listing.
Types ¶
type Attr ¶
type Attr struct {
// contains filtered or unexported fields
}
Attr is a type which wraps a closure to get an attribute from an implementation of the Attr interface.
func IntAttr ¶
IntAttr constructs a Attr which will retrieve the int field from an implementation of Attr.
func StringAttr ¶
StringAttr constructs a Attr which will retrieve the string field from an implementation of Attr.
type ByAttr ¶
type ByAttr Attr
ByAttr is a type which implements Collector, and groups elements by the value of the attribute given by the underlying Attr instance.
func (ByAttr) Collect ¶
func (a ByAttr) Collect(tracker Tracker) Collection
type ByPrefix ¶
type ByPrefix string
ByPrefix is a type which creates a collection of tracks using a common prefix.
func (ByPrefix) Collect ¶
func (p ByPrefix) Collect(t Tracker) Collection
type Collection ¶
type Collection interface { Group // Keys returns a slice of Keys which give an ordering for Groups in the Collection. Keys() []Key // Get returns the Group corresponding to the given Key. Get(Key) Group }
Collection is an interface which represents an ordered series of Groups.
func Collect ¶
func Collect(t Tracker, c Collector) Collection
Collect applies the Collector to the Tracker and returns the resulting Collection.
func NewPathsCollection ¶
func NewPathsCollection(src Collection, paths []Path) Collection
NewCollection creates a new collection from a source collection `c` which will have the groups represented by the given list of paths. All the paths are assumed to be unique, an of at least length 2.
func SubCollect ¶
func SubCollect(c Collection, r Collector) Collection
SubCollect applies the given Collector to each of the "leaf-Groups" in the Collection.
func SubTransform ¶
func SubTransform(c Collection, fn TransformFn) Collection
SubTransform recursively applies the TransformFn to each Group in the Collection.
type Collector ¶
type Collector interface {
Collect(Tracker) Collection
}
Collector is an interface which defines the Collect method.
type Expander ¶
type Expander interface { // Expand the given string, returning the result and true if succesful, or false // otherwise. Expand(string) ([]string, bool) }
Expander is an interface which implements the Expand method.
type FilterItem ¶
func Filter ¶
func Filter(c Collection, field string) []FilterItem
type FilterItemSlice ¶
type FilterItemSlice []FilterItem
func (FilterItemSlice) Len ¶
func (f FilterItemSlice) Len() int
func (FilterItemSlice) Less ¶
func (f FilterItemSlice) Less(i, j int) bool
func (FilterItemSlice) Swap ¶
func (f FilterItemSlice) Swap(i, j int)
type FlatSearcher ¶
type FlatSearcher struct {
Searcher
}
FlatSearcher is a Searcher wrapper which flattens input strings (replaces any accented characters with their un-accented equivalents).
func (FlatSearcher) Search ¶
func (f FlatSearcher) Search(s string) []Path
type Group ¶
type Group interface { Tracker // Name returns the name of the group. Name() string // Field returns the value of a field. Field(string) interface{} }
Group is an interface which represents a named group of Tracks.
func CommonGroupAttr ¶
CommonGroupAttr recurses through the Group and assigns fields on all sub groups which are common amoungst their children (Groups or Tracks). If there is no common field, then the associated Field value is not set.
func FirstTrackAttr ¶
FirstTrackAttr wraps the given Group adding a string field `field` with the value taken from the first track.
func RemoveEmptyCollections ¶
RemoveEmptyCollections recursively goes through each sub Collection contained in the Group and removes any which don't have any tracks/groups in them.
func SumGroupIntAttr ¶
SumGroupIntAttr recurses through the Group and assigns the field with the sum of fields from children (Groups or Tracks).
func Transform ¶
func Transform(g Group, fn TransformFn) Group
Transform applies the TransformFn to the Group and returns the result.
func TrimEnumPrefix ¶
TrimEnumPrefix removes enumeratative prefixes from the Tracks in the Group. The resulting group will have a ListStyle field which will indicate the style of enumeration (if any).
type Key ¶
type Key string
Key represents a unique value used to represent a group within a collection.
type LessFn ¶
LessFn is a function type used for evaluating
func SortByInt ¶
SortByInt returns a LessFn which orders Tracks using the GetInt Attr on the given field.
func SortByString ¶
SortByString returns a LessFn which orders Tracks using the GetString Attr on the given field.
func SortByTime ¶
SortByTime returns a LessFn which orders Tracks using the GetTime Attr on the given field.
type Library ¶
type Library interface { // Tracks returns a slice of all the tracks in the library. Tracks() []Track // Track returns the track from the given identifier, second return value true // if successful. Track(identifier string) (Track, bool) }
Library is an interface which defines methods for listing tracks.
type Path ¶
type Path []Key
Path is type which represents a position in the index heirarchy. Each level has a key, and so the path is a slice of strings where each element is the key of some index element (group or track).
func OrderedIntersection ¶
Compute the intersection of the given lists of paths.
func Recent ¶
func Recent(c Collection, n int) []Path
type PathSlice ¶
type PathSlice []Path
PathSlice is a wrapper type implementing sort.Interface (and index.Swapper)
type PrefixMultiExpand ¶
type PrefixMultiExpand struct {
// contains filtered or unexported fields
}
PrefixMultiExpand is a type which implements Expander
func BuildPrefixMultiExpander ¶
func BuildPrefixMultiExpander(words []string, n int) PrefixMultiExpand
BuildPrefixMultiExpander builds an Expander with given length n. All words mapped to by prefixes will have length greater than or equal to MinPrefix.
type Searcher ¶
type Searcher interface { // Search uses the given string to filter a list of paths. Search(string) []Path }
Searcher is an interface which defines the Search method.
func BuildPrefixExpandSearcher ¶
BuildPrefixExpandSearcher constructs a prefix expander which wraps the given Searcher by expanding each word in the search input using the WordIndex.
func WordsIntersectSearcher ¶
WordsSearchIntersect calls Search on the Searcher for each word in the input string and then returns the ordered intersection (Paths are ordered by the number of times they appear.
type Swaper ¶
type Swaper interface { // Swap the items at indices i and j. Swap(i, j int) }
Swapper is an interface which defines the Swap method.
type Track ¶
type Track interface { // GetString returns the string attribute with given name. GetString(string) string // GetInt returns the int attribute with given name. GetInt(string) int // GetTime returns the time attribute with given name. GetTime(string) time.Time }
Track is an interface which defines a music file.
type Tracker ¶
type Tracker interface {
Tracks() []Track
}
Tracker is an interface which defines the Tracks method which returns a list of Tracks.
type TransformFn ¶
TransformFn is a type which represents a function which Transforms a Group into another.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package history implements functionality for fetching/adding to play history.
|
Package history implements functionality for fetching/adding to play history. |
Package rating defines types and methods for setting/getting ratings for paths and persisting this data.
|
Package rating defines types and methods for setting/getting ratings for paths and persisting this data. |
Package walk implements a path walker which reads audio files under a path and constructs an index.Library from supported metadata tags (see github.com/dhowden/tag).
|
Package walk implements a path walker which reads audio files under a path and constructs an index.Library from supported metadata tags (see github.com/dhowden/tag). |