Class: ElmInstall::Cache
Overview
This class is responsible for maintaining a cache of all the repositories their versions and their dependencies.
By default the clones of the repositories live in the users home directory (~/.elm-install), this can be changed with the ‘directory` option.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#dependency(package, version, constraint) ⇒ Array
Adds a new dependency to the cache for a given package & version combination.
-
#ensure_package(package) ⇒ Hash
Ensures that a package exists in the cache.
-
#ensure_version(package, version) ⇒ Array
Ensures that a package & version combination exists in the cache.
-
#initialize(options) ⇒ Cache
constructor
Initializes a cache with the given options.
Methods inherited from Base
#directory, #file, #load, #save
Constructor Details
#initialize(options) ⇒ Cache
Initializes a cache with the given options.
14 15 16 17 |
# File 'lib/elm_install/cache.rb', line 14 def initialize() @file = 'cache.json' super end |
Instance Method Details
#dependency(package, version, constraint) ⇒ Array
Adds a new dependency to the cache for a given package & version combination.
27 28 29 30 |
# File 'lib/elm_install/cache.rb', line 27 def dependency(package, version, constraint) ensure_package version @cache[package][version] << constraint end |
#ensure_package(package) ⇒ Hash
Ensures that a package exists in the cache.
48 49 50 |
# File 'lib/elm_install/cache.rb', line 48 def ensure_package(package) @cache[package] ||= {} end |
#ensure_version(package, version) ⇒ Array
Ensures that a package & version combination exists in the cache.
38 39 40 41 |
# File 'lib/elm_install/cache.rb', line 38 def ensure_version(package, version) ensure_package package @cache[package][version] ||= [] end |