app-yml-rails 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
data/lib/app_yml/version.rb
CHANGED
@@ -1,3 +1,50 @@
|
|
1
|
+
# Public: Extends Ruby's Hash class to provide a method for performing a deep update on a hash.
|
2
|
+
class Hash
|
3
|
+
# Public: Performs an in-place deep update on the calling hash with the provided 'new_hash'. Allows us to override 'app.yml'
|
4
|
+
# settings from the 'all' environment with the current environment (test/development/staging/production) with unlimited nesting.
|
5
|
+
#
|
6
|
+
# new_hash - The hash to copy over the calling hash.
|
7
|
+
#
|
8
|
+
# Examples
|
9
|
+
#
|
10
|
+
# { :email => 'email@example.com', :name => 'Graham Swan' }.deep_update!({ :email => 'new_email@example.com' })
|
11
|
+
# => { :email => 'new_email@example.com', :name => 'Graham Swan' }
|
12
|
+
#
|
13
|
+
# Returns the calling hash with the updated values.
|
14
|
+
def deep_update! new_hash={}
|
15
|
+
new_hash.each_pair do |key, val|
|
16
|
+
if val.class.eql? Hash
|
17
|
+
self[key] = {} if self[key].nil? # Include settings defined in a specific environment (even when they're not defined in the 'all' environment)
|
18
|
+
self[key].deep_update! val
|
19
|
+
else
|
20
|
+
self[key] = val
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
self
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Public: Extends Rails' HashWithIndifferentAccess class to provide a method for accessing a hash's values with dot syntax.
|
29
|
+
module ActiveSupport
|
30
|
+
class HashWithIndifferentAccess < Hash
|
31
|
+
# Public: Causes '{}.arg' to call '{}[:arg]'.
|
32
|
+
#
|
33
|
+
# Note: None of the HashWithIndifferentAccess methods will work here. (http://as.rubyonrails.org/classes/HashWithIndifferentAccess.html)
|
34
|
+
# The aforementioned methods will invoke their expected functionality.
|
35
|
+
#
|
36
|
+
# Examples
|
37
|
+
#
|
38
|
+
# (HashWithIndifferentAccess.new({ :country => 'Canada' })).country
|
39
|
+
# => 'Canada'
|
40
|
+
#
|
41
|
+
# Returns the calling hash with the updated values.
|
42
|
+
def method_missing(method, *args)
|
43
|
+
self[method]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
1
48
|
# Public: An initializer that provides global access to the App constant (which holds all settings from config/app.yml).
|
2
49
|
#
|
3
50
|
# Thanks to Adrian Danieli (http://sickpea.com/2009/6/rails-app-configuration-in-10-lines) for this idea.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app-yml-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,19 +9,19 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &70095096241860 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '3.
|
21
|
+
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70095096241860
|
25
25
|
description: An awesome app.yml gem for Rails. Supports App.settings.nested_setting
|
26
26
|
syntax, all/production/staging/development/test environments, and auto-reloads app.yml
|
27
27
|
changes without requiring an application restart.
|
@@ -75,7 +75,6 @@ files:
|
|
75
75
|
- test/dummy/Rakefile
|
76
76
|
- test/dummy/README.rdoc
|
77
77
|
- test/dummy/script/rails
|
78
|
-
- test/dummy/tmp/pids/server.pid
|
79
78
|
- test/test_helper.rb
|
80
79
|
homepage: https://github.com/thinkswan/app-yml-rails
|
81
80
|
licenses: []
|
@@ -137,5 +136,4 @@ test_files:
|
|
137
136
|
- test/dummy/Rakefile
|
138
137
|
- test/dummy/README.rdoc
|
139
138
|
- test/dummy/script/rails
|
140
|
-
- test/dummy/tmp/pids/server.pid
|
141
139
|
- test/test_helper.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
51049
|