Class: SkillBench::OutputFormatter
- Inherits:
-
Object
- Object
- SkillBench::OutputFormatter
- 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
-
.batch_exit_code(aggregate) ⇒ Integer
Determine the exit code for an aggregate batch result.
-
.exit_code(result) ⇒ Integer
Determine exit code based on eval result.
-
.format(result, format: :human) ⇒ String
Format the eval result for output.
-
.format_batch(aggregate) ⇒ String
Format an aggregate batch result for human output.
Class Method Details
.batch_exit_code(aggregate) ⇒ Integer
Determine the exit code for an aggregate batch result.
62 63 64 |
# File 'lib/skill_bench/output_formatter.rb', line 62 def self.batch_exit_code(aggregate) aggregate.dig(:summary, :failed).to_i.positive? ? 1 : 0 end |
.exit_code(result) ⇒ Integer
Determine exit code based on eval result.
37 38 39 40 41 42 43 |
# File 'lib/skill_bench/output_formatter.rb', line 37 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.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/skill_bench/output_formatter.rb', line 20 def self.format(result, format: :human) case format when :json Services::JsonFormatter.format(result) when :junit Services::JUnitFormatter.format(result) when :html Services::HtmlFormatter.format(result) else format_human(result) end end |
.format_batch(aggregate) ⇒ String
Format an aggregate batch result for human output.
Renders one PASS/FAIL line per eval plus a final summary line.
51 52 53 54 55 56 |
# File 'lib/skill_bench/output_formatter.rb', line 51 def self.format_batch(aggregate) lines = aggregate[:results].map { |result| batch_result_line(result) } lines << '' lines << batch_summary_line(aggregate[:summary]) lines.join("\n") end |