Class: Pippi::ExecRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/pippi/exec_runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ ExecRunner

Returns a new instance of ExecRunner.



5
6
7
8
9
10
11
# File 'lib/pippi/exec_runner.rb', line 5

def initialize(args)
  check_args(args)
  @codefile = args[0]
  @check_name = args[1]
  @code_to_eval = args[2]
  @output_file_name = args[3]
end

Instance Attribute Details

#check_nameObject

Returns the value of attribute check_name.



3
4
5
# File 'lib/pippi/exec_runner.rb', line 3

def check_name
  @check_name
end

#code_to_evalObject

Returns the value of attribute code_to_eval.



3
4
5
# File 'lib/pippi/exec_runner.rb', line 3

def code_to_eval
  @code_to_eval
end

#codefileObject

Returns the value of attribute codefile.



3
4
5
# File 'lib/pippi/exec_runner.rb', line 3

def codefile
  @codefile
end

#output_file_nameObject

Returns the value of attribute output_file_name.



3
4
5
# File 'lib/pippi/exec_runner.rb', line 3

def output_file_name
  @output_file_name
end

Instance Method Details

#dump_report(ctx) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/pippi/exec_runner.rb', line 21

def dump_report(ctx)
  File.open(output_file_name, 'w') do |outfile|
    ctx.report.problems.each do |problem|
      outfile.syswrite("#{problem.to_text}\n")
    end
  end
end

#runObject



13
14
15
16
17
18
19
# File 'lib/pippi/exec_runner.rb', line 13

def run
  ctx = Pippi::Context.new
  CheckLoader.new(ctx, check_name).checks.each(&:decorate)
  load "#{codefile}"
  eval code_to_eval
  dump_report ctx
end