Sha256: 4f6269f1c3b149d9ed0244ef3a6bbcc675b3ee96cbbbcef6c93a8e1e8ce89986

Contents?: true

Size: 731 Bytes

Versions: 3

Compression:

Stored size: 731 Bytes

Contents

require 'bundler'

Bundler.ui.level = 'error'

module Gurney
  module Source
    class Bundler < Base

    def initialize(gemfile_lock:)
      @gemfile_lock = gemfile_lock
    end

    def present?
      !@gemfile_lock.nil?
    end

    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

    private

    attr_reader :gemfile_lock

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gurney_client-0.4.0 lib/gurney/source/bundler.rb
gurney_client-0.3.0 lib/gurney/source/bundler.rb
gurney_client-0.2.3 lib/gurney/source/bundler.rb