Class: Unwrappr::Github::PrSource

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

Overview

Obtains Gemfile.lock changes from a Github Pull Request

Implements the ‘lock_file_diff_source` interface as defined by the LockFileAnnotator.

Instance Method Summary collapse

Constructor Details

#initialize(repo, pr_number, lock_files, client) ⇒ PrSource

Returns a new instance of PrSource.



12
13
14
15
16
17
# File 'lib/unwrappr/github/pr_source.rb', line 12

def initialize(repo, pr_number, lock_files, client)
  @repo = repo
  @pr_number = pr_number
  @lock_files = lock_files
  @client = client
end

Instance Method Details

#each_fileObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/unwrappr/github/pr_source.rb', line 19

def each_file
  lock_file_diffs.each do |lock_file_diff|
    yield LockFileDiff.new(
      filename: lock_file_diff.filename,
      base_file: file_contents(lock_file_diff.filename, base_sha),
      head_file: file_contents(lock_file_diff.filename, head_sha),
      patch: lock_file_diff.patch,
      sha: head_sha
    )
  end
end