genosaurus 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -69,6 +69,9 @@ Now you should end up with the following:
69
69
 
70
70
  In the ComplexGenerator we told Genosaurus that we are requiring that the parameter, name, be passed into it. We are then using that parameter to generate the names of some files and folders. Pretty cool, eh? See how simple that is.
71
71
 
72
+ ===Explicit Manifests
73
+ Explicit manifests are used when there is a manifest.yml supplied at the same level as the generator. If there is a manifest.yml file then implied manifests are not used. This means you have to define the entire generation process. This is great if you have a pretty complicated generator, as the manifest.yml is also sent through ERB before being loaded.
74
+
72
75
  Let's look at the manifest.yml file for our simple_generator example:
73
76
 
74
77
  template_1:
@@ -99,9 +102,6 @@ Our manifest.yml file would look like this:
99
102
 
100
103
  This will generate the exact same thing as our implied manifest.
101
104
 
102
- ===Explicit Manifests
103
- Explicit manifests are used when there is a manifest.yml supplied at the same level as the generator. If there is a manifest.yml file then implied manifests are not used. This means you have to define the entire generation process. This is great if you have a pretty complicated generator, as the manifest.yml is also sent through ERB before being loaded.
104
-
105
105
  ==Contact
106
106
  Please mail bugs, suggestions and patches to <bugs@mackframework.com>.
107
107
 
@@ -88,11 +88,12 @@
88
88
  <div class="name-list">
89
89
  <a href="#M000007">after_generate</a>&nbsp;&nbsp;
90
90
  <a href="#M000006">before_generate</a>&nbsp;&nbsp;
91
+ <a href="#M000014">copy</a>&nbsp;&nbsp;
91
92
  <a href="#M000013">directory</a>&nbsp;&nbsp;
92
- <a href="#M000014">generate</a>&nbsp;&nbsp;
93
+ <a href="#M000015">generate</a>&nbsp;&nbsp;
93
94
  <a href="#M000008">manifest</a>&nbsp;&nbsp;
94
95
  <a href="#M000004">manifest_path</a>&nbsp;&nbsp;
95
- <a href="#M000015">method_missing</a>&nbsp;&nbsp;
96
+ <a href="#M000016">method_missing</a>&nbsp;&nbsp;
96
97
  <a href="#M000002">new</a>&nbsp;&nbsp;
97
98
  <a href="#M000011">param</a>&nbsp;&nbsp;
98
99
  <a href="#M000009">require_param</a>&nbsp;&nbsp;
@@ -239,7 +240,7 @@ Returns the <a href="Genosaurus.html#M000010">required_params</a> array.
239
240
  <p>
240
241
  Instantiates a <a href="Genosaurus.html#M000002">new</a> <a
241
242
  href="Genosaurus.html">Genosaurus</a>, passing the ENV hash as options into
242
- it, runs the <a href="Genosaurus.html#M000014">generate</a> method, and
243
+ it, runs the <a href="Genosaurus.html#M000015">generate</a> method, and
243
244
  returns the <a href="Genosaurus.html">Genosaurus</a> object.
244
245
  </p>
245
246
  <p><a class="source-toggle" href="#"
@@ -271,7 +272,7 @@ returns the <a href="Genosaurus.html">Genosaurus</a> object.
271
272
  <div class="method-description">
272
273
  <p>
273
274
  To be overridden in subclasses to do work after the <a
274
- href="Genosaurus.html#M000014">generate</a> method is <a
275
+ href="Genosaurus.html#M000015">generate</a> method is <a
275
276
  href="Genosaurus.html#M000001">run</a>. This is a simple way to call other
276
277
  generators.
277
278
  </p>
@@ -299,7 +300,7 @@ generators.
299
300
  <div class="method-description">
300
301
  <p>
301
302
  To be overridden in subclasses to do work before the <a
302
- href="Genosaurus.html#M000014">generate</a> method is <a
303
+ href="Genosaurus.html#M000015">generate</a> method is <a
303
304
  href="Genosaurus.html#M000001">run</a>.
304
305
  </p>
305
306
  <p><a class="source-toggle" href="#"
@@ -314,6 +315,31 @@ href="Genosaurus.html#M000001">run</a>.
314
315
  </div>
