Class: SkillBench::OutputFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/skill_bench/output_formatter.rb

Overview

Handles formatting output for different use cases (human, CI, etc.). Delegates all presentation logic to focused service objects under Services.

Class Method Summary collapse

Class Method Details

.exit_code(result) ⇒ Integer

Determine exit code based on eval result.

Parameters:

  • result (Hash)

    Eval result with :pass or :success/:response keys.

Returns:

  • (Integer)

    0 if passed, 1 if failed



34
35
36
37
38
39
40
# File 'lib/skill_bench/output_formatter.rb', line 34

def self.exit_code(result)
  return 0 if result[:pass]
  return 1 unless result[:success]

  report = result.dig(:response, :report)
  report&.verdict ? 0 : 1
end

.format(result, format: :human) ⇒ String

Format the eval result for output.

Parameters:

  • result (Hash)

    Eval result with keys like :eval_name, :pass, :score, etc.

  • format (Symbol) (defaults to: :human)

    Output format (:human, :json, :junit)

Returns:

  • (String)

    Formatted output string



19
20
21
22
23
24
25
26
27
28
# File 'lib/skill_bench/output_formatter.rb', line 19

def self.format(result, format: :human)
  case format
  when :json
    Services::JsonFormatter.format(result)
  when :junit
    Services::JUnitFormatter.format(result)
  else
    format_human(result)
  end
end