configatron 2.3.2 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/LICENSE +21 -0
  2. data/README +16 -12
  3. data/generators/configatron_generator.rb +20 -0
  4. data/generators/templates/configatron/cucumber.rb +4 -0
  5. data/generators/templates/configatron/defaults.rb +7 -0
  6. data/generators/templates/configatron/development.rb +4 -0
  7. data/generators/templates/configatron/production.rb +4 -0
  8. data/generators/templates/configatron/test.rb +4 -0
  9. data/generators/templates/initializers/configatron.rb +2 -0
  10. data/lib/configatron/configatron.rb +7 -3
  11. data/lib/configatron/rails.rb +44 -0
  12. data/lib/configatron/store.rb +5 -1
  13. data/lib/configatron.rb +2 -1
  14. metadata +19 -28
  15. data/doc/classes/Class.html +0 -169
  16. data/doc/classes/Configatron/LockedNamespace.html +0 -146
  17. data/doc/classes/Configatron/ProtectedParameter.html +0 -146
  18. data/doc/classes/Configatron/Store.html +0 -830
  19. data/doc/classes/Configatron.html +0 -303
  20. data/doc/classes/Kernel.html +0 -144
  21. data/doc/created.rid +0 -1
  22. data/doc/files/README.html +0 -320
  23. data/doc/files/lib/configatron/configatron_rb.html +0 -108
  24. data/doc/files/lib/configatron/core_ext/class_rb.html +0 -101
  25. data/doc/files/lib/configatron/core_ext/kernel_rb.html +0 -101
  26. data/doc/files/lib/configatron/core_ext/object_rb.html +0 -101
  27. data/doc/files/lib/configatron/core_ext/string_rb.html +0 -101
  28. data/doc/files/lib/configatron/errors_rb.html +0 -101
  29. data/doc/files/lib/configatron/store_rb.html +0 -101
  30. data/doc/files/lib/configatron_rb.html +0 -108
  31. data/doc/fr_class_index.html +0 -32
  32. data/doc/fr_file_index.html +0 -35
  33. data/doc/fr_method_index.html +0 -56
  34. data/doc/index.html +0 -24
  35. data/doc/rdoc-style.css +0 -208
@@ -1,320 +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 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>
@@ -1,108 +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: configatron.rb</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>configatron.rb</h1>
51
- <table class="header-table">
52
- <tr class="top-aligned-row">
53
- <td><strong>Path:</strong></td>
54
- <td>lib/configatron/configatron.rb
55
- </td>
56
- </tr>
57
- <tr class="top-aligned-row">
58
- <td><strong>Last Update:</strong></td>
59
- <td>Wed Apr 22 13:59:20 -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
-
72
- <div id="requires-list">
73
- <h3 class="section-bar">Required files</h3>
74
-
75
- <div class="name-list">
76
- singleton&nbsp;&nbsp;
77
- </div>
78
- </div>
79
-
80
- </div>
81
-
82
-
83
- </div>
84
-
85
-
86
- <!-- if includes -->
87
-
88
- <div id="section">
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
- <!-- if method_list -->
98
-
99
-
100
- </div>
101
-
102
-
103
- <div id="validator-badges">
104
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
105
- </div>
106
-
107
- </body>
108
- </html>
@@ -1,101 +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: class.rb</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>class.rb</h1>
51
- <table class="header-table">
52
- <tr class="top-aligned-row">
53
- <td><strong>Path:</strong></td>
54
- <td>lib/configatron/core_ext/class.rb
55
- </td>
56
- </tr>
57
- <tr class="top-aligned-row">
58
- <td><strong>Last Update:</strong></td>
59
- <td>Wed Apr 22 15:47:35 -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
-
72
-
73
- </div>
74
-
75
-
76
- </div>
77
-
78
-
79
- <!-- if includes -->
80
-
81
- <div id="section">
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
- <!-- if method_list -->
91
-
92
-
93
- </div>
94
-
95
-
96
- <div id="validator-badges">
97
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
98
- </div>
99
-
100
- </body>
101
- </html>
@@ -1,101 +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: kernel.rb</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>kernel.rb</h1>
51
- <table class="header-table">
52
- <tr class="top-aligned-row">
53
- <td><strong>Path:</strong></td>
54
- <td>lib/configatron/core_ext/kernel.rb
55
- </td>
56
- </tr>
57
- <tr class="top-aligned-row">
58
- <td><strong>Last Update:</strong></td>
59
- <td>Wed Apr 22 13:59:20 -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
-
72
-
73
- </div>
74
-
75
-
76
- </div>
77
-
78
-
79
- <!-- if includes -->
80
-
81
- <div id="section">
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
- <!-- if method_list -->
91
-
92
-
93
- </div>
94
-
95
-
96
- <div id="validator-badges">
97
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
98
- </div>
99
-
100
- </body>
101
- </html>