315
316
  </div>
316
317
 
318
+ <div id="method-M000014" class="method-detail">
319
+ <a name="M000014"></a>
320
+
321
+ <div class="method-heading">
322
+ <a href="#M000014" class="method-signature">
323
+ <span class="method-name">copy</span><span class="method-args">(input_file, output_file, options = @options)</span>
324
+ </a>
325
+ </div>
326
+
327
+ <div class="method-description">
328
+ <p><a class="source-toggle" href="#"
329
+ onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
330
+ <div class="method-source-code" id="M000014-source">
331
+ <pre>
332
+ <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 141</span>
333
+ 141: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">copy</span>(<span class="ruby-identifier">input_file</span>, <span class="ruby-identifier">output_file</span>, <span class="ruby-identifier">options</span> = <span class="ruby-ivar">@options</span>)
334
+ 142: <span class="ruby-identifier">output_file</span> = <span class="ruby-identifier">template_copy_common</span>(<span class="ruby-identifier">output_file</span>, <span class="ruby-identifier">options</span>)
335
+ 143: <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp</span>(<span class="ruby-identifier">input_file</span>, <span class="ruby-identifier">output_file</span>)
336
+ 144: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Copied: #{output_file}&quot;</span>
337
+ 145: <span class="ruby-keyword kw">end</span>
338
+ </pre>
339
+ </div>
340
+ </div>
341
+ </div>
342
+
317
343
  <div id="method-M000013" class="method-detail">
318
344
  <a name="M000013"></a>
319
345
 
@@ -331,28 +357,28 @@ Creates the specified <a href="Genosaurus.html#M000013">directory</a>.
331
357
  onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
332
358
  <div class="method-source-code" id="M000013-source">
333
359
  <pre>
334
- <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 141</span>
335
- 141: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">directory</span>(<span class="ruby-identifier">output_dir</span>, <span class="ruby-identifier">options</span> = <span class="ruby-ivar">@options</span>)
336
- 142: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$genosaurus_output_directory</span>
337
- 143: <span class="ruby-identifier">output_dir</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">$genosaurus_output_directory</span>, <span class="ruby-identifier">output_dir</span>)
338
- 144: <span class="ruby-keyword kw">end</span>
339
- 145: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">output_dir</span>)
340
- 146: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Exists: #{output_dir}&quot;</span>
341
- 147: <span class="ruby-keyword kw">return</span>
342
- 148: <span class="ruby-keyword kw">end</span>
343
- 149: <span class="ruby-identifier">mkdir_p</span>(<span class="ruby-identifier">output_dir</span>)
344
- 150: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Created: #{output_dir}&quot;</span>
345
- 151: <span class="ruby-keyword kw">end</span>
360
+ <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 129</span>
361
+ 129: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">directory</span>(<span class="ruby-identifier">output_dir</span>, <span class="ruby-identifier">options</span> = <span class="ruby-ivar">@options</span>)
362
+ 130: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$genosaurus_output_directory</span>
363
+ 131: <span class="ruby-identifier">output_dir</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">$genosaurus_output_directory</span>, <span class="ruby-identifier">output_dir</span>)
364
+ 132: <span class="ruby-keyword kw">end</span>
365
+ 133: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">output_dir</span>)
366
+ 134: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Exists: #{output_dir}&quot;</span>
367
+ 135: <span class="ruby-keyword kw">return</span>
368
+ 136: <span class="ruby-keyword kw">end</span>
369
+ 137: <span class="ruby-identifier">mkdir_p</span>(<span class="ruby-identifier">output_dir</span>)
370
+ 138: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Created: #{output_dir}&quot;</span>
371
+ 139: <span class="ruby-keyword kw">end</span>
346
372
  </pre>
347
373
  </div>
348
374
  </div>
349
375
  </div>
350
376
 
351
- <div id="method-M000014" class="method-detail">
352
- <a name="M000014"></a>
377
+ <div id="method-M000015" class="method-detail">
378
+ <a name="M000015"></a>
353
379
 
354
380
  <div class="method-heading">
355
- <a href="#M000014" class="method-signature">
381
+ <a href="#M000015" class="method-signature">
356
382
  <span class="method-name">generate</span><span class="method-args">()</span>
