Class: LlmCostTracker::PriceSync::RegistryWriter

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

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#call(path:, registry:) ⇒ Object



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

def call(path:, registry:)
  FileUtils.mkdir_p(File.dirname(path))
  payload = yaml_file?(path) ? YAML.dump(registry) : "#{JSON.pretty_generate(registry)}\n"
  File.write(path, payload)
end