Class: RubyAudit::Scanner

Inherits:
Bundler::Audit::Scanner
  • Object
show all
Defined in:
lib/ruby_audit/scanner.rb

Defined Under Namespace

Classes: Version

Instance Method Summary collapse

Constructor Details

#initializeScanner

Returns a new instance of Scanner.



12
13
14
# File 'lib/ruby_audit/scanner.rb', line 12

def initialize
  @database = Database.new
end

Instance Method Details

#scan(options = {}, &block) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/ruby_audit/scanner.rb', line 16

def scan(options = {}, &block)
  return enum_for(__method__, options) unless block

  scan_ruby(options, &block)
  scan_rubygems(options, &block)

  self
end

#scan_ruby(options = {}, &block) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/ruby_audit/scanner.rb', line 25

def scan_ruby(options = {}, &block)
  version = if RUBY_PATCHLEVEL < 0
              ruby_version
            else
              "#{RUBY_VERSION}.#{RUBY_PATCHLEVEL}"
            end
  specs = [Version.new(RUBY_ENGINE, version)]
  scan_inner(specs, 'ruby', options, &block)
end

#scan_rubygems(options = {}, &block) ⇒ Object



35
36
37
38
# File 'lib/ruby_audit/scanner.rb', line 35

def scan_rubygems(options = {}, &block)
  specs = [Version.new('rubygems', rubygems_version)]
  scan_inner(specs, 'library', options, &block)
end