Files
game-data/src/config.rb
Gregory Ballantine 3f0efce0d8
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Fixed a few lints; changed rake task name to test:lint
2025-08-12 23:56:46 -04:00

30 lines
610 B
Ruby

# frozen_string_literal: true
require 'yaml'
# Config - loads and manages the app's configuration
class Config
DEFAULT_CONFIG = 'config/defaults.yaml'
ENVIRONMENT_CONFIG = ENV.fetch('RACK_ENV', 'development')
def initialize(config_path = "config/#{ENVIRONMENT_CONFIG}.yaml")
@data = YAML.load_file(DEFAULT_CONFIG)
# merge in user-defined configuration if it exists
@data.merge!(YAML.load_file(config_path)) if File.exist?(config_path)
end
def get(key)
bits = key.split('.')
value = @data
bits.each do |bit|
value = value[bit]
end
return value
end
end