Sha256: ecc2fbf651e818d59b9d47c347000426a3b98df58bdf59a4d4c912d0e09ce9a6

Contents?: true

Size: 751 Bytes

Versions: 8

Compression:

Stored size: 751 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)
        Hash[lock_file.specs.map { |s| [s.name.to_sym, s.version.to_s] }]
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
unwrappr-0.5.0 lib/unwrappr/lock_file_comparator.rb
unwrappr-0.4.0 lib/unwrappr/lock_file_comparator.rb
unwrappr-0.3.5 lib/unwrappr/lock_file_comparator.rb
unwrappr-0.3.4 lib/unwrappr/lock_file_comparator.rb
unwrappr-0.3.3 lib/unwrappr/lock_file_comparator.rb
unwrappr-0.3.2 lib/unwrappr/lock_file_comparator.rb
unwrappr-0.3.1 lib/unwrappr/lock_file_comparator.rb
unwrappr-0.3.0 lib/unwrappr/lock_file_comparator.rb