rconfig 0.4.2 → 0.4.3

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.
Files changed (90) hide show
  1. data/ChangeLog +7 -0
  2. data/Gemfile +1 -0
  3. data/Gemfile.lock +2 -0
  4. data/Rakefile +11 -8
  5. data/doc/Array.html +184 -0
  6. data/doc/Hash.html +360 -0
  7. data/doc/NilClass.html +233 -0
  8. data/doc/RConfig.html +328 -0
  9. data/doc/RConfig/Callbacks.html +295 -0
  10. data/doc/RConfig/Cascade.html +316 -0
  11. data/doc/RConfig/Config.html +441 -0
  12. data/doc/RConfig/ConfigError.html +187 -0
  13. data/doc/RConfig/Constants.html +271 -0
  14. data/doc/RConfig/CoreMethods.html +814 -0
  15. data/doc/RConfig/DisabledLogger.html +424 -0
  16. data/doc/RConfig/Exceptions.html +266 -0
  17. data/doc/RConfig/Generators.html +186 -0
  18. data/doc/RConfig/Generators/InstallGenerator.html +233 -0
  19. data/doc/RConfig/InvalidLoadPathError.html +187 -0
  20. data/doc/RConfig/LoadPaths.html +375 -0
  21. data/doc/RConfig/Logger.html +184 -0
  22. data/doc/RConfig/PropertiesFile.html +399 -0
  23. data/doc/RConfig/Reload.html +481 -0
  24. data/doc/RConfig/Settings.html +188 -0
  25. data/doc/RConfig/Utils.html +841 -0
  26. data/doc/README_rdoc.html +331 -0
  27. data/doc/String.html +184 -0
  28. data/doc/created.rid +21 -1
  29. data/doc/index.html +423 -20
  30. data/doc/lib/generators/rconfig/install_generator_rb.html +52 -0
  31. data/doc/lib/generators/rconfig/templates/rconfig_rb.html +56 -0
  32. data/doc/lib/rconfig/callbacks_rb.html +52 -0
  33. data/doc/lib/rconfig/cascade_rb.html +52 -0
  34. data/doc/lib/rconfig/config_rb.html +61 -0
  35. data/doc/lib/rconfig/constants_rb.html +52 -0
  36. data/doc/lib/rconfig/core_ext/array_rb.html +52 -0
  37. data/doc/lib/rconfig/core_ext/hash_rb.html +61 -0
  38. data/doc/lib/rconfig/core_ext/nil_rb.html +52 -0
  39. data/doc/lib/rconfig/core_ext/string_rb.html +52 -0
  40. data/doc/lib/rconfig/core_methods_rb.html +55 -0
  41. data/doc/lib/rconfig/exceptions_rb.html +58 -0
  42. data/doc/lib/rconfig/load_paths_rb.html +52 -0
  43. data/doc/lib/rconfig/logger_rb.html +52 -0
  44. data/doc/lib/rconfig/properties_file_rb.html +93 -0
  45. data/doc/lib/rconfig/reload_rb.html +52 -0
  46. data/doc/lib/rconfig/settings_rb.html +52 -0
  47. data/doc/lib/rconfig/utils_rb.html +52 -0
  48. data/doc/lib/rconfig_rb.html +151 -0
  49. data/doc/rdoc.css +706 -0
  50. data/lib/rconfig.rb +1 -1
  51. data/lib/rconfig/load_paths.rb +2 -2
  52. data/lib/tasks/rdoc.rake +3 -4
  53. data/rconfig.gemspec +4 -2
  54. data/spec/config/erb_contents.yml +3 -0
  55. data/spec/config/props_config.conf +18 -0
  56. data/spec/config/spec.yml +17 -0
  57. data/spec/config/xml_config.xml +22 -0
  58. data/spec/config2/.gitkeep +0 -0
  59. data/spec/rconfig/load_paths_spec.rb +37 -0
  60. data/spec/rconfig/reload_spec.rb +37 -0
  61. data/spec/rconfig_spec.rb +61 -3
  62. data/spec/spec_helper.rb +12 -8
  63. metadata +82 -40
  64. data/doc/classes/ClassVariables.html +0 -111
  65. data/doc/classes/ConfigError.html +0 -120
  66. data/doc/classes/ConfigHash.html +0 -354
  67. data/doc/classes/Constants.html +0 -226
  68. data/doc/classes/Hash.html +0 -269
  69. data/doc/classes/InvalidConfigPathError.html +0 -119
  70. data/doc/classes/Object.html +0 -220
  71. data/doc/classes/PropertiesFileParser.html +0 -282
  72. data/doc/classes/RConfig.html +0 -1745
  73. data/doc/files/README_rdoc.html +0 -271
  74. data/doc/files/lib/rconfig/class_variables_rb.html +0 -107
  75. data/doc/files/lib/rconfig/config_hash_rb.html +0 -114
  76. data/doc/files/lib/rconfig/constants_rb.html +0 -101
  77. data/doc/files/lib/rconfig/core_ext/hash_rb.html +0 -114
  78. data/doc/files/lib/rconfig/core_ext/object_rb.html +0 -101
  79. data/doc/files/lib/rconfig/core_ext_rb.html +0 -114
  80. data/doc/files/lib/rconfig/exceptions_rb.html +0 -110
  81. data/doc/files/lib/rconfig/properties_file_parser_rb.html +0 -146
  82. data/doc/files/lib/rconfig/rconfig_rb.html +0 -186
  83. data/doc/files/lib/rconfig_rb.html +0 -117
  84. data/doc/fr_class_index.html +0 -35
  85. data/doc/fr_file_index.html +0 -37
  86. data/doc/fr_method_index.html +0 -75
  87. data/doc/rdoc-style.css +0 -208
  88. data/lib/tasks/gem.rake +0 -14
  89. data/lib/tasks/spec.rake +0 -25
  90. data/spec/core_ext/object_spec.rb +0 -44
