configatron 1.2.0 → 1.2.1
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 +68 -44
- data/doc/classes/Configatron/Store.html +33 -0
- data/doc/classes/Configatron/YamlStore.html +12 -12
- 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/helpers_rb.html +1 -1
- 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/yaml_store_rb.html +1 -1
- data/doc/files/lib/configatron_rb.html +1 -1
- data/doc/fr_method_index.html +12 -10
- data/lib/configatron/configuration.rb +4 -0
- data/lib/configatron/store.rb +13 -0
- data/spec/unit/configuration_spec.rb +20 -0
- data/spec/unit/store_spec.rb +24 -1
- metadata +2 -2
@@ -92,13 +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="#
|
95
|
+
<a href="#M000011">configure</a>
|
96
|
+
<a href="#M000012">configure_from_hash</a>
|
97
|
+
<a href="#M000013">configure_from_yaml</a>
|
98
|
+
<a href="#M000014">reload</a>
|
99
|
+
<a href="#M000016">reset</a>
|
100
|
+
<a href="#M000015">reset!</a>
|
101
|
+
<a href="#M000017">revert</a>
|
102
|
+
<a href="#M000018">to_hash</a>
|
102
103
|
</div>
|
103
104
|
</div>
|
104
105
|
|
@@ -146,11 +147,11 @@ NoMethodError exception will be raised.
|
|
146
147
|
<div id="methods">
|
147
148
|
<h3 class="section-bar">Public Instance methods</h3>
|
148
149
|
|
149
|
-
<div id="method-
|
150
|
-
<a name="
|
150
|
+
<div id="method-M000011" class="method-detail">
|
151
|
+
<a name="M000011"></a>
|
151
152
|
|
152
153
|
<div class="method-heading">
|
153
|
-
<a href="#
|
154
|
+
<a href="#M000011" class="method-signature">
|
154
155
|
<span class="method-name">configure</span><span class="method-args">() {|storage| ...}</span>
|
155
156
|
</a>
|
156
157
|
</div>
|
@@ -160,8 +161,8 @@ NoMethodError exception will be raised.
|
|
160
161
|
Yields a new <a href="Store.html">Configatron::Store</a> class.
|
161
162
|
</p>
|
162
163
|
<p><a class="source-toggle" href="#"
|
163
|
-
onclick="toggleCode('
|
164
|
-
<div class="method-source-code" id="
|
164
|
+
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
165
|
+
<div class="method-source-code" id="M000011-source">
|
165
166
|
<pre>
|
166
167
|
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 18</span>
|
167
168
|
18: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure</span>
|
@@ -177,11 +178,11 @@ Yields a new <a href="Store.html">Configatron::Store</a> class.
|
|
177
178
|
</div>
|
178
179
|
</div>
|
179
180
|
|
180
|
-
<div id="method-
|
181
|
-
<a name="
|
181
|
+
<div id="method-M000012" class="method-detail">
|
182
|
+
<a name="M000012"></a>
|
182
183
|
|
183
184
|
<div class="method-heading">
|
184
|
-
<a href="#
|
185
|
+
<a href="#M000012" class="method-signature">
|
185
186
|
<span class="method-name">configure_from_hash</span><span class="method-args">(parameters)</span>
|
186
187
|
</a>
|
187
188
|
</div>
|
@@ -191,8 +192,8 @@ Yields a new <a href="Store.html">Configatron::Store</a> class.
|
|
191
192
|
Used to load configuration settings from a Hash.
|
192
193
|
</p>
|
193
194
|
<p><a class="source-toggle" href="#"
|
194
|
-
onclick="toggleCode('
|
195
|
-
<div class="method-source-code" id="
|
195
|
+
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
196
|
+
<div class="method-source-code" id="M000012-source">
|
196
197
|
<pre>
|
197
198
|
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 28</span>
|
198
199
|
28: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure_from_hash</span>(<span class="ruby-identifier">parameters</span>)
|
@@ -205,11 +206,11 @@ Used to load configuration settings from a Hash.
|
|
205
206
|
</div>
|
206
207
|
</div>
|
207
208
|
|
208
|
-
<div id="method-
|
209
|
-
<a name="
|
209
|
+
<div id="method-M000013" class="method-detail">
|
210
|
+
<a name="M000013"></a>
|
210
211
|
|
211
212
|
<div class="method-heading">
|
212
|
-
<a href="#
|
213
|
+
<a href="#M000013" class="method-signature">
|
213
214
|
<span class="method-name">configure_from_yaml</span><span class="method-args">(path)</span>
|
214
215
|
</a>
|
215
216
|
</div>
|
@@ -219,8 +220,8 @@ Used to load configuration settings from a Hash.
|
|
219
220
|
Used to load configuration settings from a YAML file.
|
220
221
|
</p>
|
221
222
|
<p><a class="source-toggle" href="#"
|
222
|
-
onclick="toggleCode('
|
223
|
-
<div class="method-source-code" id="
|
223
|
+
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
224
|
+
<div class="method-source-code" id="M000013-source">
|
224
225
|
<pre>
|
225
226
|
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 35</span>
|
226
227
|
35: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure_from_yaml</span>(<span class="ruby-identifier">path</span>)
|
@@ -238,11 +239,11 @@ Used to load configuration settings from a YAML file.
|
|
238
239
|
</div>
|
239
240
|
</div>
|
240
241
|
|
241
|
-
<div id="method-
|
242
|
-
<a name="
|
242
|
+
<div id="method-M000014" class="method-detail">
|
243
|
+
<a name="M000014"></a>
|
243
244
|
|
244
245
|
<div class="method-heading">
|
245
|
-
<a href="#
|
246
|
+
<a href="#M000014" class="method-signature">
|
246
247
|
<span class="method-name">reload</span><span class="method-args">()</span>
|
247
248
|
</a>
|
248
249
|
</div>
|
@@ -252,8 +253,8 @@ Used to load configuration settings from a YAML file.
|
|
252
253
|
Replays the history of configurations.
|
253
254
|
</p>
|
254
255
|
<p><a class="source-toggle" href="#"
|
255
|
-
onclick="toggleCode('
|
256
|
-
<div class="method-source-code" id="
|
256
|
+
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
257
|
+
<div class="method-source-code" id="M000014-source">
|
257
258
|
<pre>
|
258
259
|
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 47</span>
|
259
260
|
47: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reload</span>
|
@@ -267,11 +268,11 @@ Replays the history of configurations.
|
|
267
268
|
</div>
|
268
269
|
</div>
|
269
270
|
|
270
|
-
<div id="method-
|
271
|
-
<a name="
|
271
|
+
<div id="method-M000016" class="method-detail">
|
272
|
+
<a name="M000016"></a>
|
272
273
|
|
273
274
|
<div class="method-heading">
|
274
|
-
<a href="#
|
275
|
+
<a href="#M000016" class="method-signature">
|
275
276
|
<span class="method-name">reset</span><span class="method-args">()</span>
|
276
277
|
</a>
|
277
278
|
</div>
|
@@ -281,8 +282,8 @@ Replays the history of configurations.
|
|
281
282
|
All methods are undefined.
|
282
283
|
</p>
|
283
284
|
<p><a class="source-toggle" href="#"
|
284
|
-
onclick="toggleCode('
|
285
|
-
<div class="method-source-code" id="
|
285
|
+
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
|
286
|
+
<div class="method-source-code" id="M000016-source">
|
286
287
|
<pre>
|
287
288
|
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 64</span>
|
288
289
|
64: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset</span>
|
@@ -302,26 +303,26 @@ All methods are undefined.
|
|
302
303
|
</div>
|
303
304
|
</div>
|
304
305
|
|
305
|
-
<div id="method-
|
306
|
-
<a name="
|
306
|
+
<div id="method-M000015" class="method-detail">
|
307
|
+
<a name="M000015"></a>
|
307
308
|
|
308
309
|
<div class="method-heading">
|
309
|
-
<a href="#
|
310
|
+
<a href="#M000015" class="method-signature">
|
310
311
|
<span class="method-name">reset!</span><span class="method-args">()</span>
|
311
312
|
</a>
|
312
313
|
</div>
|
313
314
|
|
314
315
|
<div class="method-description">
|
315
316
|
<p>
|
316
|
-
Does a hard <a href="Configuration.html#
|
317
|
+
Does a hard <a href="Configuration.html#M000016">reset</a> of the <a
|
317
318
|
href="Configuration.html">Configatron::Configuration</a> class. All methods
|
318
319
|
are undefined, the list of configuration parameters is emptied, and the
|
319
|
-
nil_for_missing method gets <a href="Configuration.html#
|
320
|
+
nil_for_missing method gets <a href="Configuration.html#M000016">reset</a>
|
320
321
|
to false.
|
321
322
|
</p>
|
322
323
|
<p><a class="source-toggle" href="#"
|
323
|
-
onclick="toggleCode('
|
324
|
-
<div class="method-source-code" id="
|
324
|
+
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
325
|
+
<div class="method-source-code" id="M000015-source">
|
325
326
|
<pre>
|
326
327
|
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 57</span>
|
327
328
|
57: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset!</span>
|
@@ -334,11 +335,11 @@ to false.
|
|
334
335
|
</div>
|
335
336
|
</div>
|
336
337
|
|
337
|
-
<div id="method-
|
338
|
-
<a name="
|
338
|
+
<div id="method-M000017" class="method-detail">
|
339
|
+
<a name="M000017"></a>
|
339
340
|
|
340
341
|
<div class="method-heading">
|
341
|
-
<a href="#
|
342
|
+
<a href="#M000017" class="method-signature">
|
342
343
|
<span class="method-name">revert</span><span class="method-args">(step = 1)</span>
|
343
344
|
</a>
|
344
345
|
</div>
|
@@ -348,8 +349,8 @@ to false.
|
|
348
349
|
Peels back n number of configuration parameters.
|
349
350
|
</p>
|
350
351
|
<p><a class="source-toggle" href="#"
|
351
|
-
onclick="toggleCode('
|
352
|
-
<div class="method-source-code" id="
|
352
|
+
onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
|
353
|
+
<div class="method-source-code" id="M000017-source">
|
353
354
|
<pre>
|
354
355
|
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 78</span>
|
355
356
|
78: <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>)
|
@@ -362,6 +363,29 @@ Peels back n number of configuration parameters.
|
|
362
363
|
</div>
|
363
364
|
</div>
|
364
365
|
|
366
|
+
<div id="method-M000018" class="method-detail">
|
367
|
+
<a name="M000018"></a>
|
368
|
+
|
369
|
+
<div class="method-heading">
|
370
|
+
<a href="#M000018" class="method-signature">
|
371
|
+
<span class="method-name">to_hash</span><span class="method-args">()</span>
|
372
|
+
</a>
|
373
|
+
</div>
|
374
|
+
|
375
|
+
<div class="method-description">
|
376
|
+
<p><a class="source-toggle" href="#"
|
377
|
+
onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
|
378
|
+
<div class="method-source-code" id="M000018-source">
|
379
|
+
<pre>
|
380
|
+
<span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 88</span>
|
381
|
+
88: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_hash</span>
|
382
|
+
89: <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>) }
|
383
|
+
90: <span class="ruby-keyword kw">end</span>
|
384
|
+
</pre>
|
385
|
+
</div>
|
386
|
+
</div>
|
387
|
+
</div>
|
388
|
+
|
365
389
|
|
366
390
|
</div>
|
367
391
|
|
@@ -97,6 +97,7 @@ Used to store each of the ‘sets’ of configuration parameters.
|
|
97
97
|
<a href="#M000006">namespace</a>
|
98
98
|
<a href="#M000003">new</a>
|
99
99
|
<a href="#M000007">reload</a>
|
100
|
+
<a href="#M000008">to_hash</a>
|
100
101
|
</div>
|
101
102
|
</div>
|
102
103
|
|
@@ -301,6 +302,38 @@ etc…
|
|
301
302
|
</div>
|
302
303
|
</div>
|
303
304
|
|
305
|
+
<div id="method-M000008" class="method-detail">
|
306
|
+
<a name="M000008"></a>
|
307
|
+
|
308
|
+
<div class="method-heading">
|
309
|
+
<a href="#M000008" class="method-signature">
|
310
|
+
<span class="method-name">to_hash</span><span class="method-args">()</span>
|
311
|
+
</a>
|
312
|
+
</div>
|
313
|
+
|
314
|
+
<div class="method-description">
|
315
|
+
<p><a class="source-toggle" href="#"
|
316
|
+
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
317
|
+
<div class="method-source-code" id="M000008-source">
|
318
|
+
<pre>
|
319
|
+
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 60</span>
|
320
|
+
60: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_hash</span>
|
321
|
+
61: <span class="ruby-ivar">@parameters</span>.<span class="ruby-identifier">inject</span>({}) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">acc</span>, (<span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span>)<span class="ruby-operator">|</span>
|
322
|
+
62: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">v</span>
|
323
|
+
63: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Configatron</span><span class="ruby-operator">::</span><span class="ruby-constant">Store</span>
|
324
|
+
64: <span class="ruby-identifier">acc</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>.<span class="ruby-identifier">to_hash</span>
|
325
|
+
65: <span class="ruby-keyword kw">else</span>
|
326
|
+
66: <span class="ruby-identifier">acc</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
|
327
|
+
67: <span class="ruby-keyword kw">end</span>
|
328
|
+
68:
|
329
|
+
69: <span class="ruby-identifier">acc</span>
|
330
|
+
70: <span class="ruby-keyword kw">end</span>
|
331
|
+
71: <span class="ruby-keyword kw">end</span>
|
332
|
+
</pre>
|
333
|
+
</div>
|
334
|
+
</div>
|
335
|
+
</div>
|
336
|
+
|
304
337
|
|
305
338
|
</div>
|
306
339
|
|
@@ -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="#M000009">new</a>
|
99
|
+
<a href="#M000010">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-M000009" class="method-detail">
|
135
|
+
<a name="M000009"></a>
|
136
136
|
|
137
137
|
<div class="method-heading">
|
138
|
-
<a href="#
|
138
|
+
<a href="#M000009" 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('M000009-source');return false;">[Source]</a></p>
|
149
|
+
<div class="method-source-code" id="M000009-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-M000010" class="method-detail">
|
164
|
+
<a name="M000010"></a>
|
165
165
|
|
166
166
|
<div class="method-heading">
|
167
|
-
<a href="#
|
167
|
+
<a href="#M000010" 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('M000010-source');return false;">[Source]</a></p>
|
178
|
+
<div class="method-source-code" id="M000010-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>
|
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="#M000019">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-M000019" class="method-detail">
|
106
|
+
<a name="M000019"></a>
|
107
107
|
|
108
108
|
<div class="method-heading">
|
109
|
-
<a href="#
|
109
|
+
<a href="#M000019" 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('M000019-source');return false;">[Source]</a></p>
|
124
|
+
<div class="method-source-code" id="M000019-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
|
+
Wed, 10 Sep 2008 16:12:28 -0400
|
data/doc/files/README.html
CHANGED
data/doc/fr_method_index.html
CHANGED
@@ -20,23 +20,25 @@
|
|
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#
|
23
|
+
<a href="classes/Kernel.html#M000019">configatron (Kernel)</a><br />
|
24
|
+
<a href="classes/Configatron/Configuration.html#M000011">configure (Configatron::Configuration)</a><br />
|
25
|
+
<a href="classes/Configatron/Configuration.html#M000012">configure_from_hash (Configatron::Configuration)</a><br />
|
26
|
+
<a href="classes/Configatron/Configuration.html#M000013">configure_from_yaml (Configatron::Configuration)</a><br />
|
27
27
|
<a href="classes/Configatron/Store.html#M000005">exists? (Configatron::Store)</a><br />
|
28
28
|
<a href="classes/Configatron/Helpers.html#M000001">exists? (Configatron::Helpers)</a><br />
|
29
29
|
<a href="classes/Configatron/Store.html#M000004">method_missing (Configatron::Store)</a><br />
|
30
30
|
<a href="classes/Configatron/Store.html#M000006">namespace (Configatron::Store)</a><br />
|
31
|
-
<a href="classes/Configatron/YamlStore.html#
|
31
|
+
<a href="classes/Configatron/YamlStore.html#M000009">new (Configatron::YamlStore)</a><br />
|
32
32
|
<a href="classes/Configatron/Store.html#M000003">new (Configatron::Store)</a><br />
|
33
|
+
<a href="classes/Configatron/Configuration.html#M000014">reload (Configatron::Configuration)</a><br />
|
33
34
|
<a href="classes/Configatron/Store.html#M000007">reload (Configatron::Store)</a><br />
|
34
|
-
<a href="classes/Configatron/
|
35
|
-
<a href="classes/Configatron/
|
36
|
-
<a href="classes/Configatron/Configuration.html#M000015">reset (Configatron::Configuration)</a><br />
|
37
|
-
<a href="classes/Configatron/Configuration.html#M000014">reset! (Configatron::Configuration)</a><br />
|
35
|
+
<a href="classes/Configatron/YamlStore.html#M000010">reload (Configatron::YamlStore)</a><br />
|
36
|
+
<a href="classes/Configatron/Configuration.html#M000016">reset (Configatron::Configuration)</a><br />
|
37
|
+
<a href="classes/Configatron/Configuration.html#M000015">reset! (Configatron::Configuration)</a><br />
|
38
38
|
<a href="classes/Configatron/Helpers.html#M000002">retrieve (Configatron::Helpers)</a><br />
|
39
|
-
<a href="classes/Configatron/Configuration.html#
|
39
|
+
<a href="classes/Configatron/Configuration.html#M000017">revert (Configatron::Configuration)</a><br />
|
40
|
+
<a href="classes/Configatron/Configuration.html#M000018">to_hash (Configatron::Configuration)</a><br />
|
41
|
+
<a href="classes/Configatron/Store.html#M000008">to_hash (Configatron::Store)</a><br />
|
40
42
|
</div>
|
41
43
|
</div>
|
42
44
|
</body>
|
data/lib/configatron/store.rb
CHANGED
@@ -56,6 +56,19 @@ module Configatron
|
|
56
56
|
# may need to read a file in, etc...
|
57
57
|
def reload
|
58
58
|
end
|
59
|
+
|
60
|
+
def to_hash
|
61
|
+
@parameters.inject({}) do |acc, (k,v)|
|
62
|
+
case v
|
63
|
+
when Configatron::Store
|
64
|
+
acc[k] = v.to_hash
|
65
|
+
else
|
66
|
+
acc[k] = v
|
67
|
+
end
|
68
|
+
|
69
|
+
acc
|
70
|
+
end
|
71
|
+
end
|
59
72
|
|
60
73
|
end # Store
|
61
74
|
end # Configatron
|
@@ -259,4 +259,24 @@ cartoon:
|
|
259
259
|
|
260
260
|
end
|
261
261
|
|
262
|
+
describe 'to_hash' do
|
263
|
+
it "should convert entire configuration to a hash" do
|
264
|
+
hash = {:foo => 'bar', :baz => {:quux => 'foobar'}}
|
265
|
+
|
266
|
+
configatron.configure_from_hash(hash)
|
267
|
+
|
268
|
+
configatron.to_hash.should == hash
|
269
|
+
end
|
270
|
+
|
271
|
+
it 'should convert the configration with multiple calls to configure' do
|
272
|
+
hash1 = {:foo => 'bar', :baz => {:quux => 'foobar'}}
|
273
|
+
hash2 = {:foo => 'notbar', :beep => 'boop'}
|
274
|
+
|
275
|
+
configatron.configure_from_hash(hash1)
|
276
|
+
configatron.configure_from_hash(hash2)
|
277
|
+
|
278
|
+
configatron.to_hash.should == hash1.merge(hash2)
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
262
282
|
end
|
data/spec/unit/store_spec.rb
CHANGED
@@ -62,7 +62,30 @@ describe Configatron::Store do
|
|
62
62
|
configatron.foo.bar.should == :bar
|
63
63
|
configatron.foo.name.should == "mark bates"
|
64
64
|
end
|
65
|
-
|
66
65
|
end
|
67
66
|
|
67
|
+
describe 'to_hash' do
|
68
|
+
it "should convert the store to a hash" do
|
69
|
+
configatron do |config|
|
70
|
+
config.namespace :baz do |baz|
|
71
|
+
baz.foo = 'bar'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
configatron.baz.to_hash.should == {:foo => 'bar'}
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should support multiple nesting levels in the store' do
|
79
|
+
configatron do |config|
|
80
|
+
config.namespace :baz do |baz|
|
81
|
+
baz.foo = 'bar'
|
82
|
+
baz.namespace :quux do |quux|
|
83
|
+
quux.foob = 'barbaz'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
configatron.baz.to_hash.should == {:foo => 'bar', :quux => {:foob => 'barbaz'}}
|
89
|
+
end
|
90
|
+
end
|
68
91
|
end
|
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.1
|
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-10 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|