configatron 2.2.2 → 2.3.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.
@@ -1,144 +0,0 @@
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>Module: Kernel</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>Module</strong></td>
53
- <td class="class-name-in-header">Kernel</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../files/lib/configatron/core_ext/kernel_rb.html">
59
- lib/configatron/core_ext/kernel.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- </table>
66
- </div>
67
- <!-- banner header -->
68
-
69
- <div id="bodyContent">
70
-
71
-
72
-
73
- <div id="contextContent">
74
-
75
-
76
-
77
- </div>
78
-
79
- <div id="method-list">
80
- <h3 class="section-bar">Methods</h3>
81
-
82
- <div class="name-list">
83
- <a href="#M000027">configatron</a>&nbsp;&nbsp;
84
- </div>
85
- </div>
86
-
87
- </div>
88
-
89
-
90
- <!-- if includes -->
91
-
92
- <div id="section">
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
- <!-- if method_list -->
102
- <div id="methods">
103
- <h3 class="section-bar">Public Instance methods</h3>
104
-
105
- <div id="method-M000027" class="method-detail">
106
- <a name="M000027"></a>
107
-
108
- <div class="method-heading">
109
- <a href="#M000027" class="method-signature">
110
- <span class="method-name">configatron</span><span class="method-args">()</span>
111
- </a>
112
- </div>
113
-
114
- <div class="method-description">
115
- <p>
116
- Provides access to the <a href="Configatron.html">Configatron</a> storage
117
- system.
118
- </p>
119
- <p><a class="source-toggle" href="#"
120
- onclick="toggleCode('M000027-source');return false;">[Source]</a></p>
121
- <div class="method-source-code" id="M000027-source">
122
- <pre>
123
- <span class="ruby-comment cmt"># File lib/configatron/core_ext/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>
127
- </pre>
128
- </div>
129
- </div>
130
- </div>
131
-
132
-
133
- </div>
134
-
135
-
136
- </div>
137
-
138
-
139
- <div id="validator-badges">
140
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
141
- </div>
142
-
143
- </body>
144
- </html>
data/doc/created.rid DELETED
@@ -1 +0,0 @@
1
- Fri, 16 Jan 2009 17:33:11 -0500
@@ -1,309 +0,0 @@
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>File: README</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="fileHeader">
50
- <h1>README</h1>
51
- <table class="header-table">
52
- <tr class="top-aligned-row">
53
- <td><strong>Path:</strong></td>
54
- <td>README
55
- </td>
56
- </tr>
57
- <tr class="top-aligned-row">
58
- <td><strong>Last Update:</strong></td>
59
- <td>Wed Sep 17 14:47:44 -0400 2008</td>
60
- </tr>
61
- </table>
62
- </div>
63
- <!-- banner header -->
64
-
65
- <div id="bodyContent">
66
-
67
-
68
-
69
- <div id="contextContent">
70
-
71
- <div id="description">
72
- <h1><a href="../classes/Configatron.html">Configatron</a></h1>
73
- <p>
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&#8216;s all Ruby, you can do
78
- any crazy thing you would like to!
79
- </p>
80
- <h2>Examples</h2>
81
- <h3>Simple</h3>
82
- <pre>
83
- configatron.email = 'me@example.com'
84
- configatron.database_url = &quot;postgres://localhost/mack_framework_rocks&quot;
85
- </pre>
86
- <p>
87
- Now, anywhere in your code you can do the following:
88
- </p>
89
- <pre>
90
- configatron.email # =&gt; &quot;me@example.com&quot;
91
- configatron.database_url # =&gt; &quot;postgres://localhost/mack_framework_rocks&quot;
92
- </pre>
93
- <p>
94
- Viola! Simple as can be.
95
- </p>
96
- <p>
97
- Now you&#8216;re saying, what if I want to have a &#8216;default&#8217; set
98
- of options, but then override them later, based on other information?
99
- Simple again. Let&#8216;s use our above example. We&#8216;ve configured our
100
- &#8216;database_url&#8217; option to be
101
- &quot;postgres://localhost/mack_framework_rocks&quot;. The problem with
102
- that is that is our production database url, not our development url. Fair
103
- enough, all you have to do is redeclare it:
104
- </p>
105
- <pre>
106
- configatron.database_url = &quot;postgres://localhost/mack_framework_rocks_development&quot;
107
- </pre>
108
- <p>
109
- becomes:
110
- </p>
111
- <pre>
112
- configatron.email # =&gt; &quot;me@example.com&quot;
113
- configatron.database_url # =&gt; &quot;postgres://localhost/mack_framework_rocks_development&quot;
114
- </pre>
115
- <p>
116
- Notice how our other configuration parameters haven&#8216;t changed? Cool,
117
- eh?
118
- </p>
119
- <h3>Hash/YAML</h3>
120
- <p>
121
- You can configure configatron from a hash as well:
122
- </p>
123
- <pre>
124
- configatron.configure_from_hash({:email =&gt; {:pop =&gt; {:address =&gt; 'pop.example.com', :port =&gt; 110}}, :smtp =&gt; {:address =&gt; 'smtp.example.com'}})
125
-
126
- configatron.email.pop.address # =&gt; 'pop.example.com'
127
- configatron.email.pop.port # =&gt; 110
128
- # and so on...
129
- </pre>
130
- <p>
131
- Notice how they&#8216;re all namespaced for your as well. The same holds
132
- true for YAML files:
133
- </p>
134
- <pre>
135
- configuration.configure_from_yaml('/path/to/file.yml')
136
- </pre>
137
- <p>
138
- When the &#8216;reload&#8217; method is called on configatron then the YAML
139
- file will be re-read in case changes have been made.
140
- </p>
141
- <h3>Namespaces</h3>
142
- <p>
143
- The question that should be on your lips is what I need to have namespaced
144
- configuration parameters. It&#8216;s easy! <a
145
- href="../classes/Configatron.html">Configatron</a> allows you to create
146
- namespaces.
147
- </p>
148
- <pre>
149
- configatron.website_url = &quot;http://www.mackframework.com&quot;
150
- configatron.email.pop.address = &quot;pop.example.com&quot;
151
- configatron.email.pop.port = 110
152
- configatron.email.smtp.address = &quot;smtp.example.com&quot;
153
- configatron.email.smtp.port = 25
154
- </pre>
155
- <p>
156
- becomes:
157
- </p>
158
- <pre>
159
- configatron.email.pop.address # =&gt; &quot;pop.example.com&quot;
160
- configatron.email.smtp.address # =&gt; &quot;smtp.example.com&quot;
161
- configatron.website_url # =&gt; &quot;http://www.mackframework.com&quot;
162
- </pre>
163
- <p>
164
- <a href="../classes/Configatron.html">Configatron</a> allows you to nest
165
- namespaces to your hearts content! Just keep going, it&#8216;s that easy.
166
- </p>
167
- <p>
168
- Of course you can update a single parameter n levels deep as well:
169
- </p>
170
- <pre>
171
- configatron.email.pop.address = &quot;pop2.example.com&quot;
172
-
173
- configatron.email.pop.address # =&gt; &quot;pop2.example.com&quot;
174
- configatron.email.smtp.address # =&gt; &quot;smtp.example.com&quot;
175
- </pre>
176
- <h3>Misc.</h3>
177
- <p>
178
- Even if parameters haven&#8216;t been set, you can still call them, and
179
- you&#8216;ll get nil back:
180
- </p>
181
- <pre>
182
- configatron.i.dont.exist.nil? # =&gt; true
183
- configatron.i.dont.exist # =&gt; nil
184
- </pre>
185
- <p>
186
- You can set &#8216;default&#8217; values for parameters. If there is
187
- already a setting, it won&#8216;t be replaced. This is useful if
188
- you&#8216;ve already done your &#8216;configuration&#8217; and you call a
189
- library, that needs to have parameters set. The library can set it&#8216;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 # =&gt; 'Mark Bates'
196
- configatron.set_default(:name, 'Me')
197
- configatron.name # =&gt; '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 # =&gt; 1
211
- configatron.letters.a # =&gt; 'A'
212
- configatron.letters.b # =&gt; 'bb'
213
- configatron.letters.c # =&gt; 'c'
214
- end
215
- configatron.one # =&gt; 1
216
- configatron.letters.a # =&gt; 'A'
217
- configatron.letters.b # =&gt; 'B'
218
- configatron.letters.c # =&gt; 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 =&gt; {:b =&gt; 'bb', :c =&gt; 'c'}) do
228
- configatron.one == 1
229
- configatron.letters.a # =&gt; 'A'
230
- configatron.letters.b # =&gt; 'bb'
231
- configatron.letters.c # =&gt; 'c'
232
- end
233
- configatron.one == 1
234
- configatron.letters.a # =&gt; 'A'
235
- configatron.letters.b # =&gt; 'B'
236
- configatron.letters.c # =&gt; nil
237
- </pre>
238
- <p>
239
- Enjoy!
240
- </p>
241
- <h2>Contact</h2>
242
- <p>
243
- Please mail bugs, suggestions and patches to
244
- &lt;bugs@mackframework.com&gt;.
245
- </p>
246
- <p>
247
- On the web at: <a
248
- href="http://www.mackframework.com">www.mackframework.com</a>
249
- </p>
250
- <h2>License and Copyright</h2>
251
- <p>
252
- Copyright (C) 2008 Mark Bates, <a
253
- href="http://www.mackframework.com">www.mackframework.com</a>
254
- </p>
255
- <p>
256
- Permission is hereby granted, free of charge, to any person obtaining a
257
- copy of this software and associated documentation files (the
258
- &quot;Software&quot;), to deal in the Software without restriction,
259
- including without limitation the rights to use, copy, modify, merge,
260
- publish, distribute, sublicense, and/or sell copies of the Software, and to
261
- permit persons to whom the Software is furnished to do so, subject to the
262
- following conditions:
263
- </p>
264
- <p>
265
- The above copyright notice and this permission notice shall be included in
266
- all copies or substantial portions of the Software.
267
- </p>
268
- <p>
269
- THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,
270
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
271
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
272
- NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
273
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
274
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
275
- DEALINGS IN THE SOFTWARE.
276
- </p>
277
-
278
- </div>
279
-
280
-
281
- </div>
282
-
283
-
284
- </div>
285
-
286
-
287
- <!-- if includes -->
288
-
289
- <div id="section">
290
-
291
-
292
-
293
-
294
-
295
-
296
-
297
-
298
- <!-- if method_list -->
299
-
300
-
301
- </div>
302
-
303
-
304
- <div id="validator-badges">
305
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
306
- </div>
307
-
308
- </body>
309
- </html>