configatron 1.2.2 → 2.0.0
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/README +61 -34
- data/doc/classes/Configatron.html +241 -0
- data/doc/classes/Configatron/ProtectedParameter.html +146 -0
- data/doc/classes/Configatron/Store.html +241 -121
- data/doc/classes/Kernel.html +13 -20
- data/doc/created.rid +1 -1
- data/doc/files/README.html +85 -43
- data/doc/files/lib/configatron/{configuration_rb.html → configatron_rb.html} +11 -4
- data/doc/files/lib/configatron/{helpers_rb.html → errors_rb.html} +4 -4
- data/doc/files/lib/configatron/kernel_rb.html +1 -1
- data/doc/files/lib/configatron/store_rb.html +1 -1
- data/doc/files/lib/configatron_rb.html +1 -2
- data/doc/fr_class_index.html +2 -4
- data/doc/fr_file_index.html +2 -3
- data/doc/fr_method_index.html +15 -21
- data/lib/configatron.rb +5 -44
- data/lib/configatron/configatron.rb +44 -0
- data/lib/configatron/errors.rb +7 -0
- data/lib/configatron/kernel.rb +3 -9
- data/lib/configatron/store.rb +148 -56
- data/spec/lib/configatron_spec.rb +293 -0
- data/spec/lib/futurama.yml +6 -0
- data/spec/spec_helper.rb +3 -2
- metadata +11 -18
- data/doc/classes/Configatron/Configuration.html +0 -402
- data/doc/classes/Configatron/Helpers.html +0 -174
- data/doc/classes/Configatron/YamlStore.html +0 -203
- data/doc/classes/Hash.html +0 -193
- data/doc/files/lib/configatron/yaml_store_rb.html +0 -101
- data/lib/configatron/configuration.rb +0 -112
- data/lib/configatron/helpers.rb +0 -27
- data/lib/configatron/yaml_store.rb +0 -33
- data/spec/unit/configuration_spec.rb +0 -299
- data/spec/unit/family_guy.yml +0 -2
- data/spec/unit/helpers_spec.rb +0 -115
- data/spec/unit/kernel_spec.rb +0 -48
- data/spec/unit/store_spec.rb +0 -91
data/doc/classes/Kernel.html
CHANGED
@@ -80,7 +80,7 @@
|
|
80
80
|
<h3 class="section-bar">Methods</h3>
|
81
81
|
|
82
82
|
<div class="name-list">
|
83
|
-
<a href="#
|
83
|
+
<a href="#M000015">configatron</a>
|
84
84
|
</div>
|
85
85
|
</div>
|
86
86
|
|
@@ -102,35 +102,28 @@
|
|
102
102
|
<div id="methods">
|
103
103
|
<h3 class="section-bar">Public Instance methods</h3>
|
104
104
|
|
105
|
-
<div id="method-
|
106
|
-
<a name="
|
105
|
+
<div id="method-M000015" class="method-detail">
|
106
|
+
<a name="M000015"></a>
|
107
107
|
|
108
108
|
<div class="method-heading">
|
109
|
-
<a href="#
|
110
|
-
<span class="method-name">configatron</span><span class="method-args">(
|
109
|
+
<a href="#M000015" class="method-signature">
|
110
|
+
<span class="method-name">configatron</span><span class="method-args">()</span>
|
111
111
|
</a>
|
112
112
|
</div>
|
113
113
|
|
114
114
|
<div class="method-description">
|
115
115
|
<p>
|
116
|
-
|
117
|
-
|
118
|
-
instance. If called with a block then it will call the
|
119
|
-
Configatron::Configatron configure method and yield up a <a
|
120
|
-
href="Configatron/Store.html">Configatron::Store</a> object.
|
116
|
+
Provides access to the <a href="Configatron.html">Configatron</a> storage
|
117
|
+
system.
|
121
118
|
</p>
|
122
119
|
<p><a class="source-toggle" href="#"
|
123
|
-
onclick="toggleCode('
|
124
|
-
<div class="method-source-code" id="
|
120
|
+
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
121
|
+
<div class="method-source-code" id="M000015-source">
|
125
122
|
<pre>
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
9: <span class="ruby-keyword kw">else</span>
|
131
|
-
10: <span class="ruby-constant">Configatron</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">instance</span>
|
132
|
-
11: <span class="ruby-keyword kw">end</span>
|
133
|
-
12: <span class="ruby-keyword kw">end</span>
|
123
|
+
<span class="ruby-comment cmt"># File lib/configatron/kernel.rb, line 4</span>
|
124
|
+
4: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configatron</span>
|
125
|
+
5: <span class="ruby-constant">Configatron</span>.<span class="ruby-identifier">instance</span>
|
126
|
+
6: <span class="ruby-keyword kw">end</span>
|
134
127
|
</pre>
|
135
128
|
</div>
|
136
129
|
</div>
|
data/doc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Wed, 17 Sep 2008 15:25:17 -0400
|
data/doc/files/README.html
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Wed Sep
|
59
|
+
<td>Wed Sep 17 14:47:44 -0400 2008</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -69,27 +69,25 @@
|
|
69
69
|
<div id="contextContent">
|
70
70
|
|
71
71
|
<div id="description">
|
72
|
-
<h1>Configatron</h1>
|
72
|
+
<h1><a href="../classes/Configatron.html">Configatron</a></h1>
|
73
73
|
<p>
|
74
|
-
Configatron makes configuring
|
75
|
-
easy. No longer is a there a need
|
76
|
-
you can use a simple and painless
|
77
|
-
because it‘s all Ruby, you can do
|
74
|
+
<a href="../classes/Configatron.html">Configatron</a> makes configuring
|
75
|
+
your applications and scripts incredibly easy. No longer is a there a need
|
76
|
+
to use constants or global variables. Now you can use a simple and painless
|
77
|
+
system to configure your life. And, because it‘s all Ruby, you can do
|
78
|
+
any crazy thing you would like to!
|
78
79
|
</p>
|
79
80
|
<h2>Examples</h2>
|
80
81
|
<h3>Simple</h3>
|
81
82
|
<pre>
|
82
|
-
configatron
|
83
|
-
|
84
|
-
config.database_url = "postgres://localhost/mack_framework_rocks"
|
85
|
-
# etc...
|
86
|
-
end
|
83
|
+
configatron.email = 'me@example.com'
|
84
|
+
configatron.database_url = "postgres://localhost/mack_framework_rocks"
|
87
85
|
</pre>
|
88
86
|
<p>
|
89
87
|
Now, anywhere in your code you can do the following:
|
90
88
|
</p>
|
91
89
|
<pre>
|
92
|
-
configatron.email # => "
|
90
|
+
configatron.email # => "me@example.com"
|
93
91
|
configatron.database_url # => "postgres://localhost/mack_framework_rocks"
|
94
92
|
</pre>
|
95
93
|
<p>
|
@@ -105,22 +103,20 @@ that is that is our production database url, not our development url. Fair
|
|
105
103
|
enough, all you have to do is redeclare it:
|
106
104
|
</p>
|
107
105
|
<pre>
|
108
|
-
configatron
|
109
|
-
config.database_url = "postgres://localhost/mack_framework_rocks_development"
|
110
|
-
end
|
106
|
+
configatron.database_url = "postgres://localhost/mack_framework_rocks_development"
|
111
107
|
</pre>
|
112
108
|
<p>
|
113
109
|
becomes:
|
114
110
|
</p>
|
115
111
|
<pre>
|
116
|
-
configatron.email # => "
|
112
|
+
configatron.email # => "me@example.com"
|
117
113
|
configatron.database_url # => "postgres://localhost/mack_framework_rocks_development"
|
118
114
|
</pre>
|
119
115
|
<p>
|
120
116
|
Notice how our other configuration parameters haven‘t changed? Cool,
|
121
117
|
eh?
|
122
118
|
</p>
|
123
|
-
<h3
|
119
|
+
<h3>Hash/YAML</h3>
|
124
120
|
<p>
|
125
121
|
You can configure configatron from a hash as well:
|
126
122
|
</p>
|
@@ -145,26 +141,16 @@ file will be re-read in case changes have been made.
|
|
145
141
|
<h3>Namespaces</h3>
|
146
142
|
<p>
|
147
143
|
The question that should be on your lips is what I need to have namespaced
|
148
|
-
configuration parameters. It‘s easy!
|
144
|
+
configuration parameters. It‘s easy! <a
|
145
|
+
href="../classes/Configatron.html">Configatron</a> allows you to create
|
149
146
|
namespaces.
|
150
147
|
</p>
|
151
148
|
<pre>
|
152
|
-
configatron
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
pop.port = "110"
|
158
|
-
# etc ...
|
159
|
-
end
|
160
|
-
email.namespace(:smtp) do |smtp|
|
161
|
-
smtp.address = "smtp.example.com"
|
162
|
-
smtp.port = "25"
|
163
|
-
# etc ...
|
164
|
-
end
|
165
|
-
end
|
166
|
-
# etc...
|
167
|
-
end
|
149
|
+
configatron.website_url = "http://www.mackframework.com"
|
150
|
+
configatron.email.pop.address = "pop.example.com"
|
151
|
+
configatron.email.pop.port = 110
|
152
|
+
configatron.email.smtp.address = "smtp.example.com"
|
153
|
+
configatron.email.smtp.port = 25
|
168
154
|
</pre>
|
169
155
|
<p>
|
170
156
|
becomes:
|
@@ -175,24 +161,80 @@ becomes:
|
|
175
161
|
configatron.website_url # => "http://www.mackframework.com"
|
176
162
|
</pre>
|
177
163
|
<p>
|
178
|
-
Configatron allows you to nest
|
179
|
-
going, it‘s that easy.
|
164
|
+
<a href="../classes/Configatron.html">Configatron</a> allows you to nest
|
165
|
+
namespaces to your hearts content! Just keep going, it‘s that easy.
|
180
166
|
</p>
|
181
167
|
<p>
|
182
168
|
Of course you can update a single parameter n levels deep as well:
|
183
169
|
</p>
|
184
170
|
<pre>
|
185
|
-
configatron
|
186
|
-
config.namespace(:email) do |email|
|
187
|
-
email.namespace(:pop) do |pop|
|
188
|
-
pop.address = "pop2.example.com"
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|
171
|
+
configatron.email.pop.address = "pop2.example.com"
|
192
172
|
|
193
173
|
configatron.email.pop.address # => "pop2.example.com"
|
194
174
|
configatron.email.smtp.address # => "smtp.example.com"
|
195
175
|
</pre>
|
176
|
+
<h3>Misc.</h3>
|
177
|
+
<p>
|
178
|
+
Even if parameters haven‘t been set, you can still call them, and
|
179
|
+
you‘ll get nil back:
|
180
|
+
</p>
|
181
|
+
<pre>
|
182
|
+
configatron.i.dont.exist.nil? # => true
|
183
|
+
configatron.i.dont.exist # => nil
|
184
|
+
</pre>
|
185
|
+
<p>
|
186
|
+
You can set ‘default’ values for parameters. If there is
|
187
|
+
already a setting, it won‘t be replaced. This is useful if
|
188
|
+
you‘ve already done your ‘configuration’ and you call a
|
189
|
+
library, that needs to have parameters set. The library can set it‘s
|
190
|
+
defaults, without worrying that it might have overridden your custom
|
191
|
+
settings.
|
192
|
+
</p>
|
193
|
+
<pre>
|
194
|
+
configatron.set_default(:name, 'Mark Bates')
|
195
|
+
configatron.name # => 'Mark Bates'
|
196
|
+
configatron.set_default(:name, 'Me')
|
197
|
+
configatron.name # => 'Mark Bates'
|
198
|
+
</pre>
|
199
|
+
<p>
|
200
|
+
Sometimes in testing, or other situations, you want to temporarily change
|
201
|
+
some settings. You can do this with the <tt>temp</tt> method:
|
202
|
+
</p>
|
203
|
+
<pre>
|
204
|
+
configatron.one = 1
|
205
|
+
configatron.letters.a = 'A'
|
206
|
+
configatron.letters.b = 'B'
|
207
|
+
configatron.temp do
|
208
|
+
configatron.letters.b = 'bb'
|
209
|
+
configatron.letters.c = 'c'
|
210
|
+
configatron.one # => 1
|
211
|
+
configatron.letters.a # => 'A'
|
212
|
+
configatron.letters.b # => 'bb'
|
213
|
+
configatron.letters.c # => 'c'
|
214
|
+
end
|
215
|
+
configatron.one # => 1
|
216
|
+
configatron.letters.a # => 'A'
|
217
|
+
configatron.letters.b # => 'B'
|
218
|
+
configatron.letters.c # => nil
|
219
|
+
</pre>
|
220
|
+
<p>
|
221
|
+
You can also pass in an optional Hash to the <tt>temp</tt>:
|
222
|
+
</p>
|
223
|
+
<pre>
|
224
|
+
configatron.one = 1
|
225
|
+
configatron.letters.a = 'A'
|
226
|
+
configatron.letters.b = 'B'
|
227
|
+
configatron.temp(:letters => {:b => 'bb', :c => 'c'}) do
|
228
|
+
configatron.one == 1
|
229
|
+
configatron.letters.a # => 'A'
|
230
|
+
configatron.letters.b # => 'bb'
|
231
|
+
configatron.letters.c # => 'c'
|
232
|
+
end
|
233
|
+
configatron.one == 1
|
234
|
+
configatron.letters.a # => 'A'
|
235
|
+
configatron.letters.b # => 'B'
|
236
|
+
configatron.letters.c # => nil
|
237
|
+
</pre>
|
196
238
|
<p>
|
197
239
|
Enjoy!
|
198
240
|
</p>
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
7
|
<head>
|
8
|
-
<title>File:
|
8
|
+
<title>File: configatron.rb</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
11
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
@@ -47,16 +47,16 @@
|
|
47
47
|
|
48
48
|
|
49
49
|
<div id="fileHeader">
|
50
|
-
<h1>
|
50
|
+
<h1>configatron.rb</h1>
|
51
51
|
<table class="header-table">
|
52
52
|
<tr class="top-aligned-row">
|
53
53
|
<td><strong>Path:</strong></td>
|
54
|
-
<td>lib/configatron/
|
54
|
+
<td>lib/configatron/configatron.rb
|
55
55
|
</td>
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Wed Sep 17 15:15:24 -0400 2008</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -69,6 +69,13 @@
|
|
69
69
|
<div id="contextContent">
|
70
70
|
|
71
71
|
|
72
|
+
<div id="requires-list">
|
73
|
+
<h3 class="section-bar">Required files</h3>
|
74
|
+
|
75
|
+
<div class="name-list">
|
76
|
+
singleton
|
77
|
+
</div>
|
78
|
+
</div>
|
72
79
|
|
73
80
|
</div>
|
74
81
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
7
|
<head>
|
8
|
-
<title>File:
|
8
|
+
<title>File: errors.rb</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
11
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
@@ -47,16 +47,16 @@
|
|
47
47
|
|
48
48
|
|
49
49
|
<div id="fileHeader">
|
50
|
-
<h1>
|
50
|
+
<h1>errors.rb</h1>
|
51
51
|
<table class="header-table">
|
52
52
|
<tr class="top-aligned-row">
|
53
53
|
<td><strong>Path:</strong></td>
|
54
|
-
<td>lib/configatron/
|
54
|
+
<td>lib/configatron/errors.rb
|
55
55
|
</td>
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Wed Sep 17 15:16:26 -0400 2008</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Wed Sep 17 15:02:18 -0400 2008</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -73,7 +73,6 @@
|
|
73
73
|
<h3 class="section-bar">Required files</h3>
|
74
74
|
|
75
75
|
<div class="name-list">
|
76
|
-
singleton
|
77
76
|
yaml
|
78
77
|
</div>
|
79
78
|
</div>
|
data/doc/fr_class_index.html
CHANGED
@@ -20,11 +20,9 @@
|
|
20
20
|
<div id="index">
|
21
21
|
<h1 class="section-bar">Classes</h1>
|
22
22
|
<div id="index-entries">
|
23
|
-
<a href="classes/Configatron
|
24
|
-
<a href="classes/Configatron/
|
23
|
+
<a href="classes/Configatron.html">Configatron</a><br />
|
24
|
+
<a href="classes/Configatron/ProtectedParameter.html">Configatron::ProtectedParameter</a><br />
|
25
25
|
<a href="classes/Configatron/Store.html">Configatron::Store</a><br />
|
26
|
-
<a href="classes/Configatron/YamlStore.html">Configatron::YamlStore</a><br />
|
27
|
-
<a href="classes/Hash.html">Hash</a><br />
|
28
26
|
<a href="classes/Kernel.html">Kernel</a><br />
|
29
27
|
</div>
|
30
28
|
</div>
|
data/doc/fr_file_index.html
CHANGED
@@ -22,11 +22,10 @@
|
|
22
22
|
<div id="index-entries">
|
23
23
|
<a href="files/README.html">README</a><br />
|
24
24
|
<a href="files/lib/configatron_rb.html">lib/configatron.rb</a><br />
|
25
|
-
<a href="files/lib/configatron/
|
26
|
-
<a href="files/lib/configatron/
|
25
|
+
<a href="files/lib/configatron/configatron_rb.html">lib/configatron/configatron.rb</a><br />
|
26
|
+
<a href="files/lib/configatron/errors_rb.html">lib/configatron/errors.rb</a><br />
|
27
27
|
<a href="files/lib/configatron/kernel_rb.html">lib/configatron/kernel.rb</a><br />
|
28
28
|
<a href="files/lib/configatron/store_rb.html">lib/configatron/store.rb</a><br />
|
29
|
-
<a href="files/lib/configatron/yaml_store_rb.html">lib/configatron/yaml_store.rb</a><br />
|
30
29
|
</div>
|
31
30
|
</div>
|
32
31
|
</body>
|
data/doc/fr_method_index.html
CHANGED
@@ -20,27 +20,21 @@
|
|
20
20
|
<div id="index">
|
21
21
|
<h1 class="section-bar">Methods</h1>
|
22
22
|
<div id="index-entries">
|
23
|
-
<a href="classes/Kernel.html#
|
24
|
-
<a href="classes/Configatron/
|
25
|
-
<a href="classes/Configatron/
|
26
|
-
<a href="classes/Configatron/
|
27
|
-
<a href="classes/Configatron/
|
28
|
-
<a href="classes/Configatron
|
29
|
-
<a href="classes/Configatron/Store.html#
|
30
|
-
<a href="classes/Configatron/Store.html#M000008">
|
31
|
-
<a href="classes/Configatron/Store.html#
|
32
|
-
<a href="classes/Configatron/
|
33
|
-
<a href="classes/
|
34
|
-
<a href="classes/
|
35
|
-
<a href="classes/Configatron/
|
36
|
-
<a href="classes/Configatron
|
37
|
-
<a href="classes/Configatron/
|
38
|
-
<a href="classes/Configatron/Configuration.html#M000018">reset (Configatron::Configuration)</a><br />
|
39
|
-
<a href="classes/Configatron/Configuration.html#M000017">reset! (Configatron::Configuration)</a><br />
|
40
|
-
<a href="classes/Configatron/Helpers.html#M000004">retrieve (Configatron::Helpers)</a><br />
|
41
|
-
<a href="classes/Configatron/Configuration.html#M000019">revert (Configatron::Configuration)</a><br />
|
42
|
-
<a href="classes/Configatron/Configuration.html#M000020">to_hash (Configatron::Configuration)</a><br />
|
43
|
-
<a href="classes/Configatron/Store.html#M000010">to_hash (Configatron::Store)</a><br />
|
23
|
+
<a href="classes/Kernel.html#M000015">configatron (Kernel)</a><br />
|
24
|
+
<a href="classes/Configatron/Store.html#M000006">configure_from_hash (Configatron::Store)</a><br />
|
25
|
+
<a href="classes/Configatron/Store.html#M000007">configure_from_yaml (Configatron::Store)</a><br />
|
26
|
+
<a href="classes/Configatron/Store.html#M000013">deep_clone (Configatron::Store)</a><br />
|
27
|
+
<a href="classes/Configatron/ProtectedParameter.html#M000014">intialize (Configatron::ProtectedParameter)</a><br />
|
28
|
+
<a href="classes/Configatron.html#M000001">method_missing (Configatron)</a><br />
|
29
|
+
<a href="classes/Configatron/Store.html#M000004">new (Configatron::Store)</a><br />
|
30
|
+
<a href="classes/Configatron/Store.html#M000008">nil? (Configatron::Store)</a><br />
|
31
|
+
<a href="classes/Configatron/Store.html#M000012">protect (Configatron::Store)</a><br />
|
32
|
+
<a href="classes/Configatron/Store.html#M000010">remove (Configatron::Store)</a><br />
|
33
|
+
<a href="classes/Configatron.html#M000002">reset! (Configatron)</a><br />
|
34
|
+
<a href="classes/Configatron/Store.html#M000009">retrieve (Configatron::Store)</a><br />
|
35
|
+
<a href="classes/Configatron/Store.html#M000011">set_default (Configatron::Store)</a><br />
|
36
|
+
<a href="classes/Configatron.html#M000003">temp (Configatron)</a><br />
|
37
|
+
<a href="classes/Configatron/Store.html#M000005">to_hash (Configatron::Store)</a><br />
|
44
38
|
</div>
|
45
39
|
</div>
|
46
40
|
</body>
|
data/lib/configatron.rb
CHANGED
@@ -1,45 +1,6 @@
|
|
1
|
-
|
1
|
+
base = File.join(File.dirname(__FILE__), 'configatron')
|
2
2
|
require 'yaml'
|
3
|
-
|
4
|
-
require File.join(
|
5
|
-
require File.join(
|
6
|
-
require File.join(
|
7
|
-
require File.join(File.dirname(__FILE__), 'configatron', 'store')
|
8
|
-
require File.join(File.dirname(__FILE__), 'configatron', 'yaml_store')
|
9
|
-
|
10
|
-
module Configatron # :nodoc:
|
11
|
-
end
|
12
|
-
|
13
|
-
class Hash
|
14
|
-
|
15
|
-
# Same as Hash#merge but recursively merges sub-hashes.
|
16
|
-
|
17
|
-
def recursive_merge(other)
|
18
|
-
hash = self.dup
|
19
|
-
other.each do |key, value|
|
20
|
-
myval = self[key]
|
21
|
-
if value.is_a?(Hash) && myval.is_a?(Hash)
|
22
|
-
hash[key] = myval.recursive_merge(value)
|
23
|
-
else
|
24
|
-
hash[key] = value
|
25
|
-
end
|
26
|
-
end
|
27
|
-
hash
|
28
|
-
end
|
29
|
-
|
30
|
-
# Same as Hash#merge! but recursively merges sub-hashes.
|
31
|
-
|
32
|
-
def recursive_merge!(other)
|
33
|
-
other.each do |key, value|
|
34
|
-
myval = self[key]
|
35
|
-
if value.is_a?(Hash) && myval.is_a?(Hash)
|
36
|
-
myval.recursive_merge!(value)
|
37
|
-
else
|
38
|
-
self[key] = value
|
39
|
-
end
|
40
|
-
end
|
41
|
-
self
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
3
|
+
require File.join(base, 'kernel')
|
4
|
+
require File.join(base, 'configatron')
|
5
|
+
require File.join(base, 'store')
|
6
|
+
require File.join(base, 'errors')
|