ez_model 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,848 @@
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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: Rmre::Generator
8
+
9
+ &mdash; Documentation by YARD 0.7.5
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ relpath = '..';
19
+ if (relpath != '') relpath += '/';
20
+ </script>
21
+
22
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
25
+
26
+
27
+ </head>
28
+ <body>
29
+ <script type="text/javascript" charset="utf-8">
30
+ if (window.top.frames.main) document.body.className = 'frames';
31
+ </script>
32
+
33
+ <div id="header">
34
+ <div id="menu">
35
+
36
+ <a href="../_index.html">Index (G)</a> &raquo;
37
+ <span class='title'><span class='object_link'><a href="../Rmre.html" title="Rmre (module)">Rmre</a></span></span>
38
+ &raquo;
39
+ <span class="title">Generator</span>
40
+
41
+
42
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
43
+ </div>
44
+
45
+ <div id="search">
46
+
47
+ <a id="class_list_link" href="#">Class List</a>
48
+
49
+ <a id="method_list_link" href="#">Method List</a>
50
+
51
+ <a id="file_list_link" href="#">File List</a>
52
+
53
+ </div>
54
+ <div class="clear"></div>
55
+ </div>
56
+
57
+ <iframe id="search_frame"></iframe>
58
+
59
+ <div id="content"><h1>Class: Rmre::Generator
60
+
61
+
62
+
63
+ </h1>
64
+
65
+ <dl class="box">
66
+
67
+ <dt class="r1">Inherits:</dt>
68
+ <dd class="r1">
69
+ <span class="inheritName">Object</span>
70
+
71
+ <ul class="fullTree">
72
+ <li>Object</li>
73
+
74
+ <li class="next">Rmre::Generator</li>
75
+
76
+ </ul>
77
+ <a href="#" class="inheritanceTree">show all</a>
78
+
79
+ </dd>
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+ <dt class="r2 last">Defined in:</dt>
90
+ <dd class="r2 last">lib/rmre/generator.rb</dd>
91
+
92
+ </dl>
93
+ <div class="clear"></div>
94
+
95
+
96
+ <h2>Constant Summary</h2>
97
+
98
+ <dl class="constants">
99
+
100
+ <dt id="SETTINGS_ROOT-constant" class="">SETTINGS_ROOT =
101
+
102
+ </dt>
103
+ <dd><pre class="code"><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_expand_path'>expand_path</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>../../../../db</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='kw'>__FILE__</span><span class='rparen'>)</span></pre></dd>
104
+
105
+ <dt id="BEGIN_TAG-constant" class="">BEGIN_TAG =
106
+
107
+ </dt>
108
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>##########BEGIN-EZMODEL-AUTO-GENERATED-SECTION##########</span><span class='tstring_end'>&quot;</span></span></pre></dd>
109
+
110
+ <dt id="END_TAG-constant" class="">END_TAG =
111
+
112
+ </dt>
113
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>##########END-EZMODEL-AUTO-GENERATED-SECTION##########</span><span class='tstring_end'>&quot;</span></span></pre></dd>
114
+
115
+ </dl>
116
+
117
+
118
+
119
+
120
+
121
+ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
122
+ <ul class="summary">
123
+
124
+ <li class="public ">
125
+ <span class="summary_signature">
126
+
127
+ <a href="#connection-instance_method" title="#connection (instance method)">- (Object) <strong>connection</strong> </a>
128
+
129
+
130
+
131
+ </span>
132
+
133
+
134
+ <span class="note title readonly">readonly</span>
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+ <span class="summary_desc"><div class='inline'>
144
+ <p>Returns the value of attribute connection.</p>
145
+ </div></span>
146
+
147
+ </li>
148
+
149
+
150
+ <li class="public ">
151
+ <span class="summary_signature">
152
+
153
+ <a href="#output_path-instance_method" title="#output_path (instance method)">- (Object) <strong>output_path</strong> </a>
154
+
155
+
156
+
157
+ </span>
158
+
159
+
160
+ <span class="note title readonly">readonly</span>
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+ <span class="summary_desc"><div class='inline'>
170
+ <p>Returns the value of attribute output_path.</p>
171
+ </div></span>
172
+
173
+ </li>
174
+
175
+
176
+ </ul>
177
+
178
+
179
+
180
+
181
+
182
+ <h2>
183
+ Instance Method Summary
184
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
185
+ </h2>
186
+
187
+ <ul class="summary">
188
+
189
+ <li class="public ">
190
+ <span class="summary_signature">
191
+
192
+ <a href="#connect-instance_method" title="#connect (instance method)">- (Object) <strong>connect</strong> </a>
193
+
194
+
195
+
196
+ </span>
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+ <span class="summary_desc"><div class='inline'></div></span>
206
+
207
+ </li>
208
+
209
+
210
+ <li class="public ">
211
+ <span class="summary_signature">
212
+
213
+ <a href="#create_model-instance_method" title="#create_model (instance method)">- (Object) <strong>create_model</strong>(table_name) </a>
214
+
215
+
216
+
217
+ </span>
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+ <span class="summary_desc"><div class='inline'></div></span>
227
+
228
+ </li>
229
+
230
+
231
+ <li class="public ">
232
+ <span class="summary_signature">
233
+
234
+ <a href="#create_models-instance_method" title="#create_models (instance method)">- (Object) <strong>create_models</strong>(tables) </a>
235
+
236
+
237
+
238
+ </span>
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+ <span class="summary_desc"><div class='inline'></div></span>
248
+
249
+ </li>
250
+
251
+
252
+ <li class="public ">
253
+ <span class="summary_signature">
254
+
255
+ <a href="#dump_schema-instance_method" title="#dump_schema (instance method)">- (Object) <strong>dump_schema</strong>(stream) </a>
256
+
257
+
258
+
259
+ </span>
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+ <span class="summary_desc"><div class='inline'></div></span>
269
+
270
+ </li>
271
+
272
+
273
+ <li class="public ">
274
+ <span class="summary_signature">
275
+
276
+ <a href="#foreign_keys-instance_method" title="#foreign_keys (instance method)">- (Object) <strong>foreign_keys</strong> </a>
277
+
278
+
279
+
280
+ </span>
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+ <span class="summary_desc"><div class='inline'></div></span>
290
+
291
+ </li>
292
+
293
+
294
+ <li class="public ">
295
+ <span class="summary_signature">
296
+
297
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (Generator) <strong>initialize</strong>(options, out_path, include) </a>
298
+
299
+
300
+
301
+ </span>
302
+
303
+ <span class="note title constructor">constructor</span>
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+ <span class="summary_desc"><div class='inline'>
313
+ <p>A new instance of Generator.</p>
314
+ </div></span>
315
+
316
+ </li>
317
+
318
+
319
+ <li class="public ">
320
+ <span class="summary_signature">
321
+
322
+ <a href="#process%3F-instance_method" title="#process? (instance method)">- (Boolean) <strong>process?</strong>(table_name) </a>
323
+
324
+
325
+
326
+ </span>
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+
335
+ <span class="summary_desc"><div class='inline'></div></span>
336
+
337
+ </li>
338
+
339
+
340
+ </ul>
341
+
342
+
343
+ <div id="constructor_details" class="method_details_list">
344
+ <h2>Constructor Details</h2>
345
+
346
+ <div class="method_details first">
347
+ <p class="signature first" id="initialize-instance_method">
348
+
349
+ - (<tt><span class='object_link'><a href="" title="Rmre::Generator (class)">Generator</a></span></tt>) <strong>initialize</strong>(options, out_path, include)
350
+
351
+
352
+
353
+ </p><div class="docstring">
354
+ <div class="discussion">
355
+
356
+ <p>A new instance of Generator</p>
357
+
358
+
359
+ </div>
360
+ </div>
361
+ <div class="tags">
362
+
363
+
364
+ </div><table class="source_code">
365
+ <tr>
366
+ <td>
367
+ <pre class="lines">
368
+
369
+
370
+ 16
371
+ 17
372
+ 18
373
+ 19
374
+ 20
375
+ 21</pre>
376
+ </td>
377
+ <td>
378
+ <pre class="code"><span class="info file"># File 'lib/rmre/generator.rb', line 16</span>
379
+
380
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='id identifier rubyid_out_path'>out_path</span><span class='comma'>,</span> <span class='id identifier rubyid_include'>include</span><span class='rparen'>)</span>
381
+ <span class='ivar'>@connection_options</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span>
382
+ <span class='ivar'>@connection</span> <span class='op'>=</span> <span class='kw'>nil</span>
383
+ <span class='ivar'>@output_path</span> <span class='op'>=</span> <span class='id identifier rubyid_out_path'>out_path</span>
384
+ <span class='ivar'>@include_prefixes</span> <span class='op'>=</span> <span class='id identifier rubyid_include'>include</span>
385
+ <span class='kw'>end</span></pre>
386
+ </td>
387
+ </tr>
388
+ </table>
389
+ </div>
390
+
391
+ </div>
392
+
393
+ <div id="instance_attr_details" class="attr_details">
394
+ <h2>Instance Attribute Details</h2>
395
+
396
+
397
+ <span id=""></span>
398
+ <span id="connection-instance_method"></span>
399
+ <div class="method_details first">
400
+ <p class="signature first" id="connection-instance_method">
401
+
402
+ - (<tt>Object</tt>) <strong>connection</strong> <span class="extras">(readonly)</span>
403
+
404
+
405
+
406
+ </p><div class="docstring">
407
+ <div class="discussion">
408
+
409
+ <p>Returns the value of attribute connection</p>
410
+
411
+
412
+ </div>
413
+ </div>
414
+ <div class="tags">
415
+
416
+
417
+ </div><table class="source_code">
418
+ <tr>
419
+ <td>
420
+ <pre class="lines">
421
+
422
+
423
+ 8
424
+ 9
425
+ 10</pre>
426
+ </td>
427
+ <td>
428
+ <pre class="code"><span class="info file"># File 'lib/rmre/generator.rb', line 8</span>
429
+
430
+ <span class='kw'>def</span> <span class='id identifier rubyid_connection'>connection</span>
431
+ <span class='ivar'>@connection</span>
432
+ <span class='kw'>end</span></pre>
433
+ </td>
434
+ </tr>
435
+ </table>
436
+ </div>
437
+
438
+
439
+ <span id=""></span>
440
+ <span id="output_path-instance_method"></span>
441
+ <div class="method_details ">
442
+ <p class="signature " id="output_path-instance_method">
443
+
444
+ - (<tt>Object</tt>) <strong>output_path</strong> <span class="extras">(readonly)</span>
445
+
446
+
447
+
448
+ </p><div class="docstring">
449
+ <div class="discussion">
450
+
451
+ <p>Returns the value of attribute output_path</p>
452
+
453
+
454
+ </div>
455
+ </div>
456
+ <div class="tags">
457
+
458
+
459
+ </div><table class="source_code">
460
+ <tr>
461
+ <td>
462
+ <pre class="lines">
463
+
464
+
465
+ 9
466
+ 10
467
+ 11</pre>
468
+ </td>
469
+ <td>
470
+ <pre class="code"><span class="info file"># File 'lib/rmre/generator.rb', line 9</span>
471
+
472
+ <span class='kw'>def</span> <span class='id identifier rubyid_output_path'>output_path</span>
473
+ <span class='ivar'>@output_path</span>
474
+ <span class='kw'>end</span></pre>
475
+ </td>
476
+ </tr>
477
+ </table>
478
+ </div>
479
+
480
+ </div>
481
+
482
+
483
+ <div id="instance_method_details" class="method_details_list">
484
+ <h2>Instance Method Details</h2>
485
+
486
+
487
+ <div class="method_details first">
488
+ <p class="signature first" id="connect-instance_method">
489
+
490
+ - (<tt>Object</tt>) <strong>connect</strong>
491
+
492
+
493
+
494
+ </p><table class="source_code">
495
+ <tr>
496
+ <td>
497
+ <pre class="lines">
498
+
499
+
500
+ 23
501
+ 24
502
+ 25
503
+ 26
504
+ 27
505
+ 28</pre>
506
+ </td>
507
+ <td>
508
+ <pre class="code"><span class="info file"># File 'lib/rmre/generator.rb', line 23</span>
509
+
510
+ <span class='kw'>def</span> <span class='id identifier rubyid_connect'>connect</span>
511
+ <span class='kw'>return</span> <span class='kw'>if</span> <span class='ivar'>@connection_options</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
512
+
513
+ <span class='const'>ActiveRecord</span><span class='op'>::</span><span class='const'>Base</span><span class='period'>.</span><span class='id identifier rubyid_establish_connection'>establish_connection</span><span class='lparen'>(</span><span class='ivar'>@connection_options</span><span class='rparen'>)</span>
514
+ <span class='ivar'>@connection</span> <span class='op'>=</span> <span class='const'>ActiveRecord</span><span class='op'>::</span><span class='const'>Base</span><span class='period'>.</span><span class='id identifier rubyid_connection'>connection</span>
515
+ <span class='kw'>end</span></pre>
516
+ </td>
517
+ </tr>
518
+ </table>
519
+ </div>
520
+
521
+ <div class="method_details ">
522
+ <p class="signature " id="create_model-instance_method">
523
+
524
+ - (<tt>Object</tt>) <strong>create_model</strong>(table_name)
525
+
526
+
527
+
528
+ </p><table class="source_code">
529
+ <tr>
530
+ <td>
531
+ <pre class="lines">
532
+
533
+
534
+ 44
535
+ 45
536
+ 46
537
+ 47
538
+ 48
539
+ 49
540
+ 50
541
+ 51
542
+ 52
543
+ 53
544
+ 54
545
+ 55
546
+ 56
547
+ 57
548
+ 58
549
+ 59
550
+ 60
551
+ 61
552
+ 62
553
+ 63
554
+ 64
555
+ 65
556
+ 66
557
+ 67
558
+ 68
559
+ 69
560
+ 70
561
+ 71
562
+ 72
563
+ 73
564
+ 74
565
+ 75
566
+ 76
567
+ 77
568
+ 78
569
+ 79
570
+ 80
571
+ 81
572
+ 82
573
+ 83
574
+ 84
575
+ 85
576
+ 86
577
+ 87
578
+ 88
579
+ 89
580
+ 90
581
+ 91
582
+ 92
583
+ 93
584
+ 94
585
+ 95
586
+ 96
587
+ 97
588
+ 98
589
+ 99
590
+ 100
591
+ 101
592
+ 102
593
+ 103
594
+ 104
595
+ 105
596
+ 106
597
+ 107
598
+ 108
599
+ 109
600
+ 110
601
+ 111</pre>
602
+ </td>
603
+ <td>
604
+ <pre class="code"><span class="info file"># File 'lib/rmre/generator.rb', line 44</span>
605
+
606
+ <span class='kw'>def</span> <span class='id identifier rubyid_create_model'>create_model</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
607
+ <span class='id identifier rubyid_constraints'>constraints</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
608
+
609
+ <span class='id identifier rubyid_foreign_keys'>foreign_keys</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_fk'>fk</span><span class='op'>|</span>
610
+ <span class='id identifier rubyid_src'>src</span> <span class='op'>=</span> <span class='id identifier rubyid_constraint_src'>constraint_src</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_fk'>fk</span><span class='rparen'>)</span>
611
+ <span class='id identifier rubyid_constraints'>constraints</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_src'>src</span> <span class='kw'>unless</span> <span class='id identifier rubyid_src'>src</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
612
+ <span class='kw'>end</span>
613
+
614
+ <span class='id identifier rubyid__file_path'>_file_path</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='id identifier rubyid_output_path'>output_path</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_table_name'>table_name</span><span class='period'>.</span><span class='id identifier rubyid_tableize'>tableize</span><span class='period'>.</span><span class='id identifier rubyid_singularize'>singularize</span><span class='rbrace'>}</span><span class='tstring_content'>.rb</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
615
+ <span class='kw'>if</span> <span class='lparen'>(</span><span class='op'>!</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_exists?'>exists?</span><span class='lparen'>(</span><span class='id identifier rubyid__file_path'>_file_path</span><span class='rparen'>)</span><span class='rparen'>)</span>
616
+ <span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='id identifier rubyid_generate_model_source'>generate_model_source</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_constraints'>constraints</span><span class='rparen'>)</span>
617
+ <span class='kw'>else</span>
618
+
619
+ <span class='comment'># read file content
620
+ </span> <span class='id identifier rubyid_file'>file</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid__file_path'>_file_path</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>r+</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
621
+ <span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span>
622
+ <span class='id identifier rubyid_line_begin'>line_begin</span> <span class='op'>=</span> <span class='op'>-</span><span class='int'>1</span>
623
+ <span class='id identifier rubyid_line_end'>line_end</span> <span class='op'>=</span> <span class='op'>-</span><span class='int'>1</span>
624
+ <span class='id identifier rubyid_i'>i</span> <span class='op'>=</span> <span class='op'>-</span><span class='int'>1</span>
625
+ <span class='kw'>while</span> <span class='lparen'>(</span><span class='op'>!</span><span class='id identifier rubyid_file'>file</span><span class='period'>.</span><span class='id identifier rubyid_eof?'>eof?</span><span class='rparen'>)</span>
626
+ <span class='id identifier rubyid_i'>i</span> <span class='op'>=</span> <span class='id identifier rubyid_i'>i</span><span class='op'>+</span><span class='int'>1</span>
627
+ <span class='id identifier rubyid__line'>_line</span> <span class='op'>=</span> <span class='id identifier rubyid_file'>file</span><span class='period'>.</span><span class='id identifier rubyid_readline'>readline</span>
628
+
629
+ <span class='comment'># remove old code
630
+ </span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid__line'>_line</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='period'>.</span><span class='id identifier rubyid_tableize'>tableize</span><span class='period'>.</span><span class='id identifier rubyid_classify'>classify</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span>
631
+ <span class='id identifier rubyid__line'>_line</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>EZModel::ActiveRecord</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
632
+ <span class='id identifier rubyid__line'>_line</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>class </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_table_name'>table_name</span><span class='period'>.</span><span class='id identifier rubyid_tableize'>tableize</span><span class='period'>.</span><span class='id identifier rubyid_classify'>classify</span><span class='rbrace'>}</span><span class='tstring_content'> &lt; ActiveRecord::Base \n</span><span class='tstring_end'>&quot;</span></span>
633
+ <span class='kw'>end</span>
634
+
635
+ <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid__line'>_line</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='const'>BEGIN_TAG</span><span class='rparen'>)</span><span class='rparen'>)</span>
636
+ <span class='id identifier rubyid_line_begin'>line_begin</span> <span class='op'>=</span> <span class='id identifier rubyid_i'>i</span>
637
+ <span class='kw'>end</span>
638
+ <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid__line'>_line</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='const'>END_TAG</span><span class='rparen'>)</span><span class='rparen'>)</span>
639
+ <span class='id identifier rubyid_line_end'>line_end</span> <span class='op'>=</span> <span class='id identifier rubyid_i'>i</span>
640
+ <span class='kw'>end</span>
641
+
642
+ <span class='id identifier rubyid_content'>content</span> <span class='op'>+=</span> <span class='id identifier rubyid__line'>_line</span>
643
+ <span class='kw'>end</span>
644
+ <span class='id identifier rubyid_file'>file</span><span class='period'>.</span><span class='id identifier rubyid_close'>close</span><span class='lparen'>(</span><span class='rparen'>)</span>
645
+
646
+ <span class='comment'># remove auto generated code
647
+ </span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_line_begin'>line_begin</span><span class='op'>&lt;</span><span class='id identifier rubyid_line_end'>line_end</span><span class='rparen'>)</span>
648
+ <span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='embexpr_beg'>#{</span><span class='const'>BEGIN_TAG</span><span class='rbrace'>}</span><span class='tstring_content'>(.*)</span><span class='embexpr_beg'>#{</span><span class='const'>END_TAG</span><span class='rbrace'>}</span><span class='regexp_end'>/im</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
649
+ <span class='kw'>end</span>
650
+
651
+ <span class='id identifier rubyid__text'>_text</span> <span class='op'>=</span> <span class='id identifier rubyid_content'>content</span>
652
+ <span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span>
653
+ <span class='id identifier rubyid__text'>_text</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid__line'>_line</span><span class='op'>|</span>
654
+
655
+ <span class='comment'># remove include header from old version
656
+ </span> <span class='kw'>unless</span> <span class='lparen'>(</span><span class='id identifier rubyid__line'>_line</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>require File.expand_path('../ez_models</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
657
+ <span class='id identifier rubyid_content'>content</span> <span class='op'>+=</span> <span class='id identifier rubyid__line'>_line</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</span></span>
658
+ <span class='kw'>end</span>
659
+
660
+ <span class='comment'># add auto-gen code below class
661
+ </span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid__line'>_line</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='period'>.</span><span class='id identifier rubyid_tableize'>tableize</span><span class='period'>.</span><span class='id identifier rubyid_classify'>classify</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span>
662
+ <span class='id identifier rubyid__line'>_line</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>ActiveRecord::Base</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
663
+ <span class='id identifier rubyid__body'>_body</span> <span class='op'>=</span> <span class='id identifier rubyid_generate_model_content'>generate_model_content</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_constraints'>constraints</span><span class='rparen'>)</span>
664
+ <span class='id identifier rubyid_content'>content</span> <span class='op'>+=</span> <span class='id identifier rubyid__body'>_body</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</span></span>
665
+ <span class='kw'>end</span>
666
+ <span class='kw'>end</span>
667
+ <span class='kw'>end</span>
668
+
669
+ <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid__file_path'>_file_path</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>w</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_file'>file</span><span class='op'>|</span>
670
+ <span class='id identifier rubyid_file'>file</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='rparen'>)</span>
671
+ <span class='kw'>end</span>
672
+
673
+ <span class='kw'>end</span></pre>
674
+ </td>
675
+ </tr>
676
+ </table>
677
+ </div>
678
+
679
+ <div class="method_details ">
680
+ <p class="signature " id="create_models-instance_method">
681
+
682
+ - (<tt>Object</tt>) <strong>create_models</strong>(tables)
683
+
684
+
685
+
686
+ </p><table class="source_code">
687
+ <tr>
688
+ <td>
689
+ <pre class="lines">
690
+
691
+
692
+ 30
693
+ 31
694
+ 32
695
+ 33
696
+ 34
697
+ 35
698
+ 36
699
+ 37
700
+ 38</pre>
701
+ </td>
702
+ <td>
703
+ <pre class="code"><span class="info file"># File 'lib/rmre/generator.rb', line 30</span>
704
+
705
+ <span class='kw'>def</span> <span class='id identifier rubyid_create_models'>create_models</span><span class='lparen'>(</span><span class='id identifier rubyid_tables'>tables</span><span class='rparen'>)</span>
706
+ <span class='kw'>return</span> <span class='kw'>unless</span> <span class='id identifier rubyid_tables'>tables</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Array</span>
707
+
708
+ <span class='const'>FileUtils</span><span class='period'>.</span><span class='id identifier rubyid_mkdir_p'>mkdir_p</span><span class='lparen'>(</span><span class='ivar'>@output_path</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='const'>Dir</span><span class='period'>.</span><span class='id identifier rubyid_exists?'>exists?</span><span class='lparen'>(</span><span class='ivar'>@output_path</span><span class='rparen'>)</span>
709
+
710
+ <span class='id identifier rubyid_tables'>tables</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_table_name'>table_name</span><span class='op'>|</span>
711
+ <span class='id identifier rubyid_create_model'>create_model</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_process?'>process?</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
712
+ <span class='kw'>end</span>
713
+ <span class='kw'>end</span></pre>
714
+ </td>
715
+ </tr>
716
+ </table>
717
+ </div>
718
+
719
+ <div class="method_details ">
720
+ <p class="signature " id="dump_schema-instance_method">
721
+
722
+ - (<tt>Object</tt>) <strong>dump_schema</strong>(stream)
723
+
724
+
725
+
726
+ </p><table class="source_code">
727
+ <tr>
728
+ <td>
729
+ <pre class="lines">
730
+
731
+
732
+ 40
733
+ 41
734
+ 42</pre>
735
+ </td>
736
+ <td>
737
+ <pre class="code"><span class="info file"># File 'lib/rmre/generator.rb', line 40</span>
738
+
739
+ <span class='kw'>def</span> <span class='id identifier rubyid_dump_schema'>dump_schema</span><span class='lparen'>(</span><span class='id identifier rubyid_stream'>stream</span><span class='rparen'>)</span>
740
+ <span class='const'>ActiveRecord</span><span class='op'>::</span><span class='const'>SchemaDumper</span><span class='period'>.</span><span class='id identifier rubyid_dump_with_fk'>dump_with_fk</span><span class='lparen'>(</span><span class='id identifier rubyid_connection'>connection</span><span class='comma'>,</span> <span class='id identifier rubyid_foreign_keys'>foreign_keys</span><span class='comma'>,</span> <span class='id identifier rubyid_stream'>stream</span><span class='rparen'>)</span>
741
+ <span class='kw'>end</span></pre>
742
+ </td>
743
+ </tr>
744
+ </table>
745
+ </div>
746
+
747
+ <div class="method_details ">
748
+ <p class="signature " id="foreign_keys-instance_method">
749
+
750
+ - (<tt>Object</tt>) <strong>foreign_keys</strong>
751
+
752
+
753
+
754
+ </p><table class="source_code">
755
+ <tr>
756
+ <td>
757
+ <pre class="lines">
758
+
759
+
760
+ 123
761
+ 124
762
+ 125</pre>
763
+ </td>
764
+ <td>
765
+ <pre class="code"><span class="info file"># File 'lib/rmre/generator.rb', line 123</span>
766
+
767
+ <span class='kw'>def</span> <span class='id identifier rubyid_foreign_keys'>foreign_keys</span>
768
+ <span class='ivar'>@foreign_keys</span> <span class='op'>||=</span> <span class='id identifier rubyid_fetch_foreign_keys'>fetch_foreign_keys</span>
769
+ <span class='kw'>end</span></pre>
770
+ </td>
771
+ </tr>
772
+ </table>
773
+ </div>
774
+
775
+ <div class="method_details ">
776
+ <p class="signature " id="process?-instance_method">
777
+
778
+ - (<tt>Boolean</tt>) <strong>process?</strong>(table_name)
779
+
780
+
781
+
782
+ </p><div class="docstring">
783
+ <div class="discussion">
784
+
785
+
786
+ </div>
787
+ </div>
788
+ <div class="tags">
789
+
790
+ <h3>Returns:</h3>
791
+ <ul class="return">
792
+
793
+ <li>
794
+
795
+
796
+ <span class='type'>(<tt>Boolean</tt>)</span>
797
+
798
+
799
+
800
+ </li>
801
+
802
+ </ul>
803
+
804
+ </div><table class="source_code">
805
+ <tr>
806
+ <td>
807
+ <pre class="lines">
808
+
809
+
810
+ 113
811
+ 114
812
+ 115
813
+ 116
814
+ 117
815
+ 118
816
+ 119
817
+ 120
818
+ 121</pre>
819
+ </td>
820
+ <td>
821
+ <pre class="code"><span class="info file"># File 'lib/rmre/generator.rb', line 113</span>
822
+
823
+ <span class='kw'>def</span> <span class='id identifier rubyid_process?'>process?</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
824
+ <span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='ivar'>@include_prefixes</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>||</span> <span class='ivar'>@include_prefixes</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
825
+
826
+ <span class='ivar'>@include_prefixes</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_prefix'>prefix</span><span class='op'>|</span>
827
+ <span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='id identifier rubyid_table_name'>table_name</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_prefix'>prefix</span><span class='rbrace'>}</span><span class='regexp_end'>/</span></span>
828
+ <span class='kw'>end</span>
829
+
830
+ <span class='kw'>false</span>
831
+ <span class='kw'>end</span></pre>
832
+ </td>
833
+ </tr>
834
+ </table>
835
+ </div>
836
+
837
+ </div>
838
+
839
+ </div>
840
+
841
+ <div id="footer">
842
+ Generated on Sun Apr 22 17:28:29 2012 by
843
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
844
+ 0.7.5 (ruby-1.9.3).
845
+ </div>
846
+
847
+ </body>
848
+ </html>