Class: LlmCostTracker::PriceSync::RegistryLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/llm_cost_tracker/price_sync/registry_loader.rb

Constant Summary collapse

YAML_EXTENSIONS =
%w[.yml .yaml].freeze

Instance Method Summary collapse

Instance Method Details

#call(path:, seed_path:) ⇒ Object



11
12
13
14
15
16
# File 'lib/llm_cost_tracker/price_sync/registry_loader.rb', line 11

def call(path:, seed_path:)
  source_path = File.exist?(path.to_s) ? path.to_s : seed_path.to_s
  normalize_registry(load_registry_file(source_path))
rescue Errno::ENOENT, JSON::ParserError, Psych::Exception, ArgumentError, TypeError => e
  raise Error, "Unable to load pricing registry #{source_path.inspect}: #{e.message}"
end