Class: Bundler::Advise::GemAdviser
- Inherits:
-
Object
- Object
- Bundler::Advise::GemAdviser
- Defined in:
- lib/bundler/advise/gem_adviser.rb
Instance Method Summary collapse
-
#initialize(advisories: Advisories.new, dir: Dir.pwd) ⇒ GemAdviser
constructor
A new instance of GemAdviser.
- #scan_lockfile ⇒ Object
Constructor Details
#initialize(advisories: Advisories.new, dir: Dir.pwd) ⇒ GemAdviser
Returns a new instance of GemAdviser.
5 6 7 8 9 |
# File 'lib/bundler/advise/gem_adviser.rb', line 5 def initialize(advisories: Advisories.new, dir: Dir.pwd) @advisories = advisories @dir = dir scan_lockfile end |
Instance Method Details
#scan_lockfile ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/bundler/advise/gem_adviser.rb', line 11 def scan_lockfile lockfile = nil Dir.chdir(@dir) do lockfile = Bundler::LockfileParser.new(Bundler.read_file('Gemfile.lock')) end lockfile.specs.map do |spec| @advisories.gem_advisories_for(spec.name).select do |ad| ad.is_affected?(spec.version).tap { |res| ad.send(:gem_spec=, spec) if res } end end.flatten end |