Class: CompareLinker::LockfileFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/compare_linker/lockfile_fetcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(octokit) ⇒ LockfileFetcher

Returns a new instance of LockfileFetcher.



8
9
10
# File 'lib/compare_linker/lockfile_fetcher.rb', line 8

def initialize(octokit)
  @octokit = octokit
end

Instance Attribute Details

#octokitObject (readonly)

Returns the value of attribute octokit.



6
7
8
# File 'lib/compare_linker/lockfile_fetcher.rb', line 6

def octokit
  @octokit
end

Instance Method Details

#fetch(repo_full_name, ref) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/compare_linker/lockfile_fetcher.rb', line 12

def fetch(repo_full_name, ref)
  lockfile_content = octokit.contents(
    repo_full_name, { ref: ref }
  ).find { |content|
    content.name == "Gemfile.lock"
  }
  Bundler::LockfileParser.new(
    Base64.decode64(
      octokit.blob(repo_full_name, lockfile_content.sha).content
    )
  )
end