reflection 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,409 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta name="Content-Type" content="text/html; charset=UTF-8" />
6
+ <title>Module: Reflection::Rails</title>
7
+ <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
8
+ <link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
9
+
10
+ <script type="text/javascript" charset="utf-8">
11
+ relpath = '..';
12
+ if (relpath != '') relpath += '/';
13
+ </script>
14
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
15
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
16
+
17
+ </head>
18
+ <body>
19
+ <div id="header">
20
+ <div id="menu">
21
+
22
+ <a href="../_index.html">Index (R)</a> &raquo;
23
+ <a title="Reflection" href="../Reflection.html">Reflection</a>
24
+ &raquo;
25
+ <span class="title">Rails</span>
26
+
27
+ </div>
28
+
29
+ <div id="search">
30
+ <a id="class_list_link" href="#">Namespace List</a>
31
+ <a id="method_list_link" href="#">Method List</a>
32
+ <a id ="file_list_link" href="#">File List</a>
33
+ </div>
34
+
35
+ <div class="clear"></div>
36
+ </div>
37
+
38
+ <iframe id="search_frame"></iframe>
39
+
40
+ <div id="content"><h1>Module: Reflection::Rails
41
+
42
+
43
+ </h1>
44
+
45
+ <dl class="box">
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+ <dt class="r1 last">Defined in:</dt>
54
+ <dd class="r1 last">lib/reflection/rails.rb</dd>
55
+
56
+ </dl>
57
+ <div class="clear"></div>
58
+
59
+
60
+
61
+
62
+ <h2>Method Summary</h2>
63
+ <ul class="summary">
64
+
65
+ <li class="public ">
66
+ <span class="summary_signature"><a title="apply (class method)" href="#apply-class_method">+ (Object) <strong>apply</strong>(config, target_directory) </a>
67
+
68
+ </span>
69
+
70
+
71
+
72
+
73
+
74
+
75
+ <span class="summary_desc"></span>
76
+
77
+ </li>
78
+
79
+
80
+ <li class="public ">
81
+ <span class="summary_signature"><a title="clean_target (class method)" href="#clean_target-class_method">+ (Object) <strong>clean_target</strong>(target_directory) </a>
82
+
83
+ </span>
84
+
85
+
86
+
87
+
88
+
89
+
90
+ <span class="summary_desc"></span>
91
+
92
+ </li>
93
+
94
+
95
+ <li class="public ">
96
+ <span class="summary_signature"><a title="database_command_line_options (class method)" href="#database_command_line_options-class_method">+ (Object) <strong>database_command_line_options</strong>(database_config) </a>
97
+
98
+ </span>
99
+
100
+
101
+
102
+
103
+
104
+
105
+ <span class="summary_desc"></span>
106
+
107
+ </li>
108
+
109
+
110
+ <li class="public ">
111
+ <span class="summary_signature"><a title="read_database_configuration (class method)" href="#read_database_configuration-class_method">+ (Object) <strong>read_database_configuration</strong>(config) </a>
112
+
113
+ </span>
114
+
115
+
116
+
117
+
118
+
119
+
120
+ <span class="summary_desc"></span>
121
+
122
+ </li>
123
+
124
+
125
+ <li class="public ">
126
+ <span class="summary_signature"><a title="stash (class method)" href="#stash-class_method">+ (Object) <strong>stash</strong>(config, target_directory) </a>
127
+
128
+ </span>
129
+
130
+
131
+
132
+
133
+
134
+
135
+ <span class="summary_desc"></span>
136
+
137
+ </li>
138
+
139
+
140
+ <li class="public ">
141
+ <span class="summary_signature"><a title="validate_environment (class method)" href="#validate_environment-class_method">+ (Object) <strong>validate_environment</strong>(config) </a>
142
+
143
+ </span>
144
+
145
+
146
+
147
+
148
+
149
+
150
+ <span class="summary_desc"></span>
151
+
152
+ </li>
153
+
154
+
155
+ </ul>
156
+
157
+
158
+
159
+ <div id="method_details">
160
+ <h2>Method Details</h2>
161
+
162
+ <div class="method_details first">
163
+ <p class="signature first" id="apply-class_method">
164
+
165
+ + (<tt>Object</tt>) <strong>apply</strong>(config, target_directory)
166
+
167
+
168
+
169
+ </p><table class="source_code">
170
+ <tr>
171
+ <td>
172
+ <pre class="lines">
173
+
174
+
175
+ 51
176
+ 52
177
+ 53
178
+ 54
179
+ 55
180
+ 56
181
+ 57
182
+ 58</pre>
183
+ </td>
184
+ <td>
185
+ <pre class="code"><span class="info file"># File 'lib/reflection/rails.rb', line 51</span>
186
+
187
+ <span class='def def kw'>def</span> <span class='apply identifier id'>apply</span><span class='lparen token'>(</span><span class='config identifier id'>config</span><span class='comma token'>,</span> <span class='target_directory identifier id'>target_directory</span><span class='rparen token'>)</span>
188
+ <span class='Reflection constant id'>Reflection</span><span class='dot token'>.</span><span class='log identifier id'>log</span><span class='dot token'>.</span><span class='debug identifier id'>debug</span> <span class='string val'>&quot;Applying database dump..&quot;</span>
189
+ <span class='return return kw'>return</span> <span class='unless unless_mod kw'>unless</span> <span class='database_config identifier id'>database_config</span> <span class='assign token'>=</span> <span class='read_database_configuration identifier id'>read_database_configuration</span><span class='lparen token'>(</span><span class='config identifier id'>config</span><span class='rparen token'>)</span>
190
+ <span class='options identifier id'>options</span> <span class='assign token'>=</span> <span class='database_command_line_options identifier id'>database_command_line_options</span><span class='lparen token'>(</span><span class='database_config identifier id'>database_config</span><span class='rparen token'>)</span>
191
+ <span class='target_file_path identifier id'>target_file_path</span> <span class='assign token'>=</span> <span class='File constant id'>File</span><span class='dot token'>.</span><span class='join identifier id'>join</span><span class='lparen token'>(</span><span class='target_directory identifier id'>target_directory</span><span class='dot token'>.</span><span class='path identifier id'>path</span><span class='comma token'>,</span> <span class='string val'>'_rails_database_dump.sql'</span><span class='rparen token'>)</span>
192
+ <span class='dxstring node'>%x(mysql #{options} &lt; #{target_file_path})</span>
193
+ <span class='clean_target identifier id'>clean_target</span><span class='lparen token'>(</span><span class='target_directory identifier id'>target_directory</span><span class='rparen token'>)</span>
194
+ <span class='end end kw'>end</span>
195
+ </pre>
196
+ </td>
197
+ </tr>
198
+ </table>
199
+ </div>
200
+
201
+ <div class="method_details ">
202
+ <p class="signature " id="clean_target-class_method">
203
+
204
+ + (<tt>Object</tt>) <strong>clean_target</strong>(target_directory)
205
+
206
+
207
+
208
+ </p><table class="source_code">
209
+ <tr>
210
+ <td>
211
+ <pre class="lines">
212
+
213
+
214
+ 12
215
+ 13
216
+ 14
217
+ 15
218
+ 16
219
+ 17</pre>
220
+ </td>
221
+ <td>
222
+ <pre class="code"><span class="info file"># File 'lib/reflection/rails.rb', line 12</span>
223
+
224
+ <span class='def def kw'>def</span> <span class='clean_target identifier id'>clean_target</span><span class='lparen token'>(</span><span class='target_directory identifier id'>target_directory</span><span class='rparen token'>)</span>
225
+ <span class='target_file_path identifier id'>target_file_path</span> <span class='assign token'>=</span> <span class='File constant id'>File</span><span class='dot token'>.</span><span class='join identifier id'>join</span><span class='lparen token'>(</span><span class='target_directory identifier id'>target_directory</span><span class='dot token'>.</span><span class='path identifier id'>path</span><span class='comma token'>,</span> <span class='string val'>'_rails_database_dump.sql'</span><span class='rparen token'>)</span>
226
+ <span class='if if kw'>if</span> <span class='File constant id'>File</span><span class='dot token'>.</span><span class='exist? fid id'>exist?</span><span class='lparen token'>(</span><span class='target_file_path identifier id'>target_file_path</span><span class='rparen token'>)</span>
227
+ <span class='dxstring node'>%x(rm #{target_file_path})</span>
228
+ <span class='end end kw'>end</span>
229
+ <span class='end end kw'>end</span>
230
+ </pre>
231
+ </td>
232
+ </tr>
233
+ </table>
234
+ </div>
235
+
236
+ <div class="method_details ">
237
+ <p class="signature " id="database_command_line_options-class_method">
238
+
239
+ + (<tt>Object</tt>) <strong>database_command_line_options</strong>(database_config)
240
+
241
+
242
+
243
+ </p><table class="source_code">
244
+ <tr>
245
+ <td>
246
+ <pre class="lines">
247
+
248
+
249
+ 19
250
+ 20
251
+ 21
252
+ 22
253
+ 23
254
+ 24
255
+ 25
256
+ 26</pre>
257
+ </td>
258
+ <td>
259
+ <pre class="code"><span class="info file"># File 'lib/reflection/rails.rb', line 19</span>
260
+
261
+ <span class='def def kw'>def</span> <span class='database_command_line_options identifier id'>database_command_line_options</span><span class='lparen token'>(</span><span class='database_config identifier id'>database_config</span><span class='rparen token'>)</span>
262
+ <span class='options identifier id'>options</span> <span class='assign token'>=</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span>
263
+ <span class='options identifier id'>options</span> <span class='lshft op'>&lt;&lt;</span> <span class='dstring node'>&quot;-h #{database_config['host']}&quot;</span>
264
+ <span class='options identifier id'>options</span> <span class='lshft op'>&lt;&lt;</span> <span class='dstring node'>&quot;-u #{database_config['username']}&quot;</span>
265
+ <span class='options identifier id'>options</span> <span class='lshft op'>&lt;&lt;</span> <span class='dstring node'>&quot;-p #{database_config['password']}&quot;</span> <span class='if if_mod kw'>if</span> <span class='database_config identifier id'>database_config</span><span class='lbrack token'>[</span><span class='string val'>'password'</span><span class='rbrack token'>]</span> <span class='andop op'>&amp;&amp;</span> <span class='notop op'>!</span><span class='database_config identifier id'>database_config</span><span class='lbrack token'>[</span><span class='string val'>'password'</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='empty? fid id'>empty?</span>
266
+ <span class='options identifier id'>options</span> <span class='lshft op'>&lt;&lt;</span> <span class='dstring node'>&quot;#{database_config['database']}&quot;</span>
267
+ <span class='options identifier id'>options</span><span class='dot token'>.</span><span class='join identifier id'>join</span><span class='lparen token'>(</span><span class='string val'>' '</span><span class='rparen token'>)</span>
268
+ <span class='end end kw'>end</span>
269
+ </pre>
270
+ </td>
271
+ </tr>
272
+ </table>
273
+ </div>
274
+
275
+ <div class="method_details ">
276
+ <p class="signature " id="read_database_configuration-class_method">
277
+
278
+ + (<tt>Object</tt>) <strong>read_database_configuration</strong>(config)
279
+
280
+
281
+
282
+ </p><table class="source_code">
283
+ <tr>
284
+ <td>
285
+ <pre class="lines">
286
+
287
+
288
+ 28
289
+ 29
290
+ 30
291
+ 31
292
+ 32
293
+ 33
294
+ 34
295
+ 35
296
+ 36
297
+ 37
298
+ 38
299
+ 39
300
+ 40
301
+ 41</pre>
302
+ </td>
303
+ <td>
304
+ <pre class="code"><span class="info file"># File 'lib/reflection/rails.rb', line 28</span>
305
+
306
+ <span class='def def kw'>def</span> <span class='read_database_configuration identifier id'>read_database_configuration</span><span class='lparen token'>(</span><span class='config identifier id'>config</span><span class='rparen token'>)</span>
307
+ <span class='begin begin kw'>begin</span>
308
+ <span class='database_path identifier id'>database_path</span> <span class='assign token'>=</span> <span class='File constant id'>File</span><span class='dot token'>.</span><span class='join identifier id'>join</span><span class='lparen token'>(</span><span class='config identifier id'>config</span><span class='dot token'>.</span><span class='rails_root identifier id'>rails_root</span><span class='comma token'>,</span> <span class='string val'>&quot;config/database.yml&quot;</span><span class='rparen token'>)</span>
309
+ <span class='if if kw'>if</span> <span class='db_config identifier id'>db_config</span> <span class='assign token'>=</span> <span class='YAML constant id'>YAML</span><span class='dot token'>.</span><span class='load_file identifier id'>load_file</span><span class='lparen token'>(</span><span class='database_path identifier id'>database_path</span><span class='rparen token'>)</span><span class='lbrack token'>[</span><span class='config identifier id'>config</span><span class='dot token'>.</span><span class='rails_environment identifier id'>rails_environment</span><span class='rbrack token'>]</span>
310
+ <span class='return return kw'>return</span> <span class='db_config identifier id'>db_config</span>
311
+ <span class='else else kw'>else</span>
312
+ <span class='Reflection constant id'>Reflection</span><span class='dot token'>.</span><span class='log identifier id'>log</span><span class='dot token'>.</span><span class='error identifier id'>error</span><span class='lparen token'>(</span><span class='dstring node'>&quot;Rails database configuration for '#{config.rails_environment}' isn't available in #{database_path}&quot;</span><span class='rparen token'>)</span>
313
+ <span class='return return kw'>return</span> <span class='false false kw'>false</span>
314
+ <span class='end end kw'>end</span>
315
+ <span class='rescue rescue kw'>rescue</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='e identifier id'>e</span>
316
+ <span class='Reflection constant id'>Reflection</span><span class='dot token'>.</span><span class='log identifier id'>log</span><span class='dot token'>.</span><span class='error identifier id'>error</span><span class='lparen token'>(</span><span class='dstring node'>&quot;Error while parsing Rails database configuration: #{e}&quot;</span><span class='rparen token'>)</span>
317
+ <span class='return return kw'>return</span> <span class='false false kw'>false</span>
318
+ <span class='end end kw'>end</span>
319
+ <span class='end end kw'>end</span>
320
+ </pre>
321
+ </td>
322
+ </tr>
323
+ </table>
324
+ </div>
325
+
326
+ <div class="method_details ">
327
+ <p class="signature " id="stash-class_method">
328
+
329
+ + (<tt>Object</tt>) <strong>stash</strong>(config, target_directory)
330
+
331
+
332
+
333
+ </p><table class="source_code">
334
+ <tr>
335
+ <td>
336
+ <pre class="lines">
337
+
338
+
339
+ 43
340
+ 44
341
+ 45
342
+ 46
343
+ 47
344
+ 48
345
+ 49</pre>
346
+ </td>
347
+ <td>
348
+ <pre class="code"><span class="info file"># File 'lib/reflection/rails.rb', line 43</span>
349
+
350
+ <span class='def def kw'>def</span> <span class='stash identifier id'>stash</span><span class='lparen token'>(</span><span class='config identifier id'>config</span><span class='comma token'>,</span> <span class='target_directory identifier id'>target_directory</span><span class='rparen token'>)</span>
351
+ <span class='Reflection constant id'>Reflection</span><span class='dot token'>.</span><span class='log identifier id'>log</span><span class='dot token'>.</span><span class='debug identifier id'>debug</span> <span class='string val'>&quot;Stashing database dump..&quot;</span>
352
+ <span class='return return kw'>return</span> <span class='unless unless_mod kw'>unless</span> <span class='database_config identifier id'>database_config</span> <span class='assign token'>=</span> <span class='read_database_configuration identifier id'>read_database_configuration</span><span class='lparen token'>(</span><span class='config identifier id'>config</span><span class='rparen token'>)</span>
353
+ <span class='options identifier id'>options</span> <span class='assign token'>=</span> <span class='database_command_line_options identifier id'>database_command_line_options</span><span class='lparen token'>(</span><span class='database_config identifier id'>database_config</span><span class='rparen token'>)</span>
354
+ <span class='target_file_path identifier id'>target_file_path</span> <span class='assign token'>=</span> <span class='File constant id'>File</span><span class='dot token'>.</span><span class='join identifier id'>join</span><span class='lparen token'>(</span><span class='target_directory identifier id'>target_directory</span><span class='dot token'>.</span><span class='path identifier id'>path</span><span class='comma token'>,</span> <span class='string val'>'_rails_database_dump.sql'</span><span class='rparen token'>)</span>
355
+ <span class='dxstring node'>%x(mysqldump #{options} --add-drop-table &gt; #{target_file_path})</span>
356
+ <span class='end end kw'>end</span>
357
+ </pre>
358
+ </td>
359
+ </tr>
360
+ </table>
361
+ </div>
362
+
363
+ <div class="method_details ">
364
+ <p class="signature " id="validate_environment-class_method">
365
+
366
+ + (<tt>Object</tt>) <strong>validate_environment</strong>(config)
367
+
368
+
369
+
370
+ </p><table class="source_code">
371
+ <tr>
372
+ <td>
373
+ <pre class="lines">
374
+
375
+
376
+ 5
377
+ 6
378
+ 7
379
+ 8
380
+ 9
381
+ 10</pre>
382
+ </td>
383
+ <td>
384
+ <pre class="code"><span class="info file"># File 'lib/reflection/rails.rb', line 5</span>
385
+
386
+ <span class='def def kw'>def</span> <span class='validate_environment identifier id'>validate_environment</span><span class='lparen token'>(</span><span class='config identifier id'>config</span><span class='rparen token'>)</span>
387
+ <span class='env_file_path identifier id'>env_file_path</span> <span class='assign token'>=</span> <span class='File constant id'>File</span><span class='dot token'>.</span><span class='join identifier id'>join</span><span class='lparen token'>(</span><span class='config identifier id'>config</span><span class='dot token'>.</span><span class='rails_root identifier id'>rails_root</span><span class='comma token'>,</span> <span class='string val'>'config/environments'</span><span class='comma token'>,</span> <span class='dstring node'>&quot;#{config.rails_environment}.rb&quot;</span><span class='rparen token'>)</span>
388
+ <span class='unless unless kw'>unless</span> <span class='File constant id'>File</span><span class='dot token'>.</span><span class='exist? fid id'>exist?</span><span class='lparen token'>(</span><span class='env_file_path identifier id'>env_file_path</span><span class='rparen token'>)</span>
389
+ <span class='Reflection constant id'>Reflection</span><span class='colon2 op'>::</span><span class='Support constant id'>Support</span><span class='dot token'>.</span><span class='exit_with_error identifier id'>exit_with_error</span><span class='lparen token'>(</span><span class='dstring node'>&quot;Rails environment '#{config.rails_environment}' doesn't exist in #{env_file_path}.&quot;</span><span class='rparen token'>)</span>
390
+ <span class='end end kw'>end</span>
391
+ <span class='end end kw'>end</span>
392
+ </pre>
393
+ </td>
394
+ </tr>
395
+ </table>
396
+ </div>
397
+
398
+ </div>
399
+
400
+ </div>
401
+
402
+ <div id="footer">
403
+ Generated on Wed Nov 18 18:17:12 2009 by
404
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool">yard</a>
405
+ 0.4.0 (ruby-1.8.7).
406
+ </div>
407
+
408
+ </body>
409
+ </html>