Class: SkillBench::Config::JsonLoader
- Inherits:
-
Object
- Object
- SkillBench::Config::JsonLoader
- Defined in:
- lib/skill_bench/config/json_loader.rb
Overview
Loads and normalizes evaluator JSON configuration files.
Class Method Summary collapse
-
.call(path) ⇒ Hash
Loads a JSON config file into a normalized hash.
Instance Method Summary collapse
-
#call ⇒ Hash
Loads a JSON config file into a normalized hash.
-
#initialize(path) ⇒ JsonLoader
constructor
Initializes the loader.
Constructor Details
#initialize(path) ⇒ JsonLoader
Initializes the loader.
21 22 23 |
# File 'lib/skill_bench/config/json_loader.rb', line 21 def initialize(path) @path = path end |
Class Method Details
.call(path) ⇒ Hash
Loads a JSON config file into a normalized hash.
13 14 15 |
# File 'lib/skill_bench/config/json_loader.rb', line 13 def self.call(path) new(path).call end |
Instance Method Details
#call ⇒ Hash
Loads a JSON config file into a normalized hash.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/skill_bench/config/json_loader.rb', line 28 def call data = JSON.parse(File.read(@path), symbolize_names: true) return warn_invalid_config unless data.is_a?(Hash) success(data.slice(:current_llm_provider, :max_execution_time, :allowed_commands) .compact .merge(providers: normalized_providers(data[:providers]))) rescue JSON::ParserError => e log_parse_error(e) failure('Failed to parse config file') rescue StandardError => e SkillBench::ErrorLogger.log_error(e, 'JsonLoader Error') failure(e.) end |