Class: Unwrappr::LockFileDiff

Inherits:
Object
  • Object
show all
Defined in:
lib/unwrappr/lock_file_diff.rb

Overview

Responsible for identifying all gem changes between two versions of a Gemfile.lock file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename:, base_file:, head_file:, patch:, sha:) ⇒ LockFileDiff

Returns a new instance of LockFileDiff.


7
8
9
10
11
12
13
# File 'lib/unwrappr/lock_file_diff.rb', line 7

def initialize(filename:, base_file:, head_file:, patch:, sha:)
  @filename = filename
  @base_file = base_file
  @head_file = head_file
  @patch = patch
  @sha = sha
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.


15
16
17
# File 'lib/unwrappr/lock_file_diff.rb', line 15

def filename
  @filename
end

#shaObject (readonly)

Returns the value of attribute sha.


15
16
17
# File 'lib/unwrappr/lock_file_diff.rb', line 15

def sha
  @sha
end

Instance Method Details

#each_gem_changeObject


17
18
19
20
21
22
23
24
25
26
27
# File 'lib/unwrappr/lock_file_diff.rb', line 17

def each_gem_change
  version_changes.each do |change|
    yield GemChange.new(
      name: change[:dependency].to_s,
      base_version: gem_version(change[:before]),
      head_version: gem_version(change[:after]),
      line_number: line_number_for_change(change),
      lock_file_diff: self
    )
  end
end