Class: Gurney::Source::Bundler

Inherits:
Base
  • Object
show all
Defined in:
lib/gurney/source/bundler.rb

Instance Method Summary collapse

Constructor Details

#initialize(gemfile_lock:) ⇒ Bundler

Returns a new instance of Bundler.



9
10
11
# File 'lib/gurney/source/bundler.rb', line 9

def initialize(gemfile_lock:)
  @gemfile_lock = gemfile_lock
end

Instance Method Details

#dependenciesObject



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

def dependencies
  if present?
    Dir.mktmpdir do |dir|
      Dir.chdir dir do
        File.write('Gemfile', '') # LockfileParser requires a Gemfile to be present, can be empty
        lockfile = ::Bundler::LockfileParser.new(@gemfile_lock)
        lockfile.specs.map { |spec| Dependency.new(ecosystem: 'rubygems', name: spec.name, version: spec.version.to_s) }
      end
    end
  end
end

#present?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/gurney/source/bundler.rb', line 13

def present?
  !@gemfile_lock.nil?
end