Class: CompareLinker::LockfileComparator
- Inherits:
-
Object
- Object
- CompareLinker::LockfileComparator
- Defined in:
- lib/compare_linker/lockfile_comparator.rb
Instance Attribute Summary collapse
-
#updated_gems ⇒ Object
Returns the value of attribute updated_gems.
Instance Method Summary collapse
- #compare(old_lockfile, new_lockfile) ⇒ Object
-
#initialize ⇒ LockfileComparator
constructor
A new instance of LockfileComparator.
Constructor Details
#initialize ⇒ LockfileComparator
Returns a new instance of LockfileComparator.
5 6 7 |
# File 'lib/compare_linker/lockfile_comparator.rb', line 5 def initialize @updated_gems = {} end |
Instance Attribute Details
#updated_gems ⇒ Object
Returns the value of attribute updated_gems.
3 4 5 |
# File 'lib/compare_linker/lockfile_comparator.rb', line 3 def updated_gems @updated_gems end |
Instance Method Details
#compare(old_lockfile, new_lockfile) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/compare_linker/lockfile_comparator.rb', line 9 def compare(old_lockfile, new_lockfile) old_lockfile.specs.each do |old_spec| new_lockfile.specs.each do |new_spec| if old_spec.name == new_spec.name old_rev = old_spec.source.["revision"] new_rev = new_spec.source.["revision"] if old_rev && new_rev && (old_rev != new_rev) # This section may be unnecessary? _, owner, gem_name = old_spec.source.uri.match(/github\.com\/([^\/]+)\/([^.]+)/).to_a updated_gems[old_spec.name] = { owner: owner, gem_name: gem_name, old_rev: old_rev, new_rev: new_rev, } elsif old_spec.version != new_spec.version updated_gems[old_spec.name] = { owner: nil, gem_name: old_spec.name, old_ver: old_spec.version.to_s, new_ver: new_spec.version.to_s, } end end end end updated_gems end |