Commit b8b3b790 authored by Cristian Maglie's avatar Cristian Maglie

Renamed librariesmanager.StatusContext -> librariesmanager.LibrariesManager

parent 1b766d80
......@@ -15,7 +15,7 @@
"types",
"utils"
]
revision = "e82d0725fbee6f1528426949202902d0c7aa74e5"
revision = "fd8b7dcea92845ba26eb0252aae29ccaef635a4e"
source = "github.com/bcmi-labs/arduino-builder"
[[projects]]
......
......@@ -39,9 +39,9 @@ import (
"github.com/pmylund/sortutil"
)
// StatusContext keeps the current status of the libraries in the system
// LibrariesManager keeps the current status of the libraries in the system
// (the list of libraries, revisions, installed paths, etc.)
type StatusContext struct {
type LibrariesManager struct {
Libraries map[string]*LibraryAlternatives `json:"libraries"`
Index *librariesindex.Index
}
......@@ -67,7 +67,7 @@ func (alts *LibraryAlternatives) Select() *libraries.Library {
}
// Names returns an array with all the names of the installed libraries.
func (sc StatusContext) Names() []string {
func (sc LibrariesManager) Names() []string {
res := make([]string, len(sc.Libraries))
i := 0
for n := range sc.Libraries {
......@@ -79,22 +79,22 @@ func (sc StatusContext) Names() []string {
}
// NewLibraryManager creates a new library manager
func NewLibraryManager() *StatusContext {
return &StatusContext{
func NewLibraryManager() *LibrariesManager {
return &LibrariesManager{
Libraries: map[string]*LibraryAlternatives{},
}
}
// LoadIndex reads a library_index.json from a file and returns
// the corresponding Index structure.
func (sc *StatusContext) LoadIndex() error {
func (sc *LibrariesManager) LoadIndex() error {
index, err := librariesindex.LoadIndex(IndexPath())
sc.Index = index
return err
}
// LoadLibrariesFromDir loads all libraries in the given folder
func (sc *StatusContext) LoadLibrariesFromDir(librariesDir *paths.Path) error {
func (sc *LibrariesManager) LoadLibrariesFromDir(librariesDir *LibrariesDir) error {
subFolders, err := librariesDir.ReadDir()
if err != nil {
return fmt.Errorf("reading dir %s: %s", librariesDir, err)
......
......@@ -64,7 +64,7 @@ func runDownloadCommand(cmd *cobra.Command, args []string) {
downloadLibraries(lm, pairs)
}
func downloadLibraries(lm *librariesmanager.StatusContext, refs []*librariesindex.Reference) {
func downloadLibraries(lm *librariesmanager.LibrariesManager, refs []*librariesindex.Reference) {
libsReleaseToDownload := []*librariesindex.Release{}
for _, ref := range refs {
if lib := lm.Index.FindRelease(ref); lib == nil {
......
......@@ -66,7 +66,7 @@ func runInstallCommand(cmd *cobra.Command, args []string) {
installLibraries(lm, refs)
}
func installLibraries(lm *librariesmanager.StatusContext, refs []*librariesindex.Reference) {
func installLibraries(lm *librariesmanager.LibrariesManager, refs []*librariesindex.Reference) {
libReleasesToInstall := []*librariesindex.Release{}
for _, ref := range refs {
rel := lm.Index.FindRelease(ref)
......
......@@ -76,7 +76,7 @@ func resultFromFileName(file os.FileInfo, libs *output.LibProcessResults) {
}
}
func getLibraryManager() *librariesmanager.StatusContext {
func getLibraryManager() *librariesmanager.LibrariesManager {
logrus.Info("Starting libraries manager")
lm := librariesmanager.NewLibraryManager()
if err := lm.LoadIndex(); err != nil {
......
......@@ -75,7 +75,7 @@ type Context struct {
WarningsLevel string
// Libraries handling
LibrariesManager *librariesmanager.StatusContext
LibrariesManager *librariesmanager.LibrariesManager
HeaderToLibraries map[string][]*libraries.Library
ImportedLibraries []*libraries.Library
LibrariesResolutionResults map[string]LibraryResolutionResult
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment