Class: ElmInstall::Installer
- Inherits:
-
Object
- Object
- ElmInstall::Installer
- Extended by:
- Forwardable
- 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 ⇒ Object
- #init_options(options = { verbose: false }) ⇒ Object
-
#initialize(options) ⇒ Installer
constructor
Initializes a new installer with the given options.
-
#install ⇒ Object
Executes the installation.
- #retry_install ⇒ Object
- #save ⇒ Object
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 @options = end |
Instance Method Details
#cache_directory ⇒ Object
28 29 30 |
# File 'lib/elm_install/installer.rb', line 28 def cache_directory @options[:cache_directory] end |
#init_options(options = { verbose: false }) ⇒ Object
23 24 25 26 |
# File 'lib/elm_install/installer.rb', line 23 def ( = { verbose: false }) [:cache_directory] ||= File.join(Dir.home, '.elm-install') @options = end |
#install ⇒ Object
Executes the installation
:reek:TooManyStatements { max_statements: 7 }
35 36 37 38 39 40 41 42 43 |
# File 'lib/elm_install/installer.rb', line 35 def install puts 'Resolving packages...' resolver.add_constraints dependencies puts 'Solving dependencies...' populate_elm_stuff rescue retry_install end |
#retry_install ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/elm_install/installer.rb', line 51 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 ⇒ Object
45 46 47 48 49 |
# File 'lib/elm_install/installer.rb', line 45 def save puts 'Saving package cache...' @git_resolver.save @cache.save end |