Sha256: 5b83454216fd2f6954652f57144a599e95bb47bba4330991560f6ce7148b31e3

Contents?: true

Size: 794 Bytes

Versions: 5

Compression:

Stored size: 794 Bytes

Contents

# frozen_string_literal: true

require 'bundler'

module Unwrappr
  # Compares two lock files and emits a diff of versions
  module LockFileComparator
    class << self
      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

      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
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
unwrappr-0.8.2 lib/unwrappr/lock_file_comparator.rb
unwrappr-0.8.1 lib/unwrappr/lock_file_comparator.rb
unwrappr-0.8.0 lib/unwrappr/lock_file_comparator.rb
unwrappr-0.7.0 lib/unwrappr/lock_file_comparator.rb
unwrappr-0.6.0 lib/unwrappr/lock_file_comparator.rb