Class: RBS::Collection::Installer
- Inherits:
-
Object
- Object
- RBS::Collection::Installer
- Defined in:
- lib/rbs/collection/installer.rb,
sig/collection/installer.rbs
Instance Attribute Summary collapse
-
#lockfile ⇒ Config::Lockfile
readonly
Returns the value of attribute lockfile.
-
#stdout ⇒ CLI::_IO
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 ⇒ void
- #source_for ⇒ Sources::_Source
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 ⇒ Config::Lockfile (readonly)
Returns the value of attribute lockfile.
6 7 8 |
# File 'lib/rbs/collection/installer.rb', line 6 def lockfile @lockfile end |
#stdout ⇒ CLI::_IO (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 ⇒ void
This method returns an undefined value.
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 |
#source_for ⇒ Sources::_Source
14 |
# File 'sig/collection/installer.rbs', line 14
def source_for: (Config::gem_entry) -> Sources::_Source
|