Class: Package::Audit::Ruby::BundlerSpecs

Inherits:
Object
  • Object
show all
Defined in:
lib/package/audit/ruby/bundler_specs.rb

Class Method Summary collapse

Class Method Details

.all(dir) ⇒ Object



11
12
13
14
15
16
# File 'lib/package/audit/ruby/bundler_specs.rb', line 11

def self.all(dir)
  Bundler.with_unbundled_env do
    ENV['BUNDLE_GEMFILE'] = "#{dir}/Gemfile"
    Bundler.ui.silence { Bundler.definition.resolve }
  end
end

.gemfile(dir) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/package/audit/ruby/bundler_specs.rb', line 18

def self.gemfile(dir)
  current_dependencies = Bundler.with_unbundled_env do
    ENV['BUNDLE_GEMFILE'] = "#{dir}/Gemfile"
    Bundler.ui.level = 'error'
    Bundler.reset!
    Bundler.ui.silence do
      Bundler.load.dependencies.to_h { |dep| [dep.name, dep] }
    end
  end

  gemfile_specs, = all(dir).partition do |spec|
    current_dependencies.key? spec.name
  end
  gemfile_specs
end