Class: SkillBench::Task::FileReader

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

Overview

Reads task.md and criteria.json files for an evaluation task. Returns structured responses following service object contract.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(full_eval_path) ⇒ FileReader

Returns a new instance of FileReader.

Parameters:

  • full_eval_path (Pathname)

    The path to the evaluation directory.



20
21
22
# File 'lib/skill_bench/task/file_reader.rb', line 20

def initialize(full_eval_path)
  @full_eval_path = full_eval_path
end

Class Method Details

.call(full_eval_path) ⇒ Hash

Reads the task and criteria files from the given evaluation path.

Parameters:

  • full_eval_path (Pathname)

    The path to the evaluation directory.

Returns:

  • (Hash)

    with :success [Boolean] and :response containing file contents or error.



15
16
17
# File 'lib/skill_bench/task/file_reader.rb', line 15

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

Instance Method Details

#callHash

Reads task.md and criteria.json files.

Returns:

  • (Hash)

    with :success [Boolean] and :response containing file contents or error.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/skill_bench/task/file_reader.rb', line 27

def call
  task_content = read_file('task.md')
  return task_content unless task_content[:success]

  criteria_content = read_file('criteria.json')
  return criteria_content unless criteria_content[:success]

  {
    success: true,
    response: {
      task: task_content[:response][:content],
      criteria: criteria_content[:response][:content]
    }
  }
rescue StandardError => e
  SkillBench::ErrorLogger.log_error(e, 'Task::FileReader Error')
  { success: false, response: { error: { message: "Error reading task files: #{e.message}" } } }
end