2023-03-02 13:24:24 -05:00
|
|
|
require 'yaml'
|
|
|
|
|
|
|
|
class Config
|
|
|
|
|
2023-03-09 23:22:18 -05:00
|
|
|
DEFAULT_CONFIG = 'config/defaults.yaml'
|
2023-03-09 15:48:33 -05:00
|
|
|
|
2023-03-02 13:24:24 -05:00
|
|
|
def initialize(config_path)
|
2023-03-09 15:48:33 -05:00
|
|
|
@data = YAML::load_file(DEFAULT_CONFIG)
|
|
|
|
|
|
|
|
if File.exists?(config_path)
|
|
|
|
@data.merge!(YAML::load_file(config_path))
|
|
|
|
end
|
2023-03-02 13:24:24 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def get(key, depth = 0)
|
|
|
|
bits = key.split('.')
|
|
|
|
value = @data
|
|
|
|
|
|
|
|
bits.each do |bit|
|
|
|
|
value = value[bit]
|
|
|
|
end
|
|
|
|
|
|
|
|
return value
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|