Class: RBS::Collection::Installer
- Inherits:
-
Object
- Object
- RBS::Collection::Installer
- Defined in:
- lib/rbs/collection/installer.rb
Instance Attribute Summary collapse
-
#lockfile ⇒ Object
readonly
Returns the value of attribute lockfile.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
-
#initialize(lockfile_path:, stdout: $stdout) ⇒ Installer
constructor
A new instance of Installer.
- #install_from_lockfile ⇒ Object
Constructor Details
#initialize(lockfile_path:, stdout: $stdout) ⇒ Installer
Returns a new instance of Installer.
9 10 11 12 |
# File 'lib/rbs/collection/installer.rb', line 9 def initialize(lockfile_path:, stdout: $stdout) @lockfile = Config::Lockfile.from_lockfile(lockfile_path: lockfile_path, data: YAML.load_file(lockfile_path)) @stdout = stdout end |
Instance Attribute Details
#lockfile ⇒ Object (readonly)
Returns the value of attribute lockfile.
6 7 8 |
# File 'lib/rbs/collection/installer.rb', line 6 def lockfile @lockfile end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
7 8 9 |
# File 'lib/rbs/collection/installer.rb', line 7 def stdout @stdout end |
Instance Method Details
#install_from_lockfile ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rbs/collection/installer.rb', line 14 def install_from_lockfile install_to = lockfile.fullpath install_to.mkpath selected = lockfile.gems.select do |name, gem| gem[:source].has?(name, gem[:version]) end selected.each_value do |gem| gem[:source].install( dest: install_to, name: gem[:name], version: gem[:version], stdout: stdout ) end CLI::ColoredIO.new(stdout: stdout).puts_green("It's done! #{selected.size} gems' RBSs now installed.") end |