Class: SkillBench::Services::DeltaTableFormatter

Inherits:
Object
  • Object
show all
Extended by:
FormattingHelpers
Defined in:
lib/skill_bench/services/delta_table_formatter.rb

Overview

Formats the dimension scoring table, totals, trend, and verdict for a DeltaReport.

Class Method Summary collapse

Methods included from FormattingHelpers

delta_str, humanize, trend_icon, truncate

Class Method Details

.format(report, result = nil) ⇒ String

Formats the delta report scoring section.

Parameters:

  • report (SkillBench::DeltaReport)

    The delta report.

  • result (Hash, nil) (defaults to: nil)

    Eval result envelope (used for trend data).

Returns:

  • (String)

    Formatted table, totals, trend, and verdict.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/skill_bench/services/delta_table_formatter.rb', line 16

def self.format(report, result = nil)
  lines = [
    '  DIMENSION                BASELINE   CONTEXT    DELTA',
    '  ──────────────────────── ───────── ───────── ───────'
  ]

  report.deltas.each do |name, delta|
    lines << format_dimension_row(name, delta, report)
  end

  lines << '  ──────────────────────── ───────── ───────── ───────'
  lines << format_total_row(report)
  lines << ''
  trend = result[:trend] if result
  lines << format_trend(trend) if trend

  status = report.verdict ? 'PASS' : 'FAIL'
  criteria = report.criteria
  threshold = criteria.pass_threshold
  delta_threshold = criteria.minimum_delta
  lines << "  VERDICT: #{status} (threshold: #{threshold}, minimum delta: #{delta_threshold})"
  lines << ('' * 55)

  lines.join("\n")
end