Class: SkillBench::Services::ResultPrinterService Deprecated

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

Overview

Deprecated.

Use Cli::ResultPrinter instead.

Service object for printing formatted evaluation results to stdout. Handles result formatting, score parsing, and provides standardized output for both successful and failed evaluations.

Constant Summary collapse

RESULTS_BANNER =
"\n=========================================\n              " \
"RESULTS                    \n" \
"=========================================\n"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result, stdout: $stdout) ⇒ ResultPrinterService

Initializes a new result printer instance.

Parameters:

  • result (Hash)

    Evaluation result hash containing success status and task data

  • stdout (#puts, #write) (defaults to: $stdout)

    Output stream for user-visible messages. Defaults to $stdout



36
37
38
39
# File 'lib/skill_bench/services/result_printer_service.rb', line 36

def initialize(result, stdout: $stdout)
  @result = result
  @stdout = stdout
end

Class Method Details

.call(result, stdout: $stdout) ⇒ Hash

Prints formatted evaluation results to the specified output stream.

Examples:

Print successful results

result = ResultPrinterService.call(evaluation_result)
# => { success: true, response: {} }

Print to custom stream

result = ResultPrinterService.call(evaluation_result, stdout: string_io)
# => { success: true, response: {} }

Parameters:

  • result (Hash)

    Evaluation result hash containing success status and task data

  • stdout (#puts, #write) (defaults to: $stdout)

    Output stream for user-visible messages. Defaults to $stdout

Returns:

  • (Hash)

    Standardized response hash with format:

    • { success: true, response: {} } on successful printing



28
29
30
# File 'lib/skill_bench/services/result_printer_service.rb', line 28

def self.call(result, stdout: $stdout)
  new(result, stdout: stdout).call
end

Instance Method Details

#callHash

Prints the evaluation results in a formatted, user-friendly manner. Handles both successful evaluations and error cases.

Returns:

  • (Hash)

    Standardized response hash with format:

    • { success: true, response: {} } on successful printing



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/skill_bench/services/result_printer_service.rb', line 46

def call
  @stdout.puts RESULTS_BANNER

  unless @result[:success]
    error_msg = @result.dig(:response, :error, :message) || 'Unknown error'
    @stdout.puts "Evaluation failed: #{error_msg}"
    return { success: true, response: {} }
  end

  @result[:tasks]&.each do |task_result|
    @stdout.puts "\n========================================="
    @stdout.puts "       RESULTS: #{task_result[:path]}    "
    @stdout.puts "=========================================\n"
    print_task_result(task_result)
  end

  { success: true, response: {} }
end