I was able to solve your problem with SettingsLogic and anchor labels in YAML.
My config file:
defaults: &defaults
log: &logdefault
file: /tmp/foo.log
level: WARN
freq: daily
development:
<<: *defaults
log:
<<: *logdefault
level: DEBUG
test:
<<: *defaults
production:
<<: *defaults
The trick is to store the defaults in an anchor label and re-use it, when you try to redefine a part of it. You need an anchor for each level.
You can use it as
require 'settingslogic' #https://github.com/settingslogic/settingslogic
class SettingsDEV < Settingslogic
source "./application.yml"
namespace 'development'
end
p SettingsDEV.log #{"file"=>"/tmp/foo.log", "level"=>"DEBUG", "freq"=>"daily"}
class SettingsProd < Settingslogic
source "./application.yml"
namespace 'production'
end
p SettingsProd.log #{"file"=>"/tmp/foo.log", "level"=>"WARN", "freq"=>"daily"}