parse

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ArtifactFileExtension = ".md"
View Source
const CurrentArtifactVersion = 2

Variables

View Source
var ErrInvalidArtifactFiles = errors.New("one or more artifact files are invalid")
View Source
var ErrNoFrontMatter = errors.New("this file has no front matter")

Functions

func ExtractCids

func ExtractCids(artifacts []Artifact) ([]cid.Cid, error)

func ValidateEntry

func ValidateEntry(entry ArtifactEntry, filePath string) error

Types

type Artifact

type Artifact struct {
	Path   string          `json:"path"`
	Slug   string          `json:"slug"`
	Commit *ArtifactCommit `json:"commit"`
	Entry  GenericEntry    `json:"entry"`
}

func History

func History(workspacePath, artifactsPath string) ([]Artifact, error)

func Tree

func Tree(workspacePath, artifactsPath string) ([]Artifact, error)

func (Artifact) Version added in v0.2.0

func (a Artifact) Version() int

type ArtifactCommit

type ArtifactCommit struct {
	Rev  string    `json:"rev"`
	Date time.Time `json:"date"`
}

type ArtifactEntry

type ArtifactEntry struct {
	Version         int                 `yaml:"version" json:"version"`
	Title           string              `yaml:"title" json:"title"`
	Description     string              `yaml:"description" json:"description"`
	LongDescription *string             `yaml:"longDescription" json:"longDescription"`
	Files           []ArtifactEntryFile `yaml:"files" json:"files"`
	Links           []ArtifactEntryLink `yaml:"links" json:"links"`
	People          []string            `yaml:"people" json:"people"`
	Identities      []string            `yaml:"identities" json:"identities"`
	FromYear        int                 `yaml:"fromYear" json:"fromYear"`
	ToYear          *int                `yaml:"toYear" json:"toYear"`
	Decades         []int               `yaml:"decades" json:"decades"`
	Aliases         []string            `yaml:"aliases" json:"aliases"`
}

func (ArtifactEntry) ToGeneric added in v0.2.0

func (e ArtifactEntry) ToGeneric() GenericEntry

type ArtifactEntryFile

type ArtifactEntryFile struct {
	Name      string  `yaml:"name" json:"name"`
	MediaType *string `yaml:"mediaType" json:"mediaType"`
	Filename  *string `yaml:"filename" json:"filename"`
	Cid       string  `yaml:"cid" json:"cid"`
}
type ArtifactEntryLink struct {
	Name string `yaml:"name" json:"name"`
	Url  string `yaml:"url" json:"url"`
}

type ArtifactParseError

type ArtifactParseError struct {
	Path   string
	Reason string
}

func (ArtifactParseError) Error

func (e ArtifactParseError) Error() string

type ContentKey

type ContentKey string

func ContentKeyFromCid

func ContentKeyFromCid(id cid.Cid) ContentKey

type EntryField

type EntryField string
const (
	FieldVersion         EntryField = "version"
	FieldTitle           EntryField = "title"
	FieldDescription     EntryField = "description"
	FieldLongDescription EntryField = "longDescription"
	FieldFiles           EntryField = "files"
	FieldFileName        EntryField = "name"
	FieldFileMediaType   EntryField = "mediaType"
	FieldFileFilename    EntryField = "filename"
	FieldFileCid         EntryField = "cid"
	FieldLinks           EntryField = "links"
	FieldLinkName        EntryField = "name"
	FieldLinkUrl         EntryField = "url"
	FieldPeople          EntryField = "people"
	FieldIdentities      EntryField = "identities"
	FieldFromYear        EntryField = "fromYear"
	FieldToYear          EntryField = "toYear"
	FieldDecades         EntryField = "decades"
	FieldAliases         EntryField = "aliases"
)

func (EntryField) At

func (f EntryField) At(index int) EntryField

func (EntryField) Literal

func (f EntryField) Literal() string

func (EntryField) Of

func (f EntryField) Of(outer EntryField) EntryField

type ErrorCallback

type ErrorCallback func(field EntryField, reason string)

type FieldValidator

type FieldValidator func(entry ArtifactEntry, reportError ErrorCallback)

type GenericEntry added in v0.2.0

type GenericEntry map[string]interface{}

func (GenericEntry) Sanitize added in v0.2.0

func (e GenericEntry) Sanitize() GenericEntry

Sanitize replaces `map[interface{}]interface{}` values that cannot be serialized to JSON with `map[string]interface{}`.

func (GenericEntry) ToTyped added in v0.2.0

func (e GenericEntry) ToTyped(value interface{})

type InvalidArtifactError

type InvalidArtifactError struct {
	FilePath string
	Reasons  []InvalidArtifactReason
}

func (InvalidArtifactError) Error

func (e InvalidArtifactError) Error() string

type InvalidArtifactReason

type InvalidArtifactReason struct {
	Field  EntryField
	Reason string
}

type Revision

type Revision struct {
	File object.File
	Path string
	Rev  string
	Date time.Time
}

Jump to

Keyboard shortcuts

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