Class: Gemsurance::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/gemsurance/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Runner

Returns a new instance of Runner.



5
6
7
8
9
# File 'lib/gemsurance/runner.rb', line 5

def initialize(options = {})
  @formatter   = options.delete(:formatter) || :html
  @output_file = options.delete(:output_file) || "gemsurance_report.#{@formatter}"
  @options     = options
end

Instance Attribute Details

#gem_infosObject (readonly)

Returns the value of attribute gem_infos.



3
4
5
# File 'lib/gemsurance/runner.rb', line 3

def gem_infos
  @gem_infos
end

Instance Method Details

#reportObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gemsurance/runner.rb', line 16

def report
  unless @gem_infos_loaded
    puts "Error: gem infos not yet loaded."
    exit 1
  end

  generate_report
  if @gem_infos.any? { |info| info.vulnerable? }
    exit 1
  elsif @gem_infos.any? { |info| info.outdated? } && @options[:fail_outdated]
    exit 2
  end
end

#runObject



11
12
13
14
# File 'lib/gemsurance/runner.rb', line 11

def run
  build_gem_infos
  self
end