357
383
  </a>
358
384
  </div>
@@ -362,24 +388,26 @@ Creates the specified <a href="Genosaurus.html#M000013">directory</a>.
362
388
  This does the dirty work of generation.
363
389
  </p>
364
390
  <p><a class="source-toggle" href="#"
365
- onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
366
- <div class="method-source-code" id="M000014-source">
391
+ onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
392
+ <div class="method-source-code" id="M000015-source">
367
393
  <pre>
368
- <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 154</span>
369
- 154: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">generate</span>
370
- 155: <span class="ruby-identifier">generate_callbacks</span> <span class="ruby-keyword kw">do</span>
371
- 156: <span class="ruby-identifier">manifest</span>.<span class="ruby-identifier">each_value</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">info</span><span class="ruby-operator">|</span>
372
- 157: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">info</span>[<span class="ruby-value str">&quot;type&quot;</span>]
373
- 158: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;file&quot;</span>
374
- 159: <span class="ruby-identifier">template</span>(<span class="ruby-identifier">info</span>[<span class="ruby-value str">&quot;template_path&quot;</span>], <span class="ruby-identifier">info</span>[<span class="ruby-value str">&quot;output_path&quot;</span>])
375
- 160: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;directory&quot;</span>
376
- 161: <span class="ruby-identifier">directory</span>(<span class="ruby-identifier">info</span>[<span class="ruby-value str">&quot;output_path&quot;</span>])
377
- 162: <span class="ruby-keyword kw">else</span>
378
- 163: <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unknown 'type': #{info[&quot;type&quot;]}!&quot;</span>
379
- 164: <span class="ruby-keyword kw">end</span>
380
- 165: <span class="ruby-keyword kw">end</span>
381
- 166: <span class="ruby-keyword kw">end</span>
382
- 167: <span class="ruby-keyword kw">end</span>
394
+ <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 148</span>
395
+ 148: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">generate</span>
396
+ 149: <span class="ruby-identifier">generate_callbacks</span> <span class="ruby-keyword kw">do</span>
397
+ 150: <span class="ruby-identifier">manifest</span>.<span class="ruby-identifier">each_value</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">info</span><span class="ruby-operator">|</span>
398
+ 151: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">info</span>[<span class="ruby-value str">&quot;type&quot;</span>]
399
+ 152: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;file&quot;</span>
400
+ 153: <span class="ruby-identifier">template</span>(<span class="ruby-identifier">info</span>[<span class="ruby-value str">&quot;template_path&quot;</span>], <span class="ruby-identifier">info</span>[<span class="ruby-value str">&quot;output_path&quot;</span>])
401
+ 154: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;directory&quot;</span>
402
+ 155: <span class="ruby-identifier">directory</span>(<span class="ruby-identifier">info</span>[<span class="ruby-value str">&quot;output_path&quot;</span>])
403
+ 156: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;copy&quot;</span>
404
+ 157: <span class="ruby-identifier">copy</span>(<span class="ruby-identifier">info</span>[<span class="ruby-value str">&quot;template_path&quot;</span>], <span class="ruby-identifier">info</span>[<span class="ruby-value str">&quot;output_path&quot;</span>])
405
+ 158: <span class="ruby-keyword kw">else</span>
406
+ 159: <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unknown 'type': #{info[&quot;type&quot;]}!&quot;</span>
407
+ 160: <span class="ruby-keyword kw">end</span>
408
+ 161: <span class="ruby-keyword kw">end</span>
409
+ 162: <span class="ruby-keyword kw">end</span>
410
+ 163: <span class="ruby-keyword kw">end</span>
383
411
  </pre>
384
412
  </div>
385
413
  </div>
@@ -398,7 +426,7 @@ This does the dirty work of generation.
398
426
  <p>
399
427
  Returns the <a href="Genosaurus.html#M000008">manifest</a> for this
400
428
  generator, which is used by the <a
401
- href="Genosaurus.html#M000014">generate</a> method to do the dirty work. If
429
+ href="Genosaurus.html#M000015">generate</a> method to do the dirty work. If
402
430
  there is a manifest.yml, defined by the <a
