Class: Bundler::Plumber::Scanner
- Inherits:
-
Object
- Object
- Bundler::Plumber::Scanner
- Defined in:
- lib/bundler/plumber/scanner.rb
Defined Under Namespace
Classes: UnpatchedGem
Instance Attribute Summary collapse
-
#database ⇒ Database
readonly
The advisory database.
-
#lockfile ⇒ Bundler::LockfileParser
readonly
The parsed
Gemfile.lock
from the project. -
#root ⇒ Object
readonly
Project root directory.
Instance Method Summary collapse
-
#initialize(root = Dir.pwd, gemfile_lock = 'Gemfile.lock') ⇒ Scanner
constructor
Initializes a scanner.
-
#scan(options = {}) {|result| ... } ⇒ Enumerator
Scans the project for issues.
-
#scan_specs(options = {}) {|result| ... } ⇒ Enumerator
Scans the gem sources in the lockfile.
Constructor Details
#initialize(root = Dir.pwd, gemfile_lock = 'Gemfile.lock') ⇒ Scanner
Initializes a scanner.
57 58 59 60 61 62 63 |
# File 'lib/bundler/plumber/scanner.rb', line 57 def initialize(root=Dir.pwd,gemfile_lock='Gemfile.lock') @root = File.(root) @database = Database.new @lockfile = LockfileParser.new( File.read(File.join(@root,gemfile_lock)) ) end |
Instance Attribute Details
#database ⇒ Database (readonly)
The advisory database
38 39 40 |
# File 'lib/bundler/plumber/scanner.rb', line 38 def database @database end |
#lockfile ⇒ Bundler::LockfileParser (readonly)
The parsed Gemfile.lock
from the project
46 47 48 |
# File 'lib/bundler/plumber/scanner.rb', line 46 def lockfile @lockfile end |
#root ⇒ Object (readonly)
Project root directory
41 42 43 |
# File 'lib/bundler/plumber/scanner.rb', line 41 def root @root end |
Instance Method Details
#scan(options = {}) {|result| ... } ⇒ Enumerator
Scans the project for issues.
80 81 82 83 84 85 86 |
# File 'lib/bundler/plumber/scanner.rb', line 80 def scan(={},&block) return enum_for(__method__, ) unless block scan_specs(, &block) return self end |
#scan_specs(options = {}) {|result| ... } ⇒ Enumerator
Scans the gem sources in the lockfile.
110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/bundler/plumber/scanner.rb', line 110 def scan_specs(={}) return enum_for(__method__, ) unless block_given? ignore = Set[] ignore += [:ignore] if [:ignore] @lockfile.specs.each do |gem| @database.check_gem(gem) do |advisory| gem_and_id = "#{advisory.gem}-#{advisory.id}" yield UnpatchedGem.new(gem,advisory) unless ignore.include?(gem_and_id) end end end |