Class: LockDiff::Gem::LockfileComparator
- Inherits:
-
Object
- Object
- LockDiff::Gem::LockfileComparator
- Defined in:
- lib/lock_diff/gem/lockfile_comparator.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(old_lockfile:, new_lockfile:) ⇒ LockfileComparator
constructor
A new instance of LockfileComparator.
Constructor Details
#initialize(old_lockfile:, new_lockfile:) ⇒ LockfileComparator
4 5 6 7 |
# File 'lib/lock_diff/gem/lockfile_comparator.rb', line 4 def initialize(old_lockfile:, new_lockfile:) @old_lockfile = old_lockfile @new_lockfile = new_lockfile end |
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/lock_diff/gem/lockfile_comparator.rb', line 9 def call old_specs_by_name = Spec.parse(@old_lockfile).map { |spec| [spec.name, spec] }.to_h new_specs_by_name = Spec.parse(@new_lockfile).map { |spec| [spec.name, spec] }.to_h names = (old_specs_by_name.keys + new_specs_by_name.keys).uniq names.map { |name| DiffInfo.new( old_package: (old_specs_by_name[name] || NullSpec.new(name)).to_package, new_package: (new_specs_by_name[name] || NullSpec.new(name)).to_package ) }.select(&:changed?) end |