configatron 2.3.1 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,144 @@
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="#M000030">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-M000030" class="method-detail">
106
+ <a name="M000030"></a>
107
+
108
+ <div class="method-heading">
109
+ <a href="#M000030" 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('M000030-source');return false;">[Source]</a></p>
121
+ <div class="method-source-code" id="M000030-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 ADDED
@@ -0,0 +1 @@
1
+ Wed, 20 May 2009 13:54:31 -0400
@@ -0,0 +1,320 @@
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 May 20 13:54:31 -0400 2009</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
+ <tt>database_url</tt> option to be
101
+ <tt>postgres://localhost/mack_framework_rocks</tt>. The problem with that
102
+ 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
+ <h3>Namespaces</h3>
138
+ <p>
139
+ The question that should be on your lips is what I need to have namespaced
140
+ configuration parameters. It&#8216;s easy! <a
141
+ href="../classes/Configatron.html">Configatron</a> allows you to create
142
+ namespaces.
143
+ </p>
144
+ <pre>
145
+ configatron.website_url = &quot;http://www.mackframework.com&quot;
146
+ configatron.email.pop.address = &quot;pop.example.com&quot;
147
+ configatron.email.pop.port = 110
148
+ configatron.email.smtp.address = &quot;smtp.example.com&quot;
149
+ configatron.email.smtp.port = 25
150
+ </pre>
151
+ <p>
152
+ becomes:
153
+ </p>
154
+ <pre>
155
+ configatron.email.pop.address # =&gt; &quot;pop.example.com&quot;
156
+ configatron.email.smtp.address # =&gt; &quot;smtp.example.com&quot;
157
+ configatron.website_url # =&gt; &quot;http://www.mackframework.com&quot;
158
+ </pre>
159
+ <p>
160
+ <a href="../classes/Configatron.html">Configatron</a> allows you to nest
161
+ namespaces to your hearts content! Just keep going, it&#8216;s that easy.
162
+ </p>
163
+ <p>
164
+ Of course you can update a single parameter n levels deep as well:
165
+ </p>
166
+ <pre>
167
+ configatron.email.pop.address = &quot;pop2.example.com&quot;
168
+
169
+ configatron.email.pop.address # =&gt; &quot;pop2.example.com&quot;
170
+ configatron.email.smtp.address # =&gt; &quot;smtp.example.com&quot;
171
+ </pre>
172
+ <h3>Misc.</h3>
173
+ <p>
174
+ Even if parameters haven&#8216;t been set, you can still call them, but
175
+ you&#8216;ll get a <tt><a
176
+ href="../classes/Configatron/Store.html">Configatron::Store</a></tt> object
177
+ back. The <a
178
+ href="../classes/Configatron/Store.html">Configatron::Store</a> class,
179
+ however, will respond true to <tt>.nil?</tt> if there are no parameters
180
+ configured on it.
181
+ </p>
182
+ <pre>
183
+ configatron.i.dont.exist.nil? # =&gt; true
184
+ configatron.i.dont.exist # =&gt; Configatron::Store
185
+ </pre>
186
+ <p>
187
+ If you want to get back an actual <tt>nil</tt> then you can use the
188
+ <tt>retrieve</tt> method:
189
+ </p>
190
+ <pre>
191
+ configatron.i.do.exist = [:some, :array]
192
+ configatron.i.dont.retrieve(:exist, nil) # =&gt; nil
193
+ configatron.i.do.retrieve(:exist, :foo) # =&gt; [:some, :array]
194
+ </pre>
195
+ <p>
196
+ You can set &#8216;default&#8217; values for parameters. If there is
197
+ already a setting, it won&#8216;t be replaced. This is useful if
198
+ you&#8216;ve already done your &#8216;configuration&#8217; and you call a
199
+ library, that needs to have parameters set. The library can set its
200
+ defaults, without worrying that it might have overridden your custom
201
+ settings.
202
+ </p>
203
+ <pre>
204
+ configatron.set_default(:name, 'Mark Bates')
205
+ configatron.name # =&gt; 'Mark Bates'
206
+ configatron.set_default(:name, 'Me')
207
+ configatron.name # =&gt; 'Mark Bates'
208
+ </pre>
209
+ <p>
210
+ Sometimes in testing, or other situations, you want to temporarily change
211
+ some settings. You can do this with the <tt>temp</tt> method:
212
+ </p>
213
+ <pre>
214
+ configatron.one = 1
215
+ configatron.letters.a = 'A'
216
+ configatron.letters.b = 'B'
217
+ configatron.temp do
218
+ configatron.letters.b = 'bb'
219
+ configatron.letters.c = 'c'
220
+ configatron.one # =&gt; 1
221
+ configatron.letters.a # =&gt; 'A'
222
+ configatron.letters.b # =&gt; 'bb'
223
+ configatron.letters.c # =&gt; 'c'
224
+ end
225
+ configatron.one # =&gt; 1
226
+ configatron.letters.a # =&gt; 'A'
227
+ configatron.letters.b # =&gt; 'B'
228
+ configatron.letters.c # =&gt; nil
229
+ </pre>
230
+ <p>
231
+ You can also pass in an optional Hash to the <tt>temp</tt>:
232
+ </p>
233
+ <pre>
234
+ configatron.one = 1
235
+ configatron.letters.a = 'A'
236
+ configatron.letters.b = 'B'
237
+ configatron.temp(:letters =&gt; {:b =&gt; 'bb', :c =&gt; 'c'}) do
238
+ configatron.one == 1
239
+ configatron.letters.a # =&gt; 'A'
240
+ configatron.letters.b # =&gt; 'bb'
241
+ configatron.letters.c # =&gt; 'c'
242
+ end
243
+ configatron.one == 1
244
+ configatron.letters.a # =&gt; 'A'
245
+ configatron.letters.b # =&gt; 'B'
246
+ configatron.letters.c # =&gt; nil
247
+ </pre>
248
+ <p>
249
+ Enjoy!
250
+ </p>
251
+ <h2>Contact</h2>
252
+ <p>
253
+ Please mail bugs, suggestions and patches to
254
+ &quot;bugs@mackframework.com&quot;:<a
255
+ href="mailto:bugs@mackframework.com">bugs@mackframework.com</a>
256
+ </p>
257
+ <p>
258
+ On the web at: &quot;<a
259
+ href="http://www.mackframework.com":http://www.mackframework.com">www.mackframework.com":http://www.mackframework.com</a>
260
+ </p>
261
+ <h2>License and Copyright</h2>
262
+ <p>
263
+ Copyright (C) 2008 Mark Bates, &quot;<a
264
+ href="http://www.mackframework.com":http://www.mackframework.com">www.mackframework.com":http://www.mackframework.com</a>
265
+ </p>
266
+ <p>
267
+ Permission is hereby granted, free of charge, to any person obtaining a
268
+ copy of this software and associated documentation files (the
269
+ &quot;Software&quot;), to deal in the Software without restriction,
270
+ including without limitation the rights to use, copy, modify, merge,
271
+ publish, distribute, sublicense, and/or sell copies of the Software, and to
272
+ permit persons to whom the Software is furnished to do so, subject to the
273
+ following conditions:
274
+ </p>
275
+ <p>
276
+ The above copyright notice and this permission notice shall be included in
277
+ all copies or substantial portions of the Software.
278
+ </p>
279
+ <p>
280
+ THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,
281
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
282
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
283
+ NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
284
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
285
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
286
+ DEALINGS IN THE SOFTWARE.
287
+ </p>
288
+
289
+ </div>
290
+
291
+
292
+ </div>
293
+
294
+
295
+ </div>
296
+
297
+
298
+ <!-- if includes -->
299
+
300
+ <div id="section">
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+ <!-- if method_list -->
310
+
311
+
312
+ </div>
313
+
314
+
315
+ <div id="validator-badges">
316
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
317
+ </div>
318
+
319
+ </body>
320
+ </html>