403
431
  href="Genosaurus.html#M000004">manifest_path</a> method, then the contents
404
432
  of that file are processed with ERB and returned. If there is not
@@ -473,26 +501,26 @@ return the correct path.
473
501
  </div>
474
502
  </div>
475
503
 
476
- <div id="method-M000015" class="method-detail">
477
- <a name="M000015"></a>
504
+ <div id="method-M000016" class="method-detail">
505
+ <a name="M000016"></a>
478
506
 
479
507
  <div class="method-heading">
480
- <a href="#M000015" class="method-signature">
508
+ <a href="#M000016" class="method-signature">
481
509
  <span class="method-name">method_missing</span><span class="method-args">(sym, *args)</span>
482
510
  </a>
483
511
  </div>
484
512
 
485
513
  <div class="method-description">
486
514
  <p><a class="source-toggle" href="#"
487
- onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
488
- <div class="method-source-code" id="M000015-source">
515
+ onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
516
+ <div class="method-source-code" id="M000016-source">
489
517
  <pre>
490
- <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 169</span>
491
- 169: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
492
- 170: <span class="ruby-identifier">p</span> = <span class="ruby-identifier">param</span>(<span class="ruby-identifier">sym</span>)
493
- 171: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">p</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">p</span>
494
- 172: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NoMethodError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">sym</span>)
495
- 173: <span class="ruby-keyword kw">end</span>
518
+ <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 165</span>
519
+ 165: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
520
+ 166: <span class="ruby-identifier">p</span> = <span class="ruby-identifier">param</span>(<span class="ruby-identifier">sym</span>)
521
+ 167: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">p</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">p</span>
522
+ 168: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NoMethodError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">sym</span>)
523
+ 169: <span class="ruby-keyword kw">end</span>
496
524
  </pre>
497
525
  </div>
498
526
  </div>
@@ -572,22 +600,10 @@ like to force the writing of the file, use the :force =&gt; true option.
572
600
  <pre>
573
601
  <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 122</span>
574
602
  122: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">template</span>(<span class="ruby-identifier">input_file</span>, <span class="ruby-identifier">output_file</span>, <span class="ruby-identifier">options</span> = <span class="ruby-ivar">@options</span>)
575
- 123: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">output_file</span>)
576
- 124: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:force</span>]
577
- 125: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Skipped: #{output_file}&quot;</span>
578
- 126: <span class="ruby-keyword kw">return</span>
579
- 127: <span class="ruby-keyword kw">end</span>
580
- 128: <span class="ruby-keyword kw">end</span>
581
- 129: <span class="ruby-comment cmt"># incase the directory doesn't exist, let's create it.</span>
582
- 130: <span class="ruby-identifier">directory</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">output_file</span>))
583
- 131: <span class="ruby-comment cmt"># puts &quot;input_file: #{input_file}&quot;</span>
584
- 132: <span class="ruby-comment cmt"># puts &quot;output_file: #{output_file}&quot;</span>
585
- 133: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$genosaurus_output_directory</span>
586
- 134: <span class="ruby-identifier">output_file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">$genosaurus_output_directory</span>, <span class="ruby-identifier">output_file</span>)
587
- 135: <span class="ruby-keyword kw">end</span>
588
- 136: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">output_file</span>, <span class="ruby-value str">&quot;w&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">puts</span> <span class="ruby-constant">ERB</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">input_file</span>).<span class="ruby-identifier">read</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-value str">&quot;-&gt;&quot;</span>).<span class="ruby-identifier">result</span>(<span class="ruby-identifier">binding</span>)}
589
- 137: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Wrote: #{output_file}&quot;</span>
590
- 138: <span class="ruby-keyword kw">end</span>
603
+ 123: <span class="ruby-identifier">output_file</span> = <span class="ruby-identifier">template_copy_common</span>(<span class="ruby-identifier">output_file</span>, <span class="ruby-identifier">options</span>)
604
+ 124: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">output_file</span>, <span class="ruby-value str">&quot;w&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">puts</span> <span class="ruby-constant">ERB</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">input_file</span>).<span class="ruby-identifier">read</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-value str">&quot;-&gt;&quot;</span>).<span class="ruby-identifier">result</span>(<span class="ruby-identifier">binding</span>)}
605
+ 125: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Wrote: #{output_file}&quot;</span>
606
+ 126: <span class="ruby-keyword kw">end</span>
591
607
  </pre>
