Commit b8b3b790 authored by Cristian Maglie's avatar Cristian Maglie

Renamed librariesmanager.StatusContext -> librariesmanager.LibrariesManager

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