summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2012-12-22 04:37:24 -0800
committerazul <azul@riseup.net>2012-12-22 04:37:24 -0800
commit6e90c173662583ca392ca1cefa7e7dcdc92dbf13 (patch)
tree7195099649b50a95feea1ee10a214416c31ca59b
parentb23a7999dfc3e38e0f0ea6a1a3d4fd1e86b358ca (diff)
parent54037816896a9347c5894ad8260e440bba43d14f (diff)
Merge pull request #8 from leapcode/feature/use-default-config-file
Use two config files - one for defaults that is always present and one to overwrite these
-rw-r--r--.gitignore1
-rw-r--r--config/config.yml.example8
-rw-r--r--config/defaults.yml (renamed from config/config.yml)3
-rw-r--r--config/initializers/load_config.rb8
4 files changed, 11 insertions, 9 deletions
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.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/config.yml b/config/defaults.yml
index c34dd10..4ffa2c9 100644
--- a/config/config.yml
+++ b/config/defaults.yml
@@ -1,8 +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..a3dbc5f 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).with_indifferent_access