config

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2020 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// BasenameRegexps matches on allowed names of the configuration file.
	BasenameRegexp = regexp.MustCompile(`(?i)^(dsk|dsk\.(json|ya?ml))$`)
)

Functions

func FindFile

func FindFile(path string) (bool, string, error)

Types

type Config

type Config struct {
	// The name of the organization that this Design System is for, defaults to "DSK".
	Org string `json:"org,omitempty" yaml:"org,omitempty"`

	// The project name, defaults to the basename of the DDT folder.
	Project string `json:"project,omitempty" yaml:"project,omitempty"`

	// Language, the documents are authored in. Mainly used for indexing
	// the documents, defaults to English ("en").
	Lang string `json:"lang,omitempty" yaml:"lang,omitempty"`

	// A slice of configuration objects for specific tags. Allows you to display certain tags in custom colors.
	Tags []*TagConfig `json:"tags,omitempty" yaml:"tags,omitempty"`

	// List of sources or source patterns to whitelist DDT sources
	// that can be selected and switched to, by default just the
	// "live" version is allowed. Multiple versions can be matched
	// using patterns. Patterns may include wildcards ('*'), which
	// match any number of characters or ('?') to match a single
	// character.
	//
	// Internally this is known as "sources", externally to the
	// user as "versions". "Sources" as a term is too abstract and
	// "versions" has many meanings to cover this case.
	Sources []string `json:"versions,omitempty" yaml:"versions,omitempty"`

	// Configuration related to figma.com.
	Figma *FigmaConfig `json:"figma,omitempty" yaml:"figma,omitempty"`

	Custom interface{} `json:"custom,omitempty" yaml:"custom,omitempty"`
}

type DB

type DB interface {
	// Data returns the internal configuration data.
	Data() *Config

	// Refresh updates the internal data from its original source.
	Refresh() error

	// Open prepares the struct for use, it allow structs implementing
	// the interface i.e. to retrieve data from its underlying source.
	Open() error

	// Close is the counterpart to Open()
	Close() error

	// IsAcceptedSource returns true, when the given source is
	// whitelisted by configuration. It must support pattern matching
	// with multiple ('*') and single ('?') character matching.
	IsAcceptedSource(string) bool
}

type FigmaConfig

type FigmaConfig struct {
	// A generated figma personal access token, used for accessing the Figma API on users behalf.
	AccessToken string `json:"accessToken,omitempty" yaml:"accessToken,omitempty"`
}

type FileDB

type FileDB struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewFileDB

func NewFileDB(path string, project string) (*FileDB, error)

func (*FileDB) CalculateHash

func (db *FileDB) CalculateHash() (string, error)

CalculateHash hash returns a sha1 sum of the file contents.

func (*FileDB) Close

func (db *FileDB) Close() error

func (*FileDB) Data

func (db *FileDB) Data() *Config

func (*FileDB) IsAcceptedSource

func (db *FileDB) IsAcceptedSource(name string) bool

func (*FileDB) IsGone

func (db *FileDB) IsGone() bool

IsGone checks if the underlying file still exists. This check together with IsStale() can be used to decide whether the need to initialize a new struct or can reuse the current one, and update it from the files contents.

func (*FileDB) IsStale

func (db *FileDB) IsStale() bool

func (*FileDB) Load

func (db *FileDB) Load() error

Load populates the internal data slice by parsing the underlying file.

func (*FileDB) Open

func (db *FileDB) Open() error

func (*FileDB) Refresh

func (db *FileDB) Refresh() error

type StaticDB

type StaticDB struct {
	// contains filtered or unexported fields
}

StaticDB is a read-only configuration database.

func NewStaticDB

func NewStaticDB(project string) *StaticDB

func (*StaticDB) Close

func (db *StaticDB) Close() error

func (*StaticDB) Data

func (db *StaticDB) Data() *Config

func (*StaticDB) IsAcceptedSource

func (db *StaticDB) IsAcceptedSource(name string) bool

func (*StaticDB) Open

func (db *StaticDB) Open() error

func (*StaticDB) Refresh

func (db *StaticDB) Refresh() error

type TagConfig

type TagConfig struct {
	Name  string `json:"name,omitempty" yaml:"name,omitempty"`
	Color string `json:"color,omitempty" yaml:"color,omitempty"`
}

Jump to

Keyboard shortcuts

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