592
608
  </div>
593
609
  </div>
data/doc/created.rid CHANGED
@@ -1 +1 @@
1
- Mon, 28 Apr 2008 14:27:30 -0400
1
+ Mon, 28 Apr 2008 14:44:38 -0400
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Mon Apr 28 14:26:56 -0400 2008</td>
59
+ <td>Mon Apr 28 14:32:28 -0400 2008</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -182,6 +182,14 @@ the parameter, name, be passed into it. We are then using that parameter to
182
182
  generate the names of some files and folders. Pretty cool, eh? See how
183
183
  simple that is.
184
184
  </p>
185
+ <h3>Explicit Manifests</h3>
186
+ <p>
187
+ Explicit manifests are used when there is a manifest.yml supplied at the
188
+ same level as the generator. If there is a manifest.yml file then implied
189
+ manifests are not used. This means you have to define the entire generation
190
+ process. This is great if you have a pretty complicated generator, as the
191
+ manifest.yml is also sent through ERB before being loaded.
192
+ </p>
185
193
  <p>
186
194
  Let&#8216;s look at the manifest.yml file for our simple_generator example:
187
195
  </p>
@@ -226,14 +234,6 @@ Our manifest.yml file would look like this:
226
234
  <p>
227
235
  This will generate the exact same thing as our implied manifest.
228
236
  </p>
229
- <h3>Explicit Manifests</h3>
230
- <p>
231
- Explicit manifests are used when there is a manifest.yml supplied at the
232
- same level as the generator. If there is a manifest.yml file then implied
233
- manifests are not used. This means you have to define the entire generation
234
- process. This is great if you have a pretty complicated generator, as the
235
- manifest.yml is also sent through ERB before being loaded.
236
- </p>
237
237
  <h2>Contact</h2>
238
238
  <p>
239
239
  Please mail bugs, suggestions and patches to
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Mon Apr 28 14:23:38 -0400 2008</td>
59
+ <td>Mon Apr 28 14:43:45 -0400 2008</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -22,11 +22,12 @@
22
22
  <div id="index-entries">
23
23
  <a href="classes/Genosaurus.html#M000007">after_generate (Genosaurus)</a><br />
24
24
  <a href="classes/Genosaurus.html#M000006">before_generate (Genosaurus)</a><br />
25
+ <a href="classes/Genosaurus.html#M000014">copy (Genosaurus)</a><br />
25
26
  <a href="classes/Genosaurus.html#M000013">directory (Genosaurus)</a><br />
26
- <a href="classes/Genosaurus.html#M000014">generate (Genosaurus)</a><br />
27
+ <a href="classes/Genosaurus.html#M000015">generate (Genosaurus)</a><br />
27
28
  <a href="classes/Genosaurus.html#M000008">manifest (Genosaurus)</a><br />
28
29
  <a href="classes/Genosaurus.html#M000004">manifest_path (Genosaurus)</a><br />
29
- <a href="classes/Genosaurus.html#M000015">method_missing (Genosaurus)</a><br />
30
+ <a href="classes/Genosaurus.html#M000016">method_missing (Genosaurus)</a><br />
30
31
  <a href="classes/Genosaurus.html#M000002">new (Genosaurus)</a><br />
31
32
  <a href="classes/Genosaurus.html#M000011">param (Genosaurus)</a><br />
32
33
  <a href="classes/Genosaurus.html#M000009">require_param (Genosaurus)</a><br />
data/lib/genosaurus.rb CHANGED
@@ -120,19 +120,7 @@ class Genosaurus
120
120
  # be skipped. If you would like to force the writing of the file, use the
121
121
  # :force => true option.
122
122
  def template(input_file, output_file, options = @options)
123
- if File.exists?(output_file)
124
- unless options[:force]
125
- puts "Skipped: #{output_file}"
126
- return
127
- end
128
- end
129
- # incase the directory doesn't exist, let's create it.
130
- directory(File.dirname(output_file))
131
- # puts "input_file: #{input_file}"
132
- # puts "output_file: #{output_file}"
133
- if $genosaurus_output_directory
134
- output_file = File.join($genosaurus_output_directory, output_file)
135
- end
123
+ output_file = template_copy_common(output_file, options)
136
124
  File.open(output_file, "w") {|f| f.puts ERB.new(File.open(input_file).read, nil, "->").result(binding)}
