Class: ElmInstall::Installer
- Inherits:
-
Object
- Object
- ElmInstall::Installer
- Defined in:
- lib/elm_install/installer.rb
Overview
This class is responsible getting a solution for the ‘elm-package.json` file and populating the `elm-stuff` directory with the packages and writing the `elm-stuff/exact-dependencies.json`.
Instance Method Summary collapse
-
#cache_directory ⇒ String
Returns the path to the cache directory.
-
#init_options(options = { verbose: false }) ⇒ Hash
Initializes the options setting default values.
-
#initialize(options) ⇒ Installer
constructor
Initializes a new installer with the given options.
-
#install ⇒ void
Executes the installation.
-
#retry_install ⇒ void
Clears the reference cache and retries installation.
-
#save ⇒ void
Saves the caches.
Constructor Details
#initialize(options) ⇒ Installer
Initializes a new installer with the given options.
15 16 17 18 19 20 21 |
# File 'lib/elm_install/installer.rb', line 15 def initialize() @git_resolver = GitResolver.new directory: cache_directory @cache = Cache.new directory: cache_directory @populator = Populator.new @git_resolver = end |
Instance Method Details
#cache_directory ⇒ String
Returns the path to the cache directory
36 37 38 |
# File 'lib/elm_install/installer.rb', line 36 def cache_directory [:cache_directory] end |
#init_options(options = { verbose: false }) ⇒ Hash
Initializes the options setting default values.
28 29 30 31 |
# File 'lib/elm_install/installer.rb', line 28 def ( = { verbose: false }) [:cache_directory] ||= File.join(Dir.home, '.elm-install') = end |
#install ⇒ void
This method returns an undefined value.
Executes the installation
:reek:TooManyStatements { max_statements: 7 }
45 46 47 48 49 50 51 52 53 |
# File 'lib/elm_install/installer.rb', line 45 def install puts 'Resolving packages...' resolver.add_constraints dependencies puts 'Solving dependencies...' populate_elm_stuff rescue retry_install end |
#retry_install ⇒ void
This method returns an undefined value.
Clears the reference cache and retries installation.
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/elm_install/installer.rb', line 67 def retry_install Logger.arrow( 'Could not find a solution in local cache, refreshing packages...' ) @git_resolver.clear resolver.add_constraints dependencies populate_elm_stuff rescue Solve::Errors::NoSolutionError => error puts 'Could not find a solution:' puts error.to_s.indent(2) end |
#save ⇒ void
This method returns an undefined value.
Saves the caches
58 59 60 61 62 |
# File 'lib/elm_install/installer.rb', line 58 def save puts 'Saving package cache...' @git_resolver.save @cache.save end |