Class: BundleUpdateInteractive::Lockfile
- Inherits:
-
Object
- Object
- BundleUpdateInteractive::Lockfile
- Defined in:
- lib/bundle_update_interactive/lockfile.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[](gem_name) ⇒ Object
- #entries ⇒ Object
- #gems_exclusively_installed_by(gemfile:, groups:) ⇒ Object
-
#initialize(specs) ⇒ Lockfile
constructor
A new instance of Lockfile.
Constructor Details
#initialize(specs) ⇒ Lockfile
Returns a new instance of Lockfile.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bundle_update_interactive/lockfile.rb', line 13 def initialize(specs) @specs_by_name = {} required_exactly = Set.new specs.each do |spec| specs_by_name[spec.name] = spec spec.dependencies.each { |dep| required_exactly << dep.name if dep.requirement.exact? } end @entries_by_name = specs_by_name.transform_values do |spec| build_entry(spec, required_exactly.include?(spec.name)) end end |
Class Method Details
.parse(lockfile_contents = File.read("Gemfile.lock")) ⇒ Object
8 9 10 11 |
# File 'lib/bundle_update_interactive/lockfile.rb', line 8 def self.parse(lockfile_contents=File.read("Gemfile.lock")) parser = Bundler::LockfileParser.new(lockfile_contents) new(parser.specs) end |
Instance Method Details
#[](gem_name) ⇒ Object
31 32 33 |
# File 'lib/bundle_update_interactive/lockfile.rb', line 31 def [](gem_name) entries_by_name[gem_name] end |
#entries ⇒ Object
27 28 29 |
# File 'lib/bundle_update_interactive/lockfile.rb', line 27 def entries entries_by_name.values end |
#gems_exclusively_installed_by(gemfile:, groups:) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/bundle_update_interactive/lockfile.rb', line 35 def gems_exclusively_installed_by(gemfile:, groups:) return [] if groups.empty? other_group_gems = gemfile.dependencies.filter_map { |gem| gem.name unless (gem.groups & groups).any? } other_group_gems &= entries_by_name.keys gems_installed_by_other_groups = other_group_gems + traverse_transient_dependencies(*other_group_gems) entries_by_name.keys - gems_installed_by_other_groups end |