skyfallsin-simple_settings 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +2 -2
- data/README.rdoc +4 -4
- data/lib/simple_settings.rb +8 -0
- metadata +1 -1
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2008
|
1
|
+
Copyright (c) 2008 Pradeep Elankumaran
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -27,7 +27,7 @@ You can also assign variables on runtime if you choose to.
|
|
27
27
|
#=> 5280
|
28
28
|
|
29
29
|
== Example settings.yml
|
30
|
-
my_settings:
|
30
|
+
my_settings: &my_settings
|
31
31
|
xmpp:
|
32
32
|
server: localhost
|
33
33
|
port: 5280
|
@@ -37,13 +37,13 @@ You can also assign variables on runtime if you choose to.
|
|
37
37
|
port: 9090
|
38
38
|
|
39
39
|
development:
|
40
|
-
|
40
|
+
<<: *my_settings
|
41
41
|
|
42
42
|
testing:
|
43
|
-
|
43
|
+
<<: *my_settings
|
44
44
|
|
45
45
|
production:
|
46
|
-
|
46
|
+
<<: *my_settings
|
47
47
|
xmpp:
|
48
48
|
server: 'myxmpp.com'
|
49
49
|
port: 80
|
data/lib/simple_settings.rb
CHANGED
@@ -17,11 +17,19 @@ class SettingsHandler < Mash
|
|
17
17
|
def load_from_yaml!(filename, complain=true)
|
18
18
|
if File.exists?(filename)
|
19
19
|
data = YAML.load(File.read(filename))
|
20
|
+
data = prune_data_by_environment(data)
|
20
21
|
data.each{ |key, val| load!(key, val) } if data
|
21
22
|
else
|
22
23
|
puts "[simple_settings] Could not find settings file -- #{filename}" if complain
|
23
24
|
end
|
24
25
|
end
|
26
|
+
|
27
|
+
def prune_data_by_environment(data)
|
28
|
+
env = ENV["RAILS_ENV"] || ENV["MERB_ENV"]
|
29
|
+
puts "Settings ENV: #{env}"
|
30
|
+
return data[env] if env
|
31
|
+
data
|
32
|
+
end
|
25
33
|
end
|
26
34
|
end
|
27
35
|
|