@@ -0,0 +1,271 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7
+
8
+ <title>Module: RConfig::Constants</title>
9
+
10
+ <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
11
+
12
+ <script src="../js/jquery.js" type="text/javascript"
13
+ charset="utf-8"></script>
14
+ <script src="../js/thickbox-compressed.js" type="text/javascript"
15
+ charset="utf-8"></script>
16
+ <script src="../js/quicksearch.js" type="text/javascript"
17
+ charset="utf-8"></script>
18
+ <script src="../js/darkfish.js" type="text/javascript"
19
+ charset="utf-8"></script>
20
+
21
+ </head>
22
+ <body class="module">
23
+
24
+ <div id="metadata">
25
+ <div id="home-metadata">
26
+ <div id="home-section" class="section">
27
+ <h3 class="section-header">
28
+ <a href="../index.html">Home</a>
29
+ <a href="../index.html#classes">Classes</a>
30
+ <a href="../index.html#methods">Methods</a>
31
+ </h3>
32
+ </div>
33
+ </div>
34
+
35
+ <div id="file-metadata">
36
+ <div id="file-list-section" class="section">
37
+ <h3 class="section-header">In Files</h3>
38
+ <div class="section-body">
39
+ <ul>
40
+
41
+ <li><a href="../lib/rconfig/constants_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
42
+ class="thickbox" title="lib/rconfig/constants.rb">lib/rconfig/constants.rb</a></li>
43
+
44
+ </ul>
45
+ </div>
46
+ </div>
47
+
48
+
49
+ </div>
50
+
51
+ <div id="class-metadata">
52
+
53
+ <!-- Parent Class -->
54
+
55
+
56
+ <!-- Namespace Contents -->
57
+
58
+
59
+ <!-- Method Quickref -->
60
+
61
+
62
+ <!-- Included Modules -->
63
+
64
+ </div>
65
+
66
+ <div id="project-metadata">
67
+
68
+
69
+ <div id="fileindex-section" class="section project-section">
70
+ <h3 class="section-header">Files</h3>
71
+ <ul>
72
+
73
+ <li class="file"><a href="../README_rdoc.html">README.rdoc</a></li>
74
+
75
+ </ul>
76
+ </div>
77
+
78
+
79
+ <div id="classindex-section" class="section project-section">
80
+ <h3 class="section-header">Class Index
81
+ <span class="search-toggle"><img src="../images/find.png"
82
+ height="16" width="16" alt="[+]"
83
+ title="show/hide quicksearch" /></span></h3>
84
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
85
+ <fieldset>
86
+ <legend>Quicksearch</legend>
87
+ <input type="text" name="quicksearch" value=""
88
+ class="quicksearch-field" />
89
+ </fieldset>
90
+ </form>
91
+
92
+ <ul class="link-list">
93
+
94
+ <li><a href="../RConfig.html">RConfig</a></li>
95
+
96
+ <li><a href="../RConfig/Callbacks.html">RConfig::Callbacks</a></li>
97
+
98
+ <li><a href="../RConfig/Cascade.html">RConfig::Cascade</a></li>
99
+
100
+ <li><a href="../RConfig/Config.html">RConfig::Config</a></li>
101
+
102
+ <li><a href="../RConfig/ConfigError.html">RConfig::ConfigError</a></li>
103
+
104
+ <li><a href="../RConfig/Constants.html">RConfig::Constants</a></li>
105
+
106
+ <li><a href="../RConfig/CoreMethods.html">RConfig::CoreMethods</a></li>
107
+
108
+ <li><a href="../RConfig/DisabledLogger.html">RConfig::DisabledLogger</a></li>
109
+
110
+ <li><a href="../RConfig/Exceptions.html">RConfig::Exceptions</a></li>
111
+
112
+ <li><a href="../RConfig/Generators.html">RConfig::Generators</a></li>
113
+
114
+ <li><a href="../RConfig/Generators/InstallGenerator.html">RConfig::Generators::InstallGenerator</a></li>
115
+
116
+ <li><a href="../RConfig/InvalidLoadPathError.html">RConfig::InvalidLoadPathError</a></li>
117
+
118
+ <li><a href="../RConfig/LoadPaths.html">RConfig::LoadPaths</a></li>
119
+
120
+ <li><a href="../RConfig/PropertiesFile.html">RConfig::PropertiesFile</a></li>
121
+
122
+ <li><a href="../RConfig/Reload.html">RConfig::Reload</a></li>
123
+
124
+ <li><a href="../RConfig/Settings.html">RConfig::Settings</a></li>
125
+
126
+ <li><a href="../RConfig/Utils.html">RConfig::Utils</a></li>
127
+
128
+ <li><a href="../Array.html">Array</a></li>
129
+
130
+ <li><a href="../Hash.html">Hash</a></li>
131
+
132
+ <li><a href="../NilClass.html">NilClass</a></li>
133
+
134
+ <li><a href="../String.html">String</a></li>
135
+
136
+ </ul>
137
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
138
+ </div>
139
+
140
+
141
+ </div>
142
+ </div>
143
+
144
+ <div id="documentation">
145
+ <h1 class="module">RConfig::Constants</h1>
146
+
147
+ <div id="description">
148
+
149
+ </div>
150
+
151
+ <!-- Constants -->
152
+
153
+ <div id="constants-list" class="section">
154
+ <h3 class="section-header">Constants</h3>
155
+ <dl>
156
+
157
+ <dt><a name="CONFIG_ROOT">CONFIG_ROOT</a></dt>
158
+
159
+ <dd class="description"><p>
160
+ Sets <a href="Constants.html#CONFIG_ROOT">CONFIG_ROOT</a> to
161
+ RAILS_ROOT/config unless it has already been defined (i.e. in rails env, or
162
+ calling ruby app).
163
+ </p></dd>
164
+
165
+
166
+ <dt><a name="ENV_TIER">ENV_TIER</a></dt>
167
+
168
+ <dd class="description"><p>
169
+ ENV TIER i.e. (development, integration, staging, or production) Defaults
170
+ to RAILS_ENV if running in Rails, otherwise, it checks if
171
+ ENV[&#8216;TIER&#8217;] is present. If not, it assumes production.
172
+ </p></dd>
173
+
174
+
175
+ <dt><a name="YML_FILE_TYPES">YML_FILE_TYPES</a></dt>
176
+
177
+ <dd class="description"><p>
178
+ yml, yaml => yaml files, parsable by YAML library
179
+ </p></dd>
180
+
181
+
182
+ <dt><a name="XML_FILE_TYPES">XML_FILE_TYPES</a></dt>
183
+
184
+ <dd class="description"><p>
185
+ xml => self-explanatory
186
+ </p></dd>
187
+
188
+
189
+ <dt><a name="CNF_FILE_TYPES">CNF_FILE_TYPES</a></dt>
190
+
191
+ <dd class="description"><p>
192
+ conf, properties => <key=value> based config files
193
+ </p></dd>
194
+
195
+
196
+ <dt><a name="CONFIG_FILE_TYPES">CONFIG_FILE_TYPES</a></dt>
197
+
198
+ <dd class="description"><p>
199
+ The type of file used for config. Valid choices include (yml, yaml, xml,
200
+ conf, config, properties)
201
+ </p></dd>
202
+
203
+
204
+ <dt><a name="HOSTNAME">HOSTNAME</a></dt>
205
+
206
+ <dd class="description"><p>
207
+ Use CONFIG_HOSTNAME environment variable to test host-based configurations.
208
+ </p></dd>
209
+
210
+
211
+ <dt><a name="HOSTNAME_SHORT">HOSTNAME_SHORT</a></dt>
212
+
213
+ <dd class="description"><p>
214
+ Short Hostname: removes all chars from <a
215
+ href="Constants.html#HOSTNAME">HOSTNAME</a>, after first &#8220;.&#8221;
216
+ Used to specify machine-specific config files.
217
+ </p></dd>
218
+
219
+
220
+ <dt><a name="SUFFIXES">SUFFIXES</a></dt>
221
+
222
+ <dd class="description"><p>
223
+ This is an array of filename suffixes facilitates cascading configuration
224
+ overrides (i.e. &#8216;services_local&#8217;,
225
+ &#8216;services_development&#8217;). These files get loaded in the order of
226
+ the array. Meaning the last file loaded overrides everything before it. So
227
+ config files suffixed with hostname has the highest precedence, and
228
+ therefore overrides everything. Example:
229
+ </p>
230
+ <pre>
231
+ database_local.yml overrides database.yml
232
+ database_staging.yml overrides database_local.yml
233
+ database_appsvr01.yml overrides database_integration.yml</pre></dd>
234
+
235
+
236
+ <dt><a name="EMPTY_ARRAY">EMPTY_ARRAY</a></dt>
237
+
238
+ <dd class="description"><p>
239
+ Used in place of undefined but expected arrays, to prevent creating a bunch
240
+ of unecesary arrays in memory. See ConfigCore.fire_on_load
241
+ </p></dd>
242
+
243
+
244
+ </dl>
245
+ </div>
246
+
247
+
248
+ <!-- Attributes -->
249
+
250
+
251
+ <!-- Methods -->
252
+
253
+
254
+ </div>
255
+
256
+
257
+ <div id="rdoc-debugging-section-dump" class="debugging-section">
258
+
259
+ <p>Disabled; run with --debug to generate this.</p>
260
+
261
+ </div>
262
+
263
+ <div id="validator-badges">
264
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
265
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
266
+ Rdoc Generator</a> 1.1.6</small>.</p>
267
+ </div>
268
+
269
+ </body>
270
+ </html>
271
+
@@ -0,0 +1,814 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7
+
8
+ <title>Module: RConfig::CoreMethods</title>
9
+
10
+ <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
11
+
12
+ <script src="../js/jquery.js" type="text/javascript"
13
+ charset="utf-8"></script>
14
+ <script src="../js/thickbox-compressed.js" type="text/javascript"
15
+ charset="utf-8"></script>
16
+ <script src="../js/quicksearch.js" type="text/javascript"
17
+ charset="utf-8"></script>
18
+ <script src="../js/darkfish.js" type="text/javascript"
19
+ charset="utf-8"></script>
20
+
21
+ </head>
22
+ <body class="module">
23
+
24
+ <div id="metadata">
25
+ <div id="home-metadata">
26
+ <div id="home-section" class="section">
27
+ <h3 class="section-header">
28
+ <a href="../index.html">Home</a>
29
+ <a href="../index.html#classes">Classes</a>
30
+ <a href="../index.html#methods">Methods</a>
31
+ </h3>
32
+ </div>
33
+ </div>
34
+
35
+ <div id="file-metadata">
36
+ <div id="file-list-section" class="section">
37
+ <h3 class="section-header">In Files</h3>
38
+ <div class="section-body">
39
+ <ul>
40
+
41
+ <li><a href="../lib/rconfig/core_methods_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
42
+ class="thickbox" title="lib/rconfig/core_methods.rb">lib/rconfig/core_methods.rb</a></li>
43
+
44
+ </ul>
45
+ </div>
46
+ </div>
47
+
48
+
49
+ </div>
50
+
51
+ <div id="class-metadata">
52
+
53
+ <!-- Parent Class -->
54
+
55
+
56
+ <!-- Namespace Contents -->
57
+
58
+
59
+ <!-- Method Quickref -->
60
+
61
+ <div id="method-list-section" class="section">
62
+ <h3 class="section-header">Methods</h3>
63
+ <ul class="link-list">
64
+
65
+ <li><a href="#method-i-%5B%5D">#[]</a></li>
66
+
67
+ <li><a href="#method-i-check_for_changes">#check_for_changes</a></li>
68
+
69
+ <li><a href="#method-i-config_changed%3F">#config_changed?</a></li>
70
+
71
+ <li><a href="#method-i-config_files">#config_files</a></li>
72
+
73
+ <li><a href="#method-i-config_for">#config_for</a></li>
74
+
75
+ <li><a href="#method-i-get_config_data">#get_config_data</a></li>
76
+
77
+ <li><a href="#method-i-get_config_files">#get_config_files</a></li>
78
+
79
+ <li><a href="#method-i-load_config_files">#load_config_files</a></li>
80
+
81
+ <li><a href="#method-i-method_missing">#method_missing</a></li>
82
+
83
+ <li><a href="#method-i-reload_on_change">#reload_on_change</a></li>
84
+
85
+ <li><a href="#method-i-with_file">#with_file</a></li>
86
+
87
+ </ul>
88
+ </div>
89
+
90
+
91
+ <!-- Included Modules -->
92
+
93
+ <div id="includes-section" class="section">
94
+ <h3 class="section-header">Included Modules</h3>
95
+ <ul class="link-list">
96
+
97
+
98
+ <li><span class="include">Constants</span></li>
99
+
100
+
101
+ </ul>
102
+ </div>
103
+
104
+ </div>
105
+
106
+ <div id="project-metadata">
107
+
108
+
109
+ <div id="fileindex-section" class="section project-section">
110
+ <h3 class="section-header">Files</h3>
111
+ <ul>
112
+
113
+ <li class="file"><a href="../README_rdoc.html">README.rdoc</a></li>
114
+
115
+ </ul>
116
+ </div>
117
+
118
+
119
+ <div id="classindex-section" class="section project-section">
120
+ <h3 class="section-header">Class Index
121
+ <span class="search-toggle"><img src="../images/find.png"
122
+ height="16" width="16" alt="[+]"
123
+ title="show/hide quicksearch" /></span></h3>
124
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
125
+ <fieldset>
126
+ <legend>Quicksearch</legend>
127
+ <input type="text" name="quicksearch" value=""
128
+ class="quicksearch-field" />
129
+ </fieldset>
130
+ </form>
131
+
132
+ <ul class="link-list">
133
+
134
+ <li><a href="../RConfig.html">RConfig</a></li>
135
+
136
+ <li><a href="../RConfig/Callbacks.html">RConfig::Callbacks</a></li>
137
+
138
+ <li><a href="../RConfig/Cascade.html">RConfig::Cascade</a></li>
139
+
140
+ <li><a href="../RConfig/Config.html">RConfig::Config</a></li>
141
+
142
+ <li><a href="../RConfig/ConfigError.html">RConfig::ConfigError</a></li>
143
+
144
+ <li><a href="../RConfig/Constants.html">RConfig::Constants</a></li>
145
+
146
+ <li><a href="../RConfig/CoreMethods.html">RConfig::CoreMethods</a></li>
147
+
148
+ <li><a href="../RConfig/DisabledLogger.html">RConfig::DisabledLogger</a></li>
149
+
150
+ <li><a href="../RConfig/Exceptions.html">RConfig::Exceptions</a></li>
151
+
152
+ <li><a href="../RConfig/Generators.html">RConfig::Generators</a></li>
153
+
154
+ <li><a href="../RConfig/Generators/InstallGenerator.html">RConfig::Generators::InstallGenerator</a></li>
155
+
156
+ <li><a href="../RConfig/InvalidLoadPathError.html">RConfig::InvalidLoadPathError</a></li>
157
+
158
+ <li><a href="../RConfig/LoadPaths.html">RConfig::LoadPaths</a></li>
159
+
160
+ <li><a href="../RConfig/PropertiesFile.html">RConfig::PropertiesFile</a></li>
161
+
162
+ <li><a href="../RConfig/Reload.html">RConfig::Reload</a></li>
163
+
164
+ <li><a href="../RConfig/Settings.html">RConfig::Settings</a></li>
165
+
166
+ <li><a href="../RConfig/Utils.html">RConfig::Utils</a></li>
167
+
168
+ <li><a href="../Array.html">Array</a></li>
169
+
170
+ <li><a href="../Hash.html">Hash</a></li>
171
+
172
+ <li><a href="../NilClass.html">NilClass</a></li>
173
+
174
+ <li><a href="../String.html">String</a></li>
175
+
176
+ </ul>
177
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
178
+ </div>
179
+
180
+
181
+ </div>
182
+ </div>
183
+
184
+ <div id="documentation">
185
+ <h1 class="module">RConfig::CoreMethods</h1>
186
+
187
+ <div id="description">
188
+
189
+ </div>
190
+
191
+ <!-- Constants -->
192
+
193
+
194
+ <!-- Attributes -->
195
+
196
+
197
+ <!-- Methods -->
198
+
199
+ <div id="public-instance-method-details" class="method-section section">
200
+ <h3 class="section-header">Public Instance Methods</h3>
201
+
202
+
203
+ <div id="--method" class="method-detail ">
204
+ <a name="method-i-%5B%5D"></a>
205
+
206
+ <div class="method-heading">
207
+
208
+ <span class="method-name">[]</span><span
209
+ class="method-args">(key, file=:application)</span>
210
+ <span class="method-click-advice">click to toggle source</span>
211
+
212
+ </div>
213
+
214
+ <div class="method-description">
215
+
216
+ <p>
217
+ This method provides shorthand to retrieve configuration data that is
218
+ global in scope, and used on an application or environment-wide level. The
219
+ default location that it checks is the application file. The application
220
+ config file is a special config file that should be used for config data
221
+ that is broad in scope and used throughout the application. Since <a
222
+ href="../RConfig.html">RConfig</a> gives special regard to the application
223
+ config file, thought should be given to whatever config information is
224
+ placed there.
225
+ </p>
226
+ <p>
227
+ Most config data will be specific to particular part of the application
228
+ (i.e. database, web service), and should therefore be placed in its own
229
+ specific config file, such as database.yml, or services.xml
230
+ </p>
231
+ <p>
232
+ This method also acts as a wrapper for ENV. If no value is returned from
233
+ the application config, it will also check ENV for a value matching the
234
+ specified key.
235
+ </p>
236
+ <p>
237
+ Ex.1 RConfig[:test_mode] =>
238
+ </p>
239
+ <pre>
240
+ RConfig.application[:test_mode] ||
241
+ RConfig.application.test_mode
242
+ </pre>
243
+ <p>
244
+ Ex.2 RConfig[:web_app_root] => ENV[&#8216;WEB_APP_ROOT&#8217;]
245
+ </p>
246
+ <p>
247
+ NOTE: The application config file can be in any of
248
+ </p>
249
+ <pre>
250
+ the supported formats (yml, xml, conf, etc.)</pre>
251
+
252
+
253
+
254
+ <div class="method-source-code"
255
+ id="--source">
256
+ <pre>
257
+ <span class="ruby-comment cmt"># File lib/rconfig/core_methods.rb, line 224</span>
258
+ 224: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">file</span>=<span class="ruby-value">:application</span>)
259
+ 225: <span class="ruby-identifier">with_file</span>(<span class="ruby-identifier">file</span>, <span class="ruby-identifier">key</span>) <span class="ruby-operator">||</span> <span class="ruby-constant">ENV</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">upcase</span>]
260
+ 226: <span class="ruby-keyword kw">end</span></pre>
261
+ </div>
262
+
263
+ </div>
264
+
265
+
266
+
267
+
268
+ </div>
269
+
270
+
271
+ <div id="check-for-changes-method" class="method-detail ">
272
+ <a name="method-i-check_for_changes"></a>
273
+
274
+ <div class="method-heading">
275
+
276
+ <span class="method-name">check_for_changes</span><span
277
+ class="method-args">(name=nil)</span>
278
+ <span class="method-click-advice">click to toggle source</span>
279
+
280
+ </div>
281
+
282
+ <div class="method-description">
283
+
284
+ <p>
285
+ If name is specified, checks that file for changes and reloads it if there
286
+ are. Otherwise, checks all files in the cache, reloading the changed
287
+ files.
288
+ </p>
289
+
290
+
291
+
292
+ <div class="method-source-code"
293
+ id="check-for-changes-source">
294
+ <pre>
295
+ <span class="ruby-comment cmt"># File lib/rconfig/core_methods.rb, line 164</span>
296
+ 164: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">check_for_changes</span>(<span class="ruby-identifier">name</span>=<span class="ruby-keyword kw">nil</span>)
297
+ 165: <span class="ruby-identifier">changed</span> = []
298
+ 166: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
299
+ 167: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cache_hash</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span>
300
+ 168: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">reload_on_change</span>(<span class="ruby-identifier">name</span>)
301
+ 169: <span class="ruby-identifier">changed</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">name</span>
302
+ 170: <span class="ruby-keyword kw">end</span>
303
+ 171: <span class="ruby-keyword kw">end</span>
304
+ 172: <span class="ruby-keyword kw">else</span>
305
+ 173: <span class="ruby-identifier">name</span> = <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>
306
+ 174: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">reload_on_change</span>(<span class="ruby-identifier">name</span>)
307
+ 175: <span class="ruby-identifier">changed</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">name</span>
308
+ 176: <span class="ruby-keyword kw">end</span>
309
+ 177: <span class="ruby-keyword kw">end</span>
310
+ 178: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;check_for_changes(#{name.inspect}) =&gt; #{changed.inspect}&quot;</span>
311
+ 179: <span class="ruby-identifier">changed</span>
312
+ 180: <span class="ruby-keyword kw">end</span></pre>
313
+ </div>
314
+
315
+ </div>
316
+
317
+
318
+
319
+
320
+ </div>
321
+
322
+
323
+ <div id="config-changed--method" class="method-detail ">
324
+ <a name="method-i-config_changed%3F"></a>
325
+
326
+ <div class="method-heading">
327
+
328
+ <span class="method-name">config_changed?</span><span
329
+ class="method-args">(name)</span>
330
+ <span class="method-click-advice">click to toggle source</span>
331
+
332
+ </div>
333
+
334
+ <div class="method-description">
335
+
336
+ <p>
337
+ Returns whether or not the config for the given config name has changed
338
+ since it was last loaded.
339
+ </p>
340
+ <p>
341
+ Returns true if any files for config have changes since last load.
342
+ </p>
343
+
344
+
345
+
346
+ <div class="method-source-code"
347
+ id="config-changed--source">
348
+ <pre>
349
+ <span class="ruby-comment cmt"># File lib/rconfig/core_methods.rb, line 131</span>
350
+ 131: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">config_changed?</span>(<span class="ruby-identifier">name</span>)
351
+ 132: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;config_changed?(#{name.inspect})&quot;</span>
352
+ 133: <span class="ruby-identifier">name</span> = <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>
353
+ 134: <span class="ruby-operator">!</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cache_files</span>[<span class="ruby-identifier">name</span>] <span class="ruby-operator">===</span> <span class="ruby-identifier">get_config_files</span>(<span class="ruby-identifier">name</span>))
354
+ 135: <span class="ruby-keyword kw">end</span></pre>
355
+ </div>
356
+
357
+ </div>
358
+
359
+
360
+
361
+
362
+ </div>
363
+
364
+
365
+ <div id="config-files-method" class="method-detail ">
366
+ <a name="method-i-config_files"></a>
367
+
368
+ <div class="method-heading">
369
+
370
+ <span class="method-name">config_files</span><span
371
+ class="method-args">(name)</span>
372
+ <span class="method-click-advice">click to toggle source</span>
373
+
374
+ </div>
375
+
376
+ <div class="method-description">
377
+
378
+ <p>
379
+ Return the config file information for the given config name.
380
+ </p>
381
+
382
+
383
+
384
+ <div class="method-source-code"
385
+ id="config-files-source">
386
+ <pre>
387
+ <span class="ruby-comment cmt"># File lib/rconfig/core_methods.rb, line 120</span>
388
+ 120: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">config_files</span>(<span class="ruby-identifier">name</span>)
389
+ 121: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cache_files</span>[<span class="ruby-identifier">name</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">get_config_files</span>(<span class="ruby-identifier">name</span>)
390
+ 122: <span class="ruby-keyword kw">end</span></pre>
391
+ </div>
392
+
393
+ </div>
394
+
395
+
396
+
397
+
398
+ </div>
399
+
400
+
401
+ <div id="config-for-method" class="method-detail ">
402
+ <a name="method-i-config_for"></a>
403
+
404
+ <div class="method-heading">
405
+
406
+ <span class="method-name">config_for</span><span
407
+ class="method-args">(name)</span>
408
+ <span class="method-click-advice">click to toggle source</span>
409
+
410
+ </div>
411
+
412
+ <div class="method-description">
413
+
414
+ <p>
415
+ Get a hash of merged config data. Will auto check every 5 minutes, for
416
+ longer running apps, unless reload is disabled.
417
+ </p>
418
+
419
+
420
+
421
+ <div class="method-source-code"
422
+ id="config-for-source">
423
+ <pre>
424
+ <span class="ruby-comment cmt"># File lib/rconfig/core_methods.rb, line 252</span>
425
+ 252: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">config_for</span>(<span class="ruby-identifier">name</span>)
426
+ 253: <span class="ruby-identifier">name</span> = <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>
427
+ 254: <span class="ruby-identifier">check_for_changes</span>(<span class="ruby-identifier">name</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">auto_check?</span>(<span class="ruby-identifier">name</span>)
428
+ 255: <span class="ruby-identifier">data</span> = <span class="ruby-identifier">get_config_data</span>(<span class="ruby-identifier">name</span>)
429
+ 256: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;config_for(#{name.inspect}) =&gt; #{data.inspect}&quot;</span>
430
+ 257: <span class="ruby-identifier">data</span>
431
+ 258: <span class="ruby-keyword kw">end</span></pre>
432
+ </div>
433
+
434
+ </div>
435
+
436
+
437
+
438
+
439
+ </div>
440
+
441
+
442
+ <div id="get-config-data-method" class="method-detail ">
443
+ <a name="method-i-get_config_data"></a>
444
+
445
+ <div class="method-heading">
446
+
447
+ <span class="method-name">get_config_data</span><span
448
+ class="method-args">(name)</span>
449
+ <span class="method-click-advice">click to toggle source</span>
450
+
451
+ </div>
452
+
453
+ <div class="method-description">
454
+
455
+ <p>
456
+ Get the merged config hash for the named file. Returns a cached indifferent
457
+ access faker hash merged from all config files for a name.
458
+ </p>
459
+
460
+
461
+
462
+ <div class="method-source-code"
463
+ id="get-config-data-source">
464
+ <pre>
465
+ <span class="ruby-comment cmt"># File lib/rconfig/core_methods.rb, line 143</span>
466
+ 143: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_config_data</span>(<span class="ruby-identifier">name</span>)
467
+ 144: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;get_config_data(#{name.inspect})&quot;</span>
468
+ 145:
469
+ 146: <span class="ruby-identifier">name</span> = <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>
470
+ 147: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cache_hash</span>[<span class="ruby-identifier">name</span>]
471
+ 148: <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cache_hash</span>[<span class="ruby-identifier">name</span>] =
472
+ 149: <span class="ruby-identifier">make_indifferent</span>(
473
+ 150: <span class="ruby-identifier">merge_hashes</span>(
474
+ 151: <span class="ruby-identifier">load_config_files</span>(<span class="ruby-identifier">name</span>)
475
+ 152: )
476
+ 153: )
477
+ 154: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;get_config_data(#{name.inspect}): reloaded&quot;</span>
478
+ 155: <span class="ruby-keyword kw">end</span>
479
+ 156:
480
+ 157: <span class="ruby-identifier">result</span>
481
+ 158: <span class="ruby-keyword kw">end</span></pre>
482
+ </div>
483
+
484
+ </div>
485
+
486
+
487
+
488
+
489
+ </div>
490
+
491
+
492
+ <div id="get-config-files-method" class="method-detail ">
493
+ <a name="method-i-get_config_files"></a>
494
+
495
+ <div class="method-heading">
496
+
497
+ <span class="method-name">get_config_files</span><span
498
+ class="method-args">(name)</span>
499
+ <span class="method-click-advice">click to toggle source</span>
500
+
501
+ </div>
502
+
503
+ <div class="method-description">
504
+
505
+ <p>
506
+ Returns a list of all relevant config files as specified by suffixes list.
507
+ Each element is an <a href="../Array.html">Array</a>, containing:
508
+ </p>
509
+ <pre>
510
+ [
511
+ &quot;server&quot;, # The base name of the
512
+ &quot;server_production&quot;, # The suffixed name
513
+ &quot;/path/to/server.yml&quot;, # The absolute path to the file
514
+ &lt;Wed Apr 09 08:53:14&gt; # The last modified time of the file or nil, if it doesn't exist.
515
+ ]</pre>
516
+
517
+
518
+
519
+ <div class="method-source-code"
520
+ id="get-config-files-source">
521
+ <pre>
522
+ <span class="ruby-comment cmt"># File lib/rconfig/core_methods.rb, line 95</span>
523
+ 95: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_config_files</span>(<span class="ruby-identifier">name</span>)
524
+ 96: <span class="ruby-identifier">files</span> = []
525
+ 97:
526
+ 98: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">load_paths</span>.<span class="ruby-identifier">reverse</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">directory</span><span class="ruby-operator">|</span>
527
+ 99: <span class="ruby-comment cmt"># splatting *suffix allows us to deal with multipart suffixes</span>
528
+ 100: <span class="ruby-identifier">name_no_overlay</span>, <span class="ruby-identifier">suffixes</span> = <span class="ruby-identifier">suffixes_for</span>(<span class="ruby-identifier">name</span>)
529
+ 101: <span class="ruby-identifier">suffixes</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">suffix</span><span class="ruby-operator">|</span> [<span class="ruby-identifier">name_no_overlay</span>, *<span class="ruby-identifier">suffix</span>].<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">'_'</span>) }.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name_with_suffix</span><span class="ruby-operator">|</span>
530
+ 102: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">file_types</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ext</span><span class="ruby-operator">|</span>
531
+ 103: <span class="ruby-identifier">filename</span> = <span class="ruby-identifier">filename_for_name</span>(<span class="ruby-identifier">name_with_suffix</span>, <span class="ruby-identifier">directory</span>, <span class="ruby-identifier">ext</span>)
532
+ 104: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">filename</span>)
533
+ 105: <span class="ruby-identifier">modified_time</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-identifier">filename</span>).<span class="ruby-identifier">mtime</span>
534
+ 106: <span class="ruby-identifier">files</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">name</span>, <span class="ruby-identifier">name_with_suffix</span>, <span class="ruby-identifier">filename</span>, <span class="ruby-identifier">ext</span>, <span class="ruby-identifier">modified_time</span>]
535
+ 107: <span class="ruby-keyword kw">end</span>
536
+ 108: <span class="ruby-keyword kw">end</span>
537
+ 109: <span class="ruby-keyword kw">end</span>
538
+ 110: <span class="ruby-keyword kw">end</span>
539
+ 111:
540
+ 112: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;get_config_files(#{name}) =&gt; #{files.select { |x| x[3] }.inspect}&quot;</span>
541
+ 113:
542
+ 114: <span class="ruby-identifier">files</span>
543
+ 115: <span class="ruby-keyword kw">end</span></pre>
544
+ </div>
545
+
546
+ </div>
547
+
548
+
549
+
550
+
551
+ </div>
552
+
553
+
554
+ <div id="load-config-files-method" class="method-detail ">
555
+ <a name="method-i-load_config_files"></a>
556
+
557
+ <div class="method-heading">
558
+
559
+ <span class="method-name">load_config_files</span><span
560
+ class="method-args">(name, force=false)</span>
561
+ <span class="method-click-advice">click to toggle source</span>
562
+
563
+ </div>
564
+
565
+ <div class="method-description">
566
+
567
+ <p>
568
+ Get each config file&#8217;s yaml hash for the given config name, to be
569
+ merged later. Files will only be loaded if they have not been loaded before
570
+ or the files have changed within the last five minutes, or force is
571
+ explicitly set to true.
572
+ </p>
573
+
574
+
575
+
576
+ <div class="method-source-code"
577
+ id="load-config-files-source">
578
+ <pre>
579
+ <span class="ruby-comment cmt"># File lib/rconfig/core_methods.rb, line 14</span>
580
+ 14: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">load_config_files</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">force</span>=<span class="ruby-keyword kw">false</span>)
581
+ 15: <span class="ruby-identifier">name</span> = <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>
582
+ 16:
583
+ 17: <span class="ruby-comment cmt"># Return last config file hash list loaded,</span>
584
+ 18: <span class="ruby-comment cmt"># if reload is disabled and files have already been loaded.</span>
585
+ 19: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cache_config_files</span>[<span class="ruby-identifier">name</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">reload_disabled?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cache_config_files</span>[<span class="ruby-identifier">name</span>]
586
+ 20:
587
+ 21: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-node">&quot;Loading config files for: #{name}&quot;</span>
588
+ 22: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;load_config_files(#{name.inspect})&quot;</span>
589
+ 23:
590
+ 24:
591
+ 25: <span class="ruby-identifier">now</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
592
+ 26:
593
+ 27: <span class="ruby-comment cmt"># Get array of all the existing files file the config name.</span>
594
+ 28: <span class="ruby-identifier">config_files</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">get_config_files</span>(<span class="ruby-identifier">name</span>)
595
+ 29:
596
+ 30: <span class="ruby-comment cmt"># Get all the data from all yaml files into as configs</span>
597
+ 31: <span class="ruby-identifier">configs</span> = <span class="ruby-identifier">config_files</span>.<span class="ruby-identifier">collect</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
598
+ 32: <span class="ruby-identifier">name</span>, <span class="ruby-identifier">name_with_suffix</span>, <span class="ruby-identifier">filename</span>, <span class="ruby-identifier">ext</span>, <span class="ruby-identifier">modified_time</span> = * <span class="ruby-identifier">f</span>
599
+ 33:
600
+ 34: <span class="ruby-comment cmt"># Get the cached file info the specific file, if</span>
601
+ 35: <span class="ruby-comment cmt"># it's been loaded before.</span>
602
+ 36: <span class="ruby-identifier">config_data</span>, <span class="ruby-identifier">last_modified</span>, <span class="ruby-identifier">last_loaded</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cache</span>[<span class="ruby-identifier">filename</span>]
603
+ 37:
604
+ 38: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;f = #{f.inspect}\n&quot;</span> <span class="ruby-operator">+</span>
605
+ 39: <span class="ruby-node">&quot;cache #{name_with_suffix} filename = #{filename.inspect}\n&quot;</span> <span class="ruby-operator">+</span>
606
+ 40: <span class="ruby-node">&quot;cache #{name_with_suffix} config_data = #{config_data.inspect}\n&quot;</span> <span class="ruby-operator">+</span>
607
+ 41: <span class="ruby-node">&quot;cache #{name_with_suffix} last_modified = #{last_modified.inspect}\n&quot;</span> <span class="ruby-operator">+</span>
608
+ 42: <span class="ruby-node">&quot;cache #{name_with_suffix} last_loaded = #{last_loaded.inspect}\n&quot;</span>
609
+ 43:
610
+ 44: <span class="ruby-comment cmt"># Load the file if its never been loaded or its been more than</span>
611
+ 45: <span class="ruby-comment cmt"># so many minutes since last load attempt. (default: 5 minutes)</span>
612
+ 46: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">config_data</span>.<span class="ruby-identifier">blank?</span> <span class="ruby-operator">||</span> (<span class="ruby-identifier">now</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">last_loaded</span> <span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">reload_interval</span>)
613
+ 47: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">force</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">config_data</span>.<span class="ruby-identifier">blank?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">modified_time</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">last_modified</span>
614
+ 48:
615
+ 49: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;modified_time #{name.inspect} #{filename.inspect} &quot;</span> <span class="ruby-operator">+</span>
616
+ 50: <span class="ruby-node">&quot;changed #{modified_time != last_modified} : #{modified_time.inspect} #{last_modified.inspect}&quot;</span>
617
+ 51:
618
+ 52: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;RConfig: loading #{filename.inspect}&quot;</span>
619
+ 53:
620
+ 54: <span class="ruby-identifier">config_data</span> = <span class="ruby-identifier">read</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">ext</span>) <span class="ruby-comment cmt"># Get contents from config file</span>
621
+ 55:
622
+ 56: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;RConfig: loaded #{filename.inspect} =&gt; #{config_data.inspect}&quot;</span>
623
+ 57:
624
+ 58: (<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">config_loaded</span> <span class="ruby-operator">||=</span> {})[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">config_files</span> <span class="ruby-comment cmt"># add files to the loaded files cache</span>
625
+ 59:
626
+ 60: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cache</span>[<span class="ruby-identifier">filename</span>] = [<span class="ruby-identifier">config_data</span>, <span class="ruby-identifier">modified_time</span>, <span class="ruby-identifier">now</span>] <span class="ruby-comment cmt"># Save cached config file contents, and modified_time.</span>
627
+ 61:
628
+ 62: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;cache[#{filename.inspect}] = #{self.cache[filename].inspect}&quot;</span>
629
+ 63:
630
+ 64: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cache_hash</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># Flush merged hash cache.</span>
631
+ 65:
632
+ 66: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cache_files</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">config_files</span> <span class="ruby-comment cmt"># Config files changed or disappeared.</span>
633
+ 67:
634
+ 68: <span class="ruby-keyword kw">end</span> <span class="ruby-comment cmt"># if config_data == nil || (now - last_loaded &gt; self.reload_interval)</span>
635
+ 69: <span class="ruby-keyword kw">end</span> <span class="ruby-comment cmt"># if force || config_data == nil || modified_time != last_modified</span>
636
+ 70:
637
+ 71: <span class="ruby-identifier">config_data</span>
638
+ 72: <span class="ruby-keyword kw">end</span> <span class="ruby-comment cmt"># config_files.collect</span>
639
+ 73: <span class="ruby-identifier">configs</span>.<span class="ruby-identifier">compact!</span>
640
+ 74:
641
+ 75: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;load_config_files(#{name.inspect}) =&gt; #{configs.inspect}&quot;</span>
642
+ 76:
643
+ 77: <span class="ruby-comment cmt"># Keep last loaded config files around in case self.reload_dsabled.</span>
644
+ 78: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cache_config_files</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">configs</span> <span class="ruby-comment cmt">#unless configs.empty?</span>
645
+ 79:
646
+ 80: <span class="ruby-identifier">configs</span>
647
+ 81: <span class="ruby-keyword kw">end</span></pre>
648
+ </div>
649
+
650
+ </div>
651
+
652
+
653
+
654
+
655
+ </div>
656
+
657
+
658
+ <div id="method-missing-method" class="method-detail ">
659
+ <a name="method-i-method_missing"></a>
660
+
661
+ <div class="method-heading">
662
+
663
+ <span class="method-name">method_missing</span><span
664
+ class="method-args">(method, * args)</span>
665
+ <span class="method-click-advice">click to toggle source</span>
666
+
667
+ </div>
668
+
669
+ <div class="method-description">
670
+
671
+ <p>
672
+ Short-hand access to config file by its name.
673
+ </p>
674
+ <p>
675
+ Example:
676
+ </p>
677
+ <pre>
678
+ RConfig.provider(:foo) =&gt; RConfig.with_file(:provider).foo
679
+ RConfig.provider.foo =&gt; RConfig.with_file(:provider).foo</pre>
680
+
681
+
682
+
683
+ <div class="method-source-code"
684
+ id="method-missing-source">
685
+ <pre>
686
+ <span class="ruby-comment cmt"># File lib/rconfig/core_methods.rb, line 268</span>
687
+ 268: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">method</span>, * <span class="ruby-identifier">args</span>)
688
+ 269: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">with_file</span>(<span class="ruby-identifier">method</span>, * <span class="ruby-identifier">args</span>)
689
+ 270: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;#{self}.method_missing(#{method.inspect}, #{args.inspect}) =&gt; #{value.inspect}&quot;</span>
690
+ 271: <span class="ruby-identifier">value</span>
691
+ 272: <span class="ruby-keyword kw">end</span></pre>
692
+ </div>
693
+
694
+ </div>
695
+
696
+
697
+
698
+
699
+ </div>
700
+
701
+
702
+ <div id="reload-on-change-method" class="method-detail ">
703
+ <a name="method-i-reload_on_change"></a>
704
+
705
+ <div class="method-heading">
706
+
707
+ <span class="method-name">reload_on_change</span><span
708
+ class="method-args">(name)</span>
709
+ <span class="method-click-advice">click to toggle source</span>
710
+
711
+ </div>
712
+
713
+ <div class="method-description">
714
+
715
+ <p>
716
+ If config files have changed, caches are flushed, on_load triggers are run.
717
+ </p>
718
+
719
+
720
+
721
+ <div class="method-source-code"
722
+ id="reload-on-change-source">
723
+ <pre>
724
+ <span class="ruby-comment cmt"># File lib/rconfig/core_methods.rb, line 184</span>
725
+ 184: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reload_on_change</span>(<span class="ruby-identifier">name</span>)
726
+ 185: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;reload_on_change(#{name.inspect}), reload_disabled=#{self.reload_disabled?}&quot;</span>
727
+ 186: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">changed</span> = <span class="ruby-identifier">config_changed?</span>(<span class="ruby-identifier">name</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">reload?</span>
728
+ 187: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cache_hash</span>[<span class="ruby-identifier">name</span>]
729
+ 188: <span class="ruby-identifier">flush_cache</span>(<span class="ruby-identifier">name</span>) <span class="ruby-comment cmt"># flush cached config values.</span>
730
+ 189: <span class="ruby-identifier">fire_on_load</span>(<span class="ruby-identifier">name</span>) <span class="ruby-comment cmt"># force on_load triggers.</span>
731
+ 190: <span class="ruby-keyword kw">end</span>
732
+ 191: <span class="ruby-keyword kw">end</span>
733
+ 192: <span class="ruby-identifier">changed</span>
734
+ 193: <span class="ruby-keyword kw">end</span></pre>
735
+ </div>
736
+
737
+ </div>
738
+
739
+
740
+
741
+
742
+ </div>
743
+
744
+
745
+ <div id="with-file-method" class="method-detail ">
746
+ <a name="method-i-with_file"></a>
747
+
748
+ <div class="method-heading">
749
+
750
+ <span class="method-name">with_file</span><span
751
+ class="method-args">(name, *args)</span>
752
+ <span class="method-click-advice">click to toggle source</span>
753
+
754
+ </div>
755
+
756
+ <div class="method-description">
757
+
758
+ <p>
759
+ Get the value specified by the args, in the file specified by th name
760
+ </p>
761
+
762
+
763
+
764
+ <div class="method-source-code"
765
+ id="with-file-source">
766
+ <pre>
767
+ <span class="ruby-comment cmt"># File lib/rconfig/core_methods.rb, line 231</span>
768
+ 231: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">with_file</span>(<span class="ruby-identifier">name</span>, *<span class="ruby-identifier">args</span>)
769
+ 232: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;with_file(#{name.inspect}, #{args.inspect})&quot;</span>
770
+ 233: <span class="ruby-identifier">result</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-identifier">config_for</span>(<span class="ruby-identifier">name</span>)) { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
771
+ 234: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;v = #{v.inspect}, i = #{i.inspect}&quot;</span>
772
+ 235: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">v</span>
773
+ 236: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Hash</span>
774
+ 237: <span class="ruby-identifier">v</span>[<span class="ruby-identifier">i</span>.<span class="ruby-identifier">to_s</span>]
775
+ 238: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Array</span>
776
+ 239: <span class="ruby-identifier">i</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Integer</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">v</span>[<span class="ruby-identifier">i</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
777
+ 240: <span class="ruby-keyword kw">else</span>
778
+ 241: <span class="ruby-keyword kw">nil</span>
779
+ 242: <span class="ruby-keyword kw">end</span>
780
+ 243: }
781
+ 244: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;with_file(#{name.inspect}, #{args.inspect}) =&gt; #{result.inspect}&quot;</span>
782
+ 245: <span class="ruby-identifier">result</span>
783
+ 246: <span class="ruby-keyword kw">end</span></pre>
784
+ </div>
785
+
786
+ </div>
787
+
788
+
789
+
790
+
791
+ </div>
792
+
793
+
794
+ </div>
795
+
796
+
797
+ </div>
798
+
799
+
800
+ <div id="rdoc-debugging-section-dump" class="debugging-section">
801
+
802
+ <p>Disabled; run with --debug to generate this.</p>
803
+
804
+ </div>
805
+
806
+ <div id="validator-badges">
807
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
808
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
809
+ Rdoc Generator</a> 1.1.6</small>.</p>
810
+ </div>
811
+
812
+ </body>
813
+ </html>
814
+