Class: SkillBench::Services::JudgeScoreParserService Deprecated

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

Overview

Deprecated.

Scoring is now handled internally by Judge and DeltaReport.

Service object for parsing judge score responses from evaluation results. Handles JSON strings with optional code blocks, Hash inputs, and provides standardized error handling for malformed data.

Constant Summary collapse

PARSE_ERROR =
'Failed to parse judge score'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(judge_score) ⇒ JudgeScoreParserService

Returns a new instance of JudgeScoreParserService.

Parameters:

  • judge_score (String, Hash, nil)

    Raw judge score response



29
30
31
# File 'lib/skill_bench/services/judge_score_parser_service.rb', line 29

def initialize(judge_score)
  @judge_score = judge_score
end

Class Method Details

.call(judge_score) ⇒ Hash

Parses a judge score response into a standardized format.

Parameters:

  • judge_score (String, Hash, nil)

    Raw judge score response. Can be:

    • A JSON string (with or without markdown code blocks)

    • A Hash (with string or symbol keys)

    • nil (which will result in an error response)

Returns:

  • (Hash)

    Standardized response hash with format:

    • { success: true, response: Hash } on success

    • { success: false, response: { error: { message: String } } on failure

Raises:

  • (JSON::ParserError)

    raised when the judge_score string contains invalid JSON (rescued internally)



24
25
26
# File 'lib/skill_bench/services/judge_score_parser_service.rb', line 24

def self.call(judge_score)
  new(judge_score).call
end

Instance Method Details

#callHash

Returns { success: Boolean, response: Hash }.

Returns:

  • (Hash)

    { success: Boolean, response: Hash }

Raises:

  • (JSON::ParserError)

    raised when the judge_score string contains invalid JSON (rescued internally)



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/skill_bench/services/judge_score_parser_service.rb', line 35

def call
  case @judge_score
  when String
    parsed = parse_string_input
    parsed ? { success: true, response: parsed } : error_response
  when Hash
    { success: true, response: @judge_score.transform_keys(&:to_s) }
  else
    error_response
  end
end