db

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	Libraries []*Library
	Releases  []*Release
	// contains filtered or unexported fields
}

DB is the libraries database

func Init

func Init(libraryFile string) *DB

Init loads a database from file and returns it.

func Load

func Load(r io.Reader) (*DB, error)

Load returns a DB object loaded from the given reader.

func LoadFromFile

func LoadFromFile(filename string) (*DB, error)

LoadFromFile returns a DB object loaded from the given filename.

func New

func New(libraryFile string) *DB

New returns a new DB object.

func (*DB) AddLibrary

func (db *DB) AddLibrary(library *Library) error

AddLibrary adds a library to the database.

func (*DB) AddRelease

func (db *DB) AddRelease(release *Release, repoURL string) error

AddRelease adds a library release to the database.

func (*DB) Commit

func (db *DB) Commit() error

Commit saves the database to disk.

func (*DB) FindLibrary

func (db *DB) FindLibrary(libraryName string) (*Library, error)

FindLibrary returns the Library object for the given name.

func (*DB) FindRelease

func (db *DB) FindRelease(release *Release) (*Release, error)

FindRelease returns the Release object from the database that matches the given object.

func (*DB) FindReleasesOfLibrary

func (db *DB) FindReleasesOfLibrary(lib *Library) []*Release

FindReleasesOfLibrary returns the database's releases for the given Library object.

func (*DB) HasLibrary

func (db *DB) HasLibrary(libraryName string) bool

HasLibrary returns whether the database already contains the given library.

func (*DB) HasRelease

func (db *DB) HasRelease(release *Release) bool

HasRelease returns whether the database already contains the given Release object.

func (*DB) HasReleaseByNameVersion

func (db *DB) HasReleaseByNameVersion(libraryName string, libraryVersion string) bool

HasReleaseByNameVersion returns whether the database contains a release for the given library and version number.

func (*DB) OutputLibraryIndex

func (db *DB) OutputLibraryIndex() (interface{}, error)

OutputLibraryIndex generates an object that once JSON-marshaled produces a json file suitable for the library installer (i.e. produce a valid library_index.json file)

func (*DB) RemoveLibrary

func (db *DB) RemoveLibrary(libraryName string) error

RemoveLibrary removes a library and all its releases from the database.

func (*DB) RemoveReleaseByNameVersion

func (db *DB) RemoveReleaseByNameVersion(libraryName string, libraryVersion string) error

RemoveReleaseByNameVersion removes the given library release from the database.

func (*DB) RemoveReleases

func (db *DB) RemoveReleases(libraryName string) error

RemoveReleases removes all releases of a library from the database.

func (*DB) Save

func (db *DB) Save(r io.Writer) error

Save writes the database via the given writer.

func (*DB) SaveToFile

func (db *DB) SaveToFile() error

SaveToFile saves the database to a file.

type Dependency

type Dependency struct {
	Name    string
	Version string
}

Dependency is a library dependency

func ExtractDependenciesList

func ExtractDependenciesList(depends string) ([]*Dependency, error)

ExtractDependenciesList extracts dependencies from the "depends" field of library.properties

type Library

type Library struct {
	Name       string
	Repository string

	// Category of the latest release of the library
	LatestCategory string
}

Library is an Arduino library

type Release

type Release struct {
	LibraryName     string // The library name
	Version         Version
	Author          string
	Maintainer      string
	License         string
	Sentence        string
	Paragraph       string
	Website         string
	Category        string
	Architectures   []string
	Types           []string
	URL             string
	ArchiveFileName string
	Size            int64
	Checksum        string
	Includes        []string
	Dependencies    []*Dependency
	Log             string
}

Release is a library release

func FromLibraryToRelease

func FromLibraryToRelease(library *metadata.LibraryMetadata) *Release

FromLibraryToRelease extract a Release from LibraryMetadata. LibraryMetadata must be validated before running this function.

type Version

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

Version is the type for library versions.

func VersionFromString

func VersionFromString(str string) Version

VersionFromString parses a string to a Version object.

func (*Version) Less

func (version *Version) Less(other Version) (bool, error)

Less returns whether the receiver version is lower than the argument.

func (*Version) MarshalJSON

func (version *Version) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of the receiver.

func (*Version) String

func (version *Version) String() string

String returns the version in string form.

func (*Version) UnmarshalJSON

func (version *Version) UnmarshalJSON(data []byte) error

UnmarshalJSON parses the JSON-encoded argument and stores the result in the receiver.

Jump to

Keyboard shortcuts

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