Class: RubyAudit::Scanner

Inherits:
Object
  • 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.



15
16
17
# File 'lib/ruby_audit/scanner.rb', line 15

def initialize
  @database = Database.new
end

Instance Method Details

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



19
20
21
22
23
24
25
26
# File 'lib/ruby_audit/scanner.rb', line 19

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



28
29
30
31
32
33
34
35
36
# File 'lib/ruby_audit/scanner.rb', line 28

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



38
39
40
41
# File 'lib/ruby_audit/scanner.rb', line 38

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