Class: Diogenes::Evaluation::CiRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/diogenes/evaluation/ci_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(description:, answers:, out:, err:, format: nil) ⇒ CiRunner

: (description: String, answers: String, out: IO, err: IO, ?format: String?) -> void



10
11
12
13
14
15
16
# File 'lib/diogenes/evaluation/ci_runner.rb', line 10

def initialize(description:, answers:, out:, err:, format: nil)
  @description = description
  @parsed_answers = parse_answers(answers) #: Hash[Symbol, bool]
  @format = format
  @out = out
  @err = err
end

Instance Method Details

#runObject

: () -> Integer



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/diogenes/evaluation/ci_runner.rb', line 19

def run
  missing = Gates::ALL.map(&:key) - @parsed_answers.keys
  unless missing.empty?
    @err.puts "Missing answer#{"s" if missing.size > 1} for: #{missing.join(", ")}. " \
              "Provide all 5 gate answers: --answers failure_mode=pass,user_verifiable=pass,..."
    return 1
  end

  results = build_results
  (@format == "json") ? output_json(results) : output_text(results)
  results.all?(&:passed?) ? 0 : 1
end