137
125
  puts "Wrote: #{output_file}"
138
126
  end
@@ -150,6 +138,12 @@ class Genosaurus
150
138
  puts "Created: #{output_dir}"
151
139
  end
152
140
 
141
+ def copy(input_file, output_file, options = @options)
142
+ output_file = template_copy_common(output_file, options)
143
+ FileUtils.cp(input_file, output_file)
144
+ puts "Copied: #{output_file}"
145
+ end
146
+
153
147
  # This does the dirty work of generation.
154
148
  def generate
155
149
  generate_callbacks do
@@ -159,6 +153,8 @@ class Genosaurus
159
153
  template(info["template_path"], info["output_path"])
160
154
  when "directory"
161
155
  directory(info["output_path"])
156
+ when "copy"
157
+ copy(info["template_path"], info["output_path"])
162
158
  else
163
159
  raise "Unknown 'type': #{info["type"]}!"
164
160
  end
@@ -179,4 +175,19 @@ class Genosaurus
179
175
  after_generate
180
176
  end
181
177
 
178
+ def template_copy_common(output_file, options)
179
+ if File.exists?(output_file)
180
+ unless options[:force]
181
+ puts "Skipped: #{output_file}"
182
+ return
183
+ end
184
+ end
185
+ # incase the directory doesn't exist, let's create it.
186
+ directory(File.dirname(output_file))
187
+ if $genosaurus_output_directory
188
+ output_file = File.join($genosaurus_output_directory, output_file)
189
+ end
190
+ output_file
191
+ end
192
+
182
193
  end # Genosaurus
@@ -73,6 +73,12 @@ class GenosaurusBaseTest < Test::Unit::TestCase
73
73
  assert File.exists?(File.join($genosaurus_output_directory, "months", "march"))
74
74
  end
75
75
 
76
+ def test_copy
77
+ assert !File.exists?(File.join($genosaurus_output_directory, "hw.txt"))
78
+ @generator = CopyMachineGenerator.run
79
+ assert File.exists?(File.join($genosaurus_output_directory, "hw.txt"))
80
+ end
81
+
76
82
  def clean_tmp
77
83
  FileUtils.rm_rf($genosaurus_output_directory, :verbose => false)
78
84
  end
@@ -0,0 +1,2 @@
1
+ class CopyMachineGenerator < Genosaurus
2
+ end
@@ -0,0 +1,4 @@
1
+ template_1:
2
+ type: copy
3
+ template_path: <%= File.join(templates_directory_path, "hello_world.txt") %>
4
+ output_path: hw.txt
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genosaurus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - markbates
8
- autorequire: genosaurus
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
@@ -30,14 +30,14 @@ dependencies:
30
30
  - !ruby/object:Gem::Version
31
31
  version: "0"
32
32
  version:
33
- description: "genosaurus was developed by: markbates"
33
+ description: Genosaurus is meant to be a very, very easy to use generation system for Ruby.
34
34
  email: mark@markbates.com
35
35
  executables: []
36
36
 
37
37
  extensions: []
38
38
 
39
- extra_rdoc_files: []
40
-
39
+ extra_rdoc_files:
40
+ - README
41
41
  files:
42
42
  - lib/genosaurus.rb
43
43
  - README
@@ -80,6 +80,11 @@ summary: genosaurus
80
80
  test_files:
81
81
  - test/genosaurus_test.rb
82
82
  - test/lib
83
+ - test/lib/copy_machine_generator
84
+ - test/lib/copy_machine_generator/copy_machine_generator.rb
85
+ - test/lib/copy_machine_generator/manifest.yml
86
+ - test/lib/copy_machine_generator/templates
87
+ - test/lib/copy_machine_generator/templates/hello_world.txt
83
88
  - test/lib/directory_generator
84
89
  - test/lib/directory_generator/directory_generator.rb
85
90
  - test/lib/directory_generator/templates