module Unwrappr::LockFileComparator

Compares two lock files and emits a diff of versions

Public Class Methods

perform(lock_file_content_before, lock_file_content_after) click to toggle source
# File lib/unwrappr/lock_file_comparator.rb, line 9
def perform(lock_file_content_before, lock_file_content_after)
  lock_file_before = Bundler::LockfileParser.new(lock_file_content_before)
  lock_file_after = Bundler::LockfileParser.new(lock_file_content_after)

  versions_diff = SpecVersionComparator.perform(
    specs_versions(lock_file_before),
    specs_versions(lock_file_after)
  )

  { versions: versions_diff }
end

Private Class Methods

specs_versions(lock_file) click to toggle source
# File lib/unwrappr/lock_file_comparator.rb, line 23
def specs_versions(lock_file)
  lock_file.specs.each_with_object({}) do |s, memo|
    memo[s.name.to_sym] = s.version.to_s
  end
end