configatron 1.2.1 → 1.2.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/doc/classes/Configatron/Configuration.html +103 -102
- data/doc/classes/Configatron/Helpers.html +12 -12
- data/doc/classes/Configatron/Store.html +38 -38
- data/doc/classes/Configatron/YamlStore.html +12 -12
- data/doc/classes/Hash.html +193 -0
- data/doc/classes/Kernel.html +6 -6
- data/doc/created.rid +1 -1
- data/doc/files/README.html +1 -1
- data/doc/files/lib/configatron/configuration_rb.html +1 -1
- data/doc/files/lib/configatron/store_rb.html +1 -1
- data/doc/files/lib/configatron_rb.html +1 -1
- data/doc/fr_class_index.html +1 -0
- data/doc/fr_method_index.html +21 -19
- data/lib/configatron/configuration.rb +1 -0
- data/lib/configatron.rb +35 -1
- data/spec/unit/configuration_spec.rb +17 -0
- metadata +3 -2
@@ -92,14 +92,14 @@ The central class for managing the configurations.
|
|
92
92
|
<h3 class="section-bar">Methods</h3>
|
93
93
|
|
94
94
|
<div class="name-list">
|
95
|
-
<a href="#
|
96
|
-
<a href="#
|
97
|
-
<a href="#
|
98
|
-
<a href="#
|
99
|
-
<a href="#
|
100
|
-
<a href="#
|
101
|
-
<a href="#
|
102
|
-
<a href="#
|
95
|
+
<a href="#M000013">configure</a>
|
96
|
+
<a href="#M000014">configure_from_hash</a>
|
97
|
+
<a href="#M000015">configure_from_yaml</a>
|
98
|
+
<a href="#M000016">reload</a>
|
99
|
+
<a href="#M000018">reset</a>
|
100
|
+
<a href="#M000017">reset!</a>
|
101
|
+
<a href="#M000019">revert</a>
|
102
|
+
<a href="#M000020">to_hash</a>
|
103
103
|
</div>
|
104
104
|
</div>
|
105
105
|
|
@@ -147,11 +147,11 @@ NoMethodError exception will be raised.
|
|
147
147
|
<div id="methods">
|
148
148
|
<h3 class="section-bar">Public Instance methods</h3>
|
149
149
|
|
150
|
-
<div id="method-
|
151
|
-
<a name="
|
150
|
+
<div id="method-M000013" class="method-detail">
|
151
|
+
<a name="M000013"></a>
|
152
152
|
|
153
153
|
<div class="method-heading">
|
154
|
-
<a href="#
|
154
|
+
<a href="#M000013" class="method-signature">
|
155
155
|
<span class="method-name">configure</span><span class="method-args">() {|storage| ...}</span>
|
156
156
|
</a>
|
157
157
|
</div>
|
@@ -161,8 +161,8 @@ NoMethodError exception will be raised.
|
|
161
161
|
Yields a new <a href="Store.html">Configatron::Store</a> class.
|
162
162
|
</p>
|
163
163
|
<p><a class="source-toggle" href="#"
|
164
|
-
onclick="toggleCode('
|
165
|
-
<div class="method-source-code" id="
|
164
|
+
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
165
|
+
<div class="method-source-code" id="M000013-source">
|
166
166
|
<pre>
|
167
167
|
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 18</span>
|
168
168
|
18: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure</span>
|
@@ -178,39 +178,40 @@ Yields a new <a href="Store.html">Configatron::Store</a> class.
|
|
178
178
|
</div>
|
179
179
|
</div>
|
180
180
|
|
181
|
-
<div id="method-
|
182
|
-
<a name="
|
181
|
+
<div id="method-M000014" class="method-detail">
|
182
|
+
<a name="M000014"></a>
|
183
183
|
|
184
184
|
<div class="method-heading">
|
185
|
-
<a href="#
|
185
|
+
<a href="#M000014" class="method-signature">
|
186
186
|
<span class="method-name">configure_from_hash</span><span class="method-args">(parameters)</span>
|
187
187
|
</a>
|
188
188
|
</div>
|
189
189
|
|
190
190
|
<div class="method-description">
|
191
191
|
<p>
|
192
|
-
Used to load configuration settings from a Hash.
|
192
|
+
Used to load configuration settings from a <a href="../Hash.html">Hash</a>.
|
193
193
|
</p>
|
194
194
|
<p><a class="source-toggle" href="#"
|
195
|
-
onclick="toggleCode('
|
196
|
-
<div class="method-source-code" id="
|
195
|
+
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
196
|
+
<div class="method-source-code" id="M000014-source">
|
197
197
|
<pre>
|
198
198
|
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 28</span>
|
199
199
|
28: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure_from_hash</span>(<span class="ruby-identifier">parameters</span>)
|
200
|
-
29: <span class="ruby-identifier">
|
201
|
-
30: <span class="ruby-
|
202
|
-
31: <span class="ruby-
|
203
|
-
32:
|
200
|
+
29: <span class="ruby-identifier">parameters</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_hash</span>.<span class="ruby-identifier">recursive_merge</span>(<span class="ruby-identifier">parameters</span>)
|
201
|
+
30: <span class="ruby-identifier">storage</span> = <span class="ruby-constant">Configatron</span><span class="ruby-operator">::</span><span class="ruby-constant">Store</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">parameters</span>)
|
202
|
+
31: <span class="ruby-ivar">@_storage_list</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">storage</span>
|
203
|
+
32: <span class="ruby-identifier">load_methods</span>(<span class="ruby-identifier">storage</span>)
|
204
|
+
33: <span class="ruby-keyword kw">end</span>
|
204
205
|
</pre>
|
205
206
|
</div>
|
206
207
|
</div>
|
207
208
|
</div>
|
208
209
|
|
209
|
-
<div id="method-
|
210
|
-
<a name="
|
210
|
+
<div id="method-M000015" class="method-detail">
|
211
|
+
<a name="M000015"></a>
|
211
212
|
|
212
213
|
<div class="method-heading">
|
213
|
-
<a href="#
|
214
|
+
<a href="#M000015" class="method-signature">
|
214
215
|
<span class="method-name">configure_from_yaml</span><span class="method-args">(path)</span>
|
215
216
|
</a>
|
216
217
|
</div>
|
@@ -220,30 +221,30 @@ Used to load configuration settings from a Hash.
|
|
220
221
|
Used to load configuration settings from a YAML file.
|
221
222
|
</p>
|
222
223
|
<p><a class="source-toggle" href="#"
|
223
|
-
onclick="toggleCode('
|
224
|
-
<div class="method-source-code" id="
|
224
|
+
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
225
|
+
<div class="method-source-code" id="M000015-source">
|
225
226
|
<pre>
|
226
|
-
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
227
|
+
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 36</span>
|
228
|
+
36: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure_from_yaml</span>(<span class="ruby-identifier">path</span>)
|
229
|
+
37: <span class="ruby-keyword kw">begin</span>
|
230
|
+
38: <span class="ruby-identifier">storage</span> = <span class="ruby-constant">Configatron</span><span class="ruby-operator">::</span><span class="ruby-constant">YamlStore</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">path</span>)
|
231
|
+
39: <span class="ruby-ivar">@_storage_list</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">storage</span>
|
232
|
+
40: <span class="ruby-identifier">load_methods</span>(<span class="ruby-identifier">storage</span>)
|
233
|
+
41: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
234
|
+
42: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
|
235
|
+
43: <span class="ruby-comment cmt"># file doesn't exist.</span>
|
236
|
+
44: <span class="ruby-keyword kw">end</span>
|
237
|
+
45: <span class="ruby-keyword kw">end</span>
|
237
238
|
</pre>
|
238
239
|
</div>
|
239
240
|
</div>
|
240
241
|
</div>
|
241
242
|
|
242
|
-
<div id="method-
|
243
|
-
<a name="
|
243
|
+
<div id="method-M000016" class="method-detail">
|
244
|
+
<a name="M000016"></a>
|
244
245
|
|
245
246
|
<div class="method-heading">
|
246
|
-
<a href="#
|
247
|
+
<a href="#M000016" class="method-signature">
|
247
248
|
<span class="method-name">reload</span><span class="method-args">()</span>
|
248
249
|
</a>
|
249
250
|
</div>
|
@@ -253,26 +254,26 @@ Used to load configuration settings from a YAML file.
|
|
253
254
|
Replays the history of configurations.
|
254
255
|
</p>
|
255
256
|
<p><a class="source-toggle" href="#"
|
256
|
-
onclick="toggleCode('
|
257
|
-
<div class="method-source-code" id="
|
257
|
+
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
|
258
|
+
<div class="method-source-code" id="M000016-source">
|
258
259
|
<pre>
|
259
|
-
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
260
|
+
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 48</span>
|
261
|
+
48: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reload</span>
|
262
|
+
49: <span class="ruby-ivar">@_storage_list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">storage</span><span class="ruby-operator">|</span>
|
263
|
+
50: <span class="ruby-identifier">storage</span>.<span class="ruby-identifier">reload</span>
|
264
|
+
51: <span class="ruby-identifier">load_methods</span>(<span class="ruby-identifier">storage</span>)
|
265
|
+
52: <span class="ruby-keyword kw">end</span>
|
266
|
+
53: <span class="ruby-keyword kw">end</span>
|
266
267
|
</pre>
|
267
268
|
</div>
|
268
269
|
</div>
|
269
270
|
</div>
|
270
271
|
|
271
|
-
<div id="method-
|
272
|
-
<a name="
|
272
|
+
<div id="method-M000018" class="method-detail">
|
273
|
+
<a name="M000018"></a>
|
273
274
|
|
274
275
|
<div class="method-heading">
|
275
|
-
<a href="#
|
276
|
+
<a href="#M000018" class="method-signature">
|
276
277
|
<span class="method-name">reset</span><span class="method-args">()</span>
|
277
278
|
</a>
|
278
279
|
</div>
|
@@ -282,64 +283,64 @@ Replays the history of configurations.
|
|
282
283
|
All methods are undefined.
|
283
284
|
</p>
|
284
285
|
<p><a class="source-toggle" href="#"
|
285
|
-
onclick="toggleCode('
|
286
|
-
<div class="method-source-code" id="
|
286
|
+
onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
|
287
|
+
<div class="method-source-code" id="M000018-source">
|
287
288
|
<pre>
|
288
|
-
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
289
|
+
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 65</span>
|
290
|
+
65: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset</span>
|
291
|
+
66: <span class="ruby-ivar">@_storage_list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">storage</span><span class="ruby-operator">|</span>
|
292
|
+
67: <span class="ruby-identifier">storage</span>.<span class="ruby-identifier">parameters</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
293
|
+
68: <span class="ruby-constant">Configatron</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">instance_eval</span> <span class="ruby-keyword kw">do</span>
|
294
|
+
69: <span class="ruby-keyword kw">begin</span>
|
295
|
+
70: <span class="ruby-identifier">undef_method</span>(<span class="ruby-identifier">k</span>)
|
296
|
+
71: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">NameError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
297
|
+
72: <span class="ruby-keyword kw">end</span>
|
298
|
+
73: <span class="ruby-keyword kw">end</span>
|
299
|
+
74: <span class="ruby-keyword kw">end</span>
|
300
|
+
75: <span class="ruby-keyword kw">end</span>
|
301
|
+
76: <span class="ruby-keyword kw">end</span>
|
301
302
|
</pre>
|
302
303
|
</div>
|
303
304
|
</div>
|
304
305
|
</div>
|
305
306
|
|
306
|
-
<div id="method-
|
307
|
-
<a name="
|
307
|
+
<div id="method-M000017" class="method-detail">
|
308
|
+
<a name="M000017"></a>
|
308
309
|
|
309
310
|
<div class="method-heading">
|
310
|
-
<a href="#
|
311
|
+
<a href="#M000017" class="method-signature">
|
311
312
|
<span class="method-name">reset!</span><span class="method-args">()</span>
|
312
313
|
</a>
|
313
314
|
</div>
|
314
315
|
|
315
316
|
<div class="method-description">
|
316
317
|
<p>
|
317
|
-
Does a hard <a href="Configuration.html#
|
318
|
+
Does a hard <a href="Configuration.html#M000018">reset</a> of the <a
|
318
319
|
href="Configuration.html">Configatron::Configuration</a> class. All methods
|
319
320
|
are undefined, the list of configuration parameters is emptied, and the
|
320
|
-
nil_for_missing method gets <a href="Configuration.html#
|
321
|
+
nil_for_missing method gets <a href="Configuration.html#M000018">reset</a>
|
321
322
|
to false.
|
322
323
|
</p>
|
323
324
|
<p><a class="source-toggle" href="#"
|
324
|
-
onclick="toggleCode('
|
325
|
-
<div class="method-source-code" id="
|
325
|
+
onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
|
326
|
+
<div class="method-source-code" id="M000017-source">
|
326
327
|
<pre>
|
327
|
-
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
328
|
+
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 58</span>
|
329
|
+
58: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset!</span>
|
330
|
+
59: <span class="ruby-identifier">reset</span>
|
331
|
+
60: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">nil_for_missing</span> = <span class="ruby-keyword kw">false</span>
|
332
|
+
61: <span class="ruby-ivar">@_storage_list</span> = []
|
333
|
+
62: <span class="ruby-keyword kw">end</span>
|
333
334
|
</pre>
|
334
335
|
</div>
|
335
336
|
</div>
|
336
337
|
</div>
|
337
338
|
|
338
|
-
<div id="method-
|
339
|
-
<a name="
|
339
|
+
<div id="method-M000019" class="method-detail">
|
340
|
+
<a name="M000019"></a>
|
340
341
|
|
341
342
|
<div class="method-heading">
|
342
|
-
<a href="#
|
343
|
+
<a href="#M000019" class="method-signature">
|
343
344
|
<span class="method-name">revert</span><span class="method-args">(step = 1)</span>
|
344
345
|
</a>
|
345
346
|
</div>
|
@@ -349,38 +350,38 @@ to false.
|
|
349
350
|
Peels back n number of configuration parameters.
|
350
351
|
</p>
|
351
352
|
<p><a class="source-toggle" href="#"
|
352
|
-
onclick="toggleCode('
|
353
|
-
<div class="method-source-code" id="
|
353
|
+
onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
|
354
|
+
<div class="method-source-code" id="M000019-source">
|
354
355
|
<pre>
|
355
|
-
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
356
|
+
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 79</span>
|
357
|
+
79: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">revert</span>(<span class="ruby-identifier">step</span> = <span class="ruby-value">1</span>)
|
358
|
+
80: <span class="ruby-identifier">reset</span>
|
359
|
+
81: <span class="ruby-identifier">step</span>.<span class="ruby-identifier">times</span> {<span class="ruby-ivar">@_storage_list</span>.<span class="ruby-identifier">pop</span>}
|
360
|
+
82: <span class="ruby-identifier">reload</span>
|
361
|
+
83: <span class="ruby-keyword kw">end</span>
|
361
362
|
</pre>
|
362
363
|
</div>
|
363
364
|
</div>
|
364
365
|
</div>
|
365
366
|
|
366
|
-
<div id="method-
|
367
|
-
<a name="
|
367
|
+
<div id="method-M000020" class="method-detail">
|
368
|
+
<a name="M000020"></a>
|
368
369
|
|
369
370
|
<div class="method-heading">
|
370
|
-
<a href="#
|
371
|
+
<a href="#M000020" class="method-signature">
|
371
372
|
<span class="method-name">to_hash</span><span class="method-args">()</span>
|
372
373
|
</a>
|
373
374
|
</div>
|
374
375
|
|
375
376
|
<div class="method-description">
|
376
377
|
<p><a class="source-toggle" href="#"
|
377
|
-
onclick="toggleCode('
|
378
|
-
<div class="method-source-code" id="
|
378
|
+
onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
|
379
|
+
<div class="method-source-code" id="M000020-source">
|
379
380
|
<pre>
|
380
|
-
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line
|
381
|
-
|
382
|
-
|
383
|
-
|
381
|
+
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 89</span>
|
382
|
+
89: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_hash</span>
|
383
|
+
90: <span class="ruby-ivar">@_storage_list</span>.<span class="ruby-identifier">inject</span>({}) { <span class="ruby-operator">|</span><span class="ruby-identifier">acc</span>, <span class="ruby-identifier">storage</span><span class="ruby-operator">|</span> <span class="ruby-identifier">acc</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">storage</span>.<span class="ruby-identifier">to_hash</span>) }
|
384
|
+
91: <span class="ruby-keyword kw">end</span>
|
384
385
|
</pre>
|
385
386
|
</div>
|
386
387
|
</div>
|
@@ -80,8 +80,8 @@
|
|
80
80
|
<h3 class="section-bar">Methods</h3>
|
81
81
|
|
82
82
|
<div class="name-list">
|
83
|
-
<a href="#
|
84
|
-
<a href="#
|
83
|
+
<a href="#M000003">exists?</a>
|
84
|
+
<a href="#M000004">retrieve</a>
|
85
85
|
</div>
|
86
86
|
</div>
|
87
87
|
|
@@ -103,11 +103,11 @@
|
|
103
103
|
<div id="methods">
|
104
104
|
<h3 class="section-bar">Public Instance methods</h3>
|
105
105
|
|
106
|
-
<div id="method-
|
107
|
-
<a name="
|
106
|
+
<div id="method-M000003" class="method-detail">
|
107
|
+
<a name="M000003"></a>
|
108
108
|
|
109
109
|
<div class="method-heading">
|
110
|
-
<a href="#
|
110
|
+
<a href="#M000003" class="method-signature">
|
111
111
|
<span class="method-name">exists?</span><span class="method-args">(name)</span>
|
112
112
|
</a>
|
113
113
|
</div>
|
@@ -117,8 +117,8 @@
|
|
117
117
|
Checks whether or not configuration parameter exists.
|
118
118
|
</p>
|
119
119
|
<p><a class="source-toggle" href="#"
|
120
|
-
onclick="toggleCode('
|
121
|
-
<div class="method-source-code" id="
|
120
|
+
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
121
|
+
<div class="method-source-code" id="M000003-source">
|
122
122
|
<pre>
|
123
123
|
<span class="ruby-comment cmt"># File lib/configatron/helpers.rb, line 5</span>
|
124
124
|
5: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">name</span>)
|
@@ -129,11 +129,11 @@ Checks whether or not configuration parameter exists.
|
|
129
129
|
</div>
|
130
130
|
</div>
|
131
131
|
|
132
|
-
<div id="method-
|
133
|
-
<a name="
|
132
|
+
<div id="method-M000004" class="method-detail">
|
133
|
+
<a name="M000004"></a>
|
134
134
|
|
135
135
|
<div class="method-heading">
|
136
|
-
<a href="#
|
136
|
+
<a href="#M000004" class="method-signature">
|
137
137
|
<span class="method-name">retrieve</span><span class="method-args">(name, default_value = ArgumentError)</span>
|
138
138
|
</a>
|
139
139
|
</div>
|
@@ -145,8 +145,8 @@ be passed that will be returned if the config parameter doesn‘t
|
|
145
145
|
exist.
|
146
146
|
</p>
|
147
147
|
<p><a class="source-toggle" href="#"
|
148
|
-
onclick="toggleCode('
|
149
|
-
<div class="method-source-code" id="
|
148
|
+
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
149
|
+
<div class="method-source-code" id="M000004-source">
|
150
150
|
<pre>
|
151
151
|
<span class="ruby-comment cmt"># File lib/configatron/helpers.rb, line 20</span>
|
152
152
|
20: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">retrieve</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">default_value</span> = <span class="ruby-constant">ArgumentError</span>)
|
@@ -92,12 +92,12 @@ Used to store each of the ‘sets’ of configuration parameters.
|
|
92
92
|
<h3 class="section-bar">Methods</h3>
|
93
93
|
|
94
94
|
<div class="name-list">
|
95
|
-
<a href="#
|
96
|
-
<a href="#
|
97
|
-
<a href="#
|
98
|
-
<a href="#
|
99
|
-
<a href="#
|
100
|
-
<a href="#
|
95
|
+
<a href="#M000007">exists?</a>
|
96
|
+
<a href="#M000006">method_missing</a>
|
97
|
+
<a href="#M000008">namespace</a>
|
98
|
+
<a href="#M000005">new</a>
|
99
|
+
<a href="#M000009">reload</a>
|
100
|
+
<a href="#M000010">to_hash</a>
|
101
101
|
</div>
|
102
102
|
</div>
|
103
103
|
|
@@ -142,22 +142,22 @@ The actual key/pair parameter values.
|
|
142
142
|
<div id="methods">
|
143
143
|
<h3 class="section-bar">Public Class methods</h3>
|
144
144
|
|
145
|
-
<div id="method-
|
146
|
-
<a name="
|
145
|
+
<div id="method-M000005" class="method-detail">
|
146
|
+
<a name="M000005"></a>
|
147
147
|
|
148
148
|
<div class="method-heading">
|
149
|
-
<a href="#
|
149
|
+
<a href="#M000005" class="method-signature">
|
150
150
|
<span class="method-name">new</span><span class="method-args">(parameters = {})</span>
|
151
151
|
</a>
|
152
152
|
</div>
|
153
153
|
|
154
154
|
<div class="method-description">
|
155
155
|
<p>
|
156
|
-
Takes an optional Hash to configure parameters.
|
156
|
+
Takes an optional <a href="../Hash.html">Hash</a> to configure parameters.
|
157
157
|
</p>
|
158
158
|
<p><a class="source-toggle" href="#"
|
159
|
-
onclick="toggleCode('
|
160
|
-
<div class="method-source-code" id="
|
159
|
+
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
160
|
+
<div class="method-source-code" id="M000005-source">
|
161
161
|
<pre>
|
162
162
|
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 10</span>
|
163
163
|
10: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">parameters</span> = {})
|
@@ -174,11 +174,11 @@ Takes an optional Hash to configure parameters.
|
|
174
174
|
|
175
175
|
<h3 class="section-bar">Public Instance methods</h3>
|
176
176
|
|
177
|
-
<div id="method-
|
178
|
-
<a name="
|
177
|
+
<div id="method-M000007" class="method-detail">
|
178
|
+
<a name="M000007"></a>
|
179
179
|
|
180
180
|
<div class="method-heading">
|
181
|
-
<a href="#
|
181
|
+
<a href="#M000007" class="method-signature">
|
182
182
|
<span class="method-name">exists?</span><span class="method-args">(name)</span>
|
183
183
|
</a>
|
184
184
|
</div>
|
@@ -188,8 +188,8 @@ Takes an optional Hash to configure parameters.
|
|
188
188
|
Checks whether or not configuration parameter exists.
|
189
189
|
</p>
|
190
190
|
<p><a class="source-toggle" href="#"
|
191
|
-
onclick="toggleCode('
|
192
|
-
<div class="method-source-code" id="
|
191
|
+
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
192
|
+
<div class="method-source-code" id="M000007-source">
|
193
193
|
<pre>
|
194
194
|
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 37</span>
|
195
195
|
37: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">name</span>)
|
@@ -201,11 +201,11 @@ Checks whether or not configuration parameter exists.
|
|
201
201
|
</div>
|
202
202
|
</div>
|
203
203
|
|
204
|
-
<div id="method-
|
205
|
-
<a name="
|
204
|
+
<div id="method-M000006" class="method-detail">
|
205
|
+
<a name="M000006"></a>
|
206
206
|
|
207
207
|
<div class="method-heading">
|
208
|
-
<a href="#
|
208
|
+
<a href="#M000006" class="method-signature">
|
209
209
|
<span class="method-name">method_missing</span><span class="method-args">(sym, *args)</span>
|
210
210
|
</a>
|
211
211
|
</div>
|
@@ -219,8 +219,8 @@ names. If a method is called without an = sign at the end then the value
|
|
219
219
|
from the parameters hash is returned, if it exists.
|
220
220
|
</p>
|
221
221
|
<p><a class="source-toggle" href="#"
|
222
|
-
onclick="toggleCode('
|
223
|
-
<div class="method-source-code" id="
|
222
|
+
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
223
|
+
<div class="method-source-code" id="M000006-source">
|
224
224
|
<pre>
|
225
225
|
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 23</span>
|
226
226
|
23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
@@ -240,11 +240,11 @@ from the parameters hash is returned, if it exists.
|
|
240
240
|
</div>
|
241
241
|
</div>
|
242
242
|
|
243
|
-
<div id="method-
|
244
|
-
<a name="
|
243
|
+
<div id="method-M000008" class="method-detail">
|
244
|
+
<a name="M000008"></a>
|
245
245
|
|
246
246
|
<div class="method-heading">
|
247
|
-
<a href="#
|
247
|
+
<a href="#M000008" class="method-signature">
|
248
248
|
<span class="method-name">namespace</span><span class="method-args">(name) {|self.send(name.to_sym)| ...}</span>
|
249
249
|
</a>
|
250
250
|
</div>
|
@@ -255,8 +255,8 @@ Used to create ‘namespaces’ around a set of configuration
|
|
255
255
|
parameters.
|
256
256
|
</p>
|
257
257
|
<p><a class="source-toggle" href="#"
|
258
|
-
onclick="toggleCode('
|
259
|
-
<div class="method-source-code" id="
|
258
|
+
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
259
|
+
<div class="method-source-code" id="M000008-source">
|
260
260
|
<pre>
|
261
261
|
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 43</span>
|
262
262
|
43: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">namespace</span>(<span class="ruby-identifier">name</span>)
|
@@ -275,24 +275,24 @@ parameters.
|
|
275
275
|
</div>
|
276
276
|
</div>
|
277
277
|
|
278
|
-
<div id="method-
|
279
|
-
<a name="
|
278
|
+
<div id="method-M000009" class="method-detail">
|
279
|
+
<a name="M000009"></a>
|
280
280
|
|
281
281
|
<div class="method-heading">
|
282
|
-
<a href="#
|
282
|
+
<a href="#M000009" class="method-signature">
|
283
283
|
<span class="method-name">reload</span><span class="method-args">()</span>
|
284
284
|
</a>
|
285
285
|
</div>
|
286
286
|
|
287
287
|
<div class="method-description">
|
288
288
|
<p>
|
289
|
-
Called when a <a href="Store.html#
|
289
|
+
Called when a <a href="Store.html#M000009">reload</a> is called on
|
290
290
|
configatron. Useful for subclasses that may need to read a file in,
|
291
291
|
etc…
|
292
292
|
</p>
|
293
293
|
<p><a class="source-toggle" href="#"
|
294
|
-
onclick="toggleCode('
|
295
|
-
<div class="method-source-code" id="
|
294
|
+
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
295
|
+
<div class="method-source-code" id="M000009-source">
|
296
296
|
<pre>
|
297
297
|
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 57</span>
|
298
298
|
57: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reload</span>
|
@@ -302,19 +302,19 @@ etc…
|
|
302
302
|
</div>
|
303
303
|
</div>
|
304
304
|
|
305
|
-
<div id="method-
|
306
|
-
<a name="
|
305
|
+
<div id="method-M000010" class="method-detail">
|
306
|
+
<a name="M000010"></a>
|
307
307
|
|
308
308
|
<div class="method-heading">
|
309
|
-
<a href="#
|
309
|
+
<a href="#M000010" class="method-signature">
|
310
310
|
<span class="method-name">to_hash</span><span class="method-args">()</span>
|
311
311
|
</a>
|
312
312
|
</div>
|
313
313
|
|
314
314
|
<div class="method-description">
|
315
315
|
<p><a class="source-toggle" href="#"
|
316
|
-
onclick="toggleCode('
|
317
|
-
<div class="method-source-code" id="
|
316
|
+
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
317
|
+
<div class="method-source-code" id="M000010-source">
|
318
318
|
<pre>
|
319
319
|
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 60</span>
|
320
320
|
60: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_hash</span>
|
@@ -95,8 +95,8 @@ that came from a YAML file.
|
|
95
95
|
<h3 class="section-bar">Methods</h3>
|
96
96
|
|
97
97
|
<div class="name-list">
|
98
|
-
<a href="#
|
99
|
-
<a href="#
|
98
|
+
<a href="#M000011">new</a>
|
99
|
+
<a href="#M000012">reload</a>
|
100
100
|
</div>
|
101
101
|
</div>
|
102
102
|
|
@@ -131,11 +131,11 @@ that came from a YAML file.
|
|
131
131
|
<div id="methods">
|
132
132
|
<h3 class="section-bar">Public Class methods</h3>
|
133
133
|
|
134
|
-
<div id="method-
|
135
|
-
<a name="
|
134
|
+
<div id="method-M000011" class="method-detail">
|
135
|
+
<a name="M000011"></a>
|
136
136
|
|
137
137
|
<div class="method-heading">
|
138
|
-
<a href="#
|
138
|
+
<a href="#M000011" class="method-signature">
|
139
139
|
<span class="method-name">new</span><span class="method-args">(file_location)</span>
|
140
140
|
</a>
|
141
141
|
</div>
|
@@ -145,8 +145,8 @@ that came from a YAML file.
|
|
145
145
|
Takes the full path to the YAML file.
|
146
146
|
</p>
|
147
147
|
<p><a class="source-toggle" href="#"
|
148
|
-
onclick="toggleCode('
|
149
|
-
<div class="method-source-code" id="
|
148
|
+
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
149
|
+
<div class="method-source-code" id="M000011-source">
|
150
150
|
<pre>
|
151
151
|
<span class="ruby-comment cmt"># File lib/configatron/yaml_store.rb, line 9</span>
|
152
152
|
9: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">file_location</span>)
|
@@ -160,11 +160,11 @@ Takes the full path to the YAML file.
|
|
160
160
|
|
161
161
|
<h3 class="section-bar">Public Instance methods</h3>
|
162
162
|
|
163
|
-
<div id="method-
|
164
|
-
<a name="
|
163
|
+
<div id="method-M000012" class="method-detail">
|
164
|
+
<a name="M000012"></a>
|
165
165
|
|
166
166
|
<div class="method-heading">
|
167
|
-
<a href="#
|
167
|
+
<a href="#M000012" class="method-signature">
|
168
168
|
<span class="method-name">reload</span><span class="method-args">()</span>
|
169
169
|
</a>
|
170
170
|
</div>
|
@@ -174,8 +174,8 @@ Takes the full path to the YAML file.
|
|
174
174
|
Re-reads the YAML file.
|
175
175
|
</p>
|
176
176
|
<p><a class="source-toggle" href="#"
|
177
|
-
onclick="toggleCode('
|
178
|
-
<div class="method-source-code" id="
|
177
|
+
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
178
|
+
<div class="method-source-code" id="M000012-source">
|
179
179
|
<pre>
|
180
180
|
<span class="ruby-comment cmt"># File lib/configatron/yaml_store.rb, line 15</span>
|
181
181
|
15: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reload</span>
|
@@ -0,0 +1,193 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Hash</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Hash</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../files/lib/configatron_rb.html">
|
59
|
+
lib/configatron.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<div id="method-list">
|
86
|
+
<h3 class="section-bar">Methods</h3>
|
87
|
+
|
88
|
+
<div class="name-list">
|
89
|
+
<a href="#M000001">recursive_merge</a>
|
90
|
+
<a href="#M000002">recursive_merge!</a>
|
91
|
+
</div>
|
92
|
+
</div>
|
93
|
+
|
94
|
+
</div>
|
95
|
+
|
96
|
+
|
97
|
+
<!-- if includes -->
|
98
|
+
|
99
|
+
<div id="section">
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
<!-- if method_list -->
|
109
|
+
<div id="methods">
|
110
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
111
|
+
|
112
|
+
<div id="method-M000001" class="method-detail">
|
113
|
+
<a name="M000001"></a>
|
114
|
+
|
115
|
+
<div class="method-heading">
|
116
|
+
<a href="#M000001" class="method-signature">
|
117
|
+
<span class="method-name">recursive_merge</span><span class="method-args">(other)</span>
|
118
|
+
</a>
|
119
|
+
</div>
|
120
|
+
|
121
|
+
<div class="method-description">
|
122
|
+
<p>
|
123
|
+
Same as Hash#merge but recursively merges sub-hashes.
|
124
|
+
</p>
|
125
|
+
<p><a class="source-toggle" href="#"
|
126
|
+
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
127
|
+
<div class="method-source-code" id="M000001-source">
|
128
|
+
<pre>
|
129
|
+
<span class="ruby-comment cmt"># File lib/configatron.rb, line 17</span>
|
130
|
+
17: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">recursive_merge</span>(<span class="ruby-identifier">other</span>)
|
131
|
+
18: <span class="ruby-identifier">hash</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">dup</span>
|
132
|
+
19: <span class="ruby-identifier">other</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
|
133
|
+
20: <span class="ruby-identifier">myval</span> = <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">key</span>]
|
134
|
+
21: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">myval</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
135
|
+
22: <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">myval</span>.<span class="ruby-identifier">recursive_merge</span>(<span class="ruby-identifier">value</span>)
|
136
|
+
23: <span class="ruby-keyword kw">else</span>
|
137
|
+
24: <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
|
138
|
+
25: <span class="ruby-keyword kw">end</span>
|
139
|
+
26: <span class="ruby-keyword kw">end</span>
|
140
|
+
27: <span class="ruby-identifier">hash</span>
|
141
|
+
28: <span class="ruby-keyword kw">end</span>
|
142
|
+
</pre>
|
143
|
+
</div>
|
144
|
+
</div>
|
145
|
+
</div>
|
146
|
+
|
147
|
+
<div id="method-M000002" class="method-detail">
|
148
|
+
<a name="M000002"></a>
|
149
|
+
|
150
|
+
<div class="method-heading">
|
151
|
+
<a href="#M000002" class="method-signature">
|
152
|
+
<span class="method-name">recursive_merge!</span><span class="method-args">(other)</span>
|
153
|
+
</a>
|
154
|
+
</div>
|
155
|
+
|
156
|
+
<div class="method-description">
|
157
|
+
<p>
|
158
|
+
Same as Hash#merge! but recursively merges sub-hashes.
|
159
|
+
</p>
|
160
|
+
<p><a class="source-toggle" href="#"
|
161
|
+
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
162
|
+
<div class="method-source-code" id="M000002-source">
|
163
|
+
<pre>
|
164
|
+
<span class="ruby-comment cmt"># File lib/configatron.rb, line 32</span>
|
165
|
+
32: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">recursive_merge!</span>(<span class="ruby-identifier">other</span>)
|
166
|
+
33: <span class="ruby-identifier">other</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
|
167
|
+
34: <span class="ruby-identifier">myval</span> = <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">key</span>]
|
168
|
+
35: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">myval</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
169
|
+
36: <span class="ruby-identifier">myval</span>.<span class="ruby-identifier">recursive_merge!</span>(<span class="ruby-identifier">value</span>)
|
170
|
+
37: <span class="ruby-keyword kw">else</span>
|
171
|
+
38: <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
|
172
|
+
39: <span class="ruby-keyword kw">end</span>
|
173
|
+
40: <span class="ruby-keyword kw">end</span>
|
174
|
+
41: <span class="ruby-keyword kw">self</span>
|
175
|
+
42: <span class="ruby-keyword kw">end</span>
|
176
|
+
</pre>
|
177
|
+
</div>
|
178
|
+
</div>
|
179
|
+
</div>
|
180
|
+
|
181
|
+
|
182
|
+
</div>
|
183
|
+
|
184
|
+
|
185
|
+
</div>
|
186
|
+
|
187
|
+
|
188
|
+
<div id="validator-badges">
|
189
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
190
|
+
</div>
|
191
|
+
|
192
|
+
</body>
|
193
|
+
</html>
|
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="#M000021">configatron</a>
|
84
84
|
</div>
|
85
85
|
</div>
|
86
86
|
|
@@ -102,11 +102,11 @@
|
|
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-M000021" class="method-detail">
|
106
|
+
<a name="M000021"></a>
|
107
107
|
|
108
108
|
<div class="method-heading">
|
109
|
-
<a href="#
|
109
|
+
<a href="#M000021" class="method-signature">
|
110
110
|
<span class="method-name">configatron</span><span class="method-args">(&block)</span>
|
111
111
|
</a>
|
112
112
|
</div>
|
@@ -120,8 +120,8 @@ Configatron::Configatron configure method and yield up a <a
|
|
120
120
|
href="Configatron/Store.html">Configatron::Store</a> object.
|
121
121
|
</p>
|
122
122
|
<p><a class="source-toggle" href="#"
|
123
|
-
onclick="toggleCode('
|
124
|
-
<div class="method-source-code" id="
|
123
|
+
onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
|
124
|
+
<div class="method-source-code" id="M000021-source">
|
125
125
|
<pre>
|
126
126
|
<span class="ruby-comment cmt"># File lib/configatron/kernel.rb, line 6</span>
|
127
127
|
6: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configatron</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
data/doc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Mon, 15 Sep 2008 11:06:30 -0400
|
data/doc/files/README.html
CHANGED
@@ -120,7 +120,7 @@ becomes:
|
|
120
120
|
Notice how our other configuration parameters haven‘t changed? Cool,
|
121
121
|
eh?
|
122
122
|
</p>
|
123
|
-
<h3>Hash
|
123
|
+
<h3><a href="../classes/Hash.html">Hash</a>/YAML</h3>
|
124
124
|
<p>
|
125
125
|
You can configure configatron from a hash as well:
|
126
126
|
</p>
|
data/doc/fr_class_index.html
CHANGED
@@ -24,6 +24,7 @@
|
|
24
24
|
<a href="classes/Configatron/Helpers.html">Configatron::Helpers</a><br />
|
25
25
|
<a href="classes/Configatron/Store.html">Configatron::Store</a><br />
|
26
26
|
<a href="classes/Configatron/YamlStore.html">Configatron::YamlStore</a><br />
|
27
|
+
<a href="classes/Hash.html">Hash</a><br />
|
27
28
|
<a href="classes/Kernel.html">Kernel</a><br />
|
28
29
|
</div>
|
29
30
|
</div>
|
data/doc/fr_method_index.html
CHANGED
@@ -20,25 +20,27 @@
|
|
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/Configuration.html#
|
25
|
-
<a href="classes/Configatron/Configuration.html#
|
26
|
-
<a href="classes/Configatron/Configuration.html#
|
27
|
-
<a href="classes/Configatron/
|
28
|
-
<a href="classes/Configatron/
|
29
|
-
<a href="classes/Configatron/Store.html#
|
30
|
-
<a href="classes/Configatron/Store.html#
|
31
|
-
<a href="classes/Configatron/
|
32
|
-
<a href="classes/Configatron/
|
33
|
-
<a href="classes/
|
34
|
-
<a href="classes/
|
35
|
-
<a href="classes/Configatron/YamlStore.html#
|
36
|
-
<a href="classes/Configatron/
|
37
|
-
<a href="classes/Configatron/Configuration.html#
|
38
|
-
<a href="classes/Configatron/
|
39
|
-
<a href="classes/Configatron/Configuration.html#M000017">
|
40
|
-
<a href="classes/Configatron/
|
41
|
-
<a href="classes/Configatron/
|
23
|
+
<a href="classes/Kernel.html#M000021">configatron (Kernel)</a><br />
|
24
|
+
<a href="classes/Configatron/Configuration.html#M000013">configure (Configatron::Configuration)</a><br />
|
25
|
+
<a href="classes/Configatron/Configuration.html#M000014">configure_from_hash (Configatron::Configuration)</a><br />
|
26
|
+
<a href="classes/Configatron/Configuration.html#M000015">configure_from_yaml (Configatron::Configuration)</a><br />
|
27
|
+
<a href="classes/Configatron/Helpers.html#M000003">exists? (Configatron::Helpers)</a><br />
|
28
|
+
<a href="classes/Configatron/Store.html#M000007">exists? (Configatron::Store)</a><br />
|
29
|
+
<a href="classes/Configatron/Store.html#M000006">method_missing (Configatron::Store)</a><br />
|
30
|
+
<a href="classes/Configatron/Store.html#M000008">namespace (Configatron::Store)</a><br />
|
31
|
+
<a href="classes/Configatron/Store.html#M000005">new (Configatron::Store)</a><br />
|
32
|
+
<a href="classes/Configatron/YamlStore.html#M000011">new (Configatron::YamlStore)</a><br />
|
33
|
+
<a href="classes/Hash.html#M000001">recursive_merge (Hash)</a><br />
|
34
|
+
<a href="classes/Hash.html#M000002">recursive_merge! (Hash)</a><br />
|
35
|
+
<a href="classes/Configatron/YamlStore.html#M000012">reload (Configatron::YamlStore)</a><br />
|
36
|
+
<a href="classes/Configatron/Store.html#M000009">reload (Configatron::Store)</a><br />
|
37
|
+
<a href="classes/Configatron/Configuration.html#M000016">reload (Configatron::Configuration)</a><br />
|
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 />
|
42
44
|
</div>
|
43
45
|
</div>
|
44
46
|
</body>
|
@@ -26,6 +26,7 @@ module Configatron
|
|
26
26
|
|
27
27
|
# Used to load configuration settings from a Hash.
|
28
28
|
def configure_from_hash(parameters)
|
29
|
+
parameters = self.to_hash.recursive_merge(parameters)
|
29
30
|
storage = Configatron::Store.new(parameters)
|
30
31
|
@_storage_list << storage
|
31
32
|
load_methods(storage)
|
data/lib/configatron.rb
CHANGED
@@ -8,4 +8,38 @@ require File.join(File.dirname(__FILE__), 'configatron', 'store')
|
|
8
8
|
require File.join(File.dirname(__FILE__), 'configatron', 'yaml_store')
|
9
9
|
|
10
10
|
module Configatron # :nodoc:
|
11
|
-
end
|
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
|
+
|
@@ -28,6 +28,23 @@ describe Configatron::Configuration do
|
|
28
28
|
configatron.homer.should == "Homer Simpson"
|
29
29
|
end
|
30
30
|
|
31
|
+
it "doesn't wipe out existing configurations" do
|
32
|
+
configatron do |c|
|
33
|
+
c.namespace(:mack) do |mack|
|
34
|
+
mack.one = 1
|
35
|
+
mack.two = 2
|
36
|
+
mack.three = 3
|
37
|
+
end
|
38
|
+
c.a = 'a'
|
39
|
+
c.b = 'b'
|
40
|
+
end
|
41
|
+
configatron.to_hash.should == {:mack => {:one => 1, :two => 2, :three => 3}, :a => 'a', :b => 'b'}
|
42
|
+
configatron.configure_from_hash(:mack => {:one => 'one'}, :b => 'bee')
|
43
|
+
configatron.to_hash.should == {:mack => {:one => 'one', :two => 2, :three => 3}, :a => 'a', :b => 'bee'}
|
44
|
+
configatron.revert
|
45
|
+
configatron.to_hash.should == {:mack => {:one => 1, :two => 2, :three => 3}, :a => 'a', :b => 'b'}
|
46
|
+
end
|
47
|
+
|
31
48
|
end
|
32
49
|
|
33
50
|
describe "hashes to namespace" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: configatron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- markbates
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-09-
|
12
|
+
date: 2008-09-15 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -33,6 +33,7 @@ files:
|
|
33
33
|
- doc/classes/Configatron/Helpers.html
|
34
34
|
- doc/classes/Configatron/Store.html
|
35
35
|
- doc/classes/Configatron/YamlStore.html
|
36
|
+
- doc/classes/Hash.html
|
36
37
|
- doc/classes/Kernel.html
|
37
38
|
- doc/created.rid
|
38
39
|
- doc/files/lib/configatron/configuration_rb.html
|