From 5f05c741f216a61beddaed506670381db5c6425d Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 20 Dec 2012 11:34:45 +0100 Subject: Loading config defaults from default.yml now You can overwrite them in config/config.yml --- .gitignore | 1 + config/config.yml | 8 -------- config/config.yml.example | 8 -------- config/defaults.yml | 11 +++++++++++ config/initializers/load_config.rb | 8 +++++++- 5 files changed, 19 insertions(+), 17 deletions(-) delete mode 100644 config/config.yml delete mode 100644 config/config.yml.example create mode 100644 config/defaults.yml diff --git a/.gitignore b/.gitignore index 974d05e..3b31e0b 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ public/assets/* public/ca.crt public/config/* public/provider.json +config/config.yml diff --git a/config/config.yml b/config/config.yml deleted file mode 100644 index c34dd10..0000000 --- a/config/config.yml +++ /dev/null @@ -1,8 +0,0 @@ -development: - admins: [admin, admin2] - -test: - admins: [admin, admin2] - -production: - admins: [] diff --git a/config/config.yml.example b/config/config.yml.example deleted file mode 100644 index c34dd10..0000000 --- a/config/config.yml.example +++ /dev/null @@ -1,8 +0,0 @@ -development: - admins: [admin, admin2] - -test: - admins: [admin, admin2] - -production: - admins: [] diff --git a/config/defaults.yml b/config/defaults.yml new file mode 100644 index 0000000..4ffa2c9 --- /dev/null +++ b/config/defaults.yml @@ -0,0 +1,11 @@ +development: + admins: [admin, admin2] + domain: develop.me + +test: + admins: [admin, admin2] + domain: test.me + +production: + admins: [] + domain: deploy.me diff --git a/config/initializers/load_config.rb b/config/initializers/load_config.rb index e687429..6cfde12 100644 --- a/config/initializers/load_config.rb +++ b/config/initializers/load_config.rb @@ -1 +1,7 @@ -APP_CONFIG = YAML.load_file("#{Rails.root}/config/config.yml")[Rails.env] +def load_config_file(file) + File.exists?(file) ? YAML.load_file(file)[Rails.env] : {} +end + +defaults = load_config_file("#{Rails.root}/config/defaults.yml") +config = load_config_file("#{Rails.root}/config/config.yml") +APP_CONFIG = defaults.merge(config) -- cgit v1.2.3 From 54037816896a9347c5894ad8260e440bba43d14f Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 20 Dec 2012 12:46:06 +0100 Subject: config hash now has indifferent access --- config/initializers/load_config.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/load_config.rb b/config/initializers/load_config.rb index 6cfde12..a3dbc5f 100644 --- a/config/initializers/load_config.rb +++ b/config/initializers/load_config.rb @@ -4,4 +4,4 @@ end defaults = load_config_file("#{Rails.root}/config/defaults.yml") config = load_config_file("#{Rails.root}/config/config.yml") -APP_CONFIG = defaults.merge(config) +APP_CONFIG = defaults.merge(config).with_indifferent_access -- cgit v1.2.3