123456789_123456789_123456789_123456789_123456789_

Class: RBS::Collection::Installer

Relationships & Source Files
Inherits: Object
Defined in: lib/rbs/collection/installer.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(lockfile_path:, stdout: $stdout) ⇒ Installer

[ GitHub ]

  
# File 'lib/rbs/collection/installer.rb', line 9

def initialize(lockfile_path:, stdout: $stdout)
  @lockfile = Config.from_path(lockfile_path)
  @stdout = stdout
end

Instance Attribute Details

#lockfile (readonly)

[ GitHub ]

  
# File 'lib/rbs/collection/installer.rb', line 6

attr_reader :lockfile

#stdout (readonly)

[ GitHub ]

  
# File 'lib/rbs/collection/installer.rb', line 7

attr_reader :stdout

Instance Method Details

#install_from_lockfile

[ GitHub ]

  
# File 'lib/rbs/collection/installer.rb', line 14

def install_from_lockfile
  install_to = lockfile.repo_path
  install_to.mkpath
  lockfile.gems.each do |config_entry|
    source_for(config_entry).install(dest: install_to, config_entry: config_entry, stdout: stdout)
  end
  stdout.puts "It's done! #{lockfile.gems.size} gems' RBSs now installed."
end

#source_for(config_entry) (private)

[ GitHub ]

  
# File 'lib/rbs/collection/installer.rb', line 23

private def source_for(config_entry)
  @source_for ||= {}
  key = config_entry['source']
  unless key
    raise "Cannot find source of '#{config_entry['name']}' gem"
  end
  @source_for[key] ||= Sources.from_config_entry(key)
end