genosaurus 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -31,7 +31,7 @@ We should get a file called hello_world.txt generated in the current directory.
31
31
 
32
32
  With implied manifests our directory structure under 'templates' tells the whole story, and Genosaurus is smart enough to figure it out. All the file names, and the same goes for folders, need to end in .template, and Genosaurus will do the rest.
33
33
 
34
- All the files will go through ERB before they generated, so you can put all your lovely little dynamic goodies in there. File, and folder, names also get run through ERB so you can even make the file name dynamic too!
34
+ All the files will go through ERB before they generated, so you can put all your lovely little dynamic goodies in there. File, and folder, names also get run through ERB so you can even make the file name dynamic too! The caveat to that is that it's a modified version of ERB for the file names. The syntax is just %= ... % and not <%= ... %>. It's just a little easier on the file system.
35
35
 
36
36
  Let's look at a more complex example:
37
37
 
@@ -40,10 +40,10 @@ Let's look at a more complex example:
40
40
  templates:
41
41
  app:
42
42
  views:
43
- <%=param(:name).plural%>.template:
43
+ %=param(:name).plural%.template: # or %=name.plural%.rb.template
44
44
  hello_world.html.erb
45
45
  models:
46
- <%=param(:name)%>.rb.template
46
+ %=param(:name)%.rb.template # or %=name%.rb.template
47
47
 
48
48
  Let's run our complex_generator.rb file:
49
49
 
@@ -92,6 +92,7 @@
92
92
  <a href="#M000014">generate</a>&nbsp;&nbsp;
93
93
  <a href="#M000008">manifest</a>&nbsp;&nbsp;
94
94
  <a href="#M000004">manifest_path</a>&nbsp;&nbsp;
95
+ <a href="#M000015">method_missing</a>&nbsp;&nbsp;
95
96
  <a href="#M000002">new</a>&nbsp;&nbsp;
96
97
  <a href="#M000011">param</a>&nbsp;&nbsp;
97
98
  <a href="#M000009">require_param</a>&nbsp;&nbsp;
@@ -149,24 +150,24 @@ initialization.
149
150
  onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
150
151
  <div class="method-source-code" id="M000002-source">
151
152
  <pre>
152
- <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 24</span>
153
- 24: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span> = {})
154
- 25: <span class="ruby-ivar">@options</span> = <span class="ruby-identifier">options</span>
155
- 26: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">required_params</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
156
- 27: <span class="ruby-identifier">raise</span> <span class="ruby-operator">::</span><span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;The required parameter '#{p.to_s.upcase}' is missing for this generator!&quot;</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">param</span>(<span class="ruby-identifier">p</span>)
157
- 28: <span class="ruby-keyword kw">end</span>
158
- 29: <span class="ruby-ivar">@generator_name</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">name</span>
159
- 30: <span class="ruby-ivar">@generator_name_underscore</span> = <span class="ruby-ivar">@generator_name</span>.<span class="ruby-identifier">underscore</span>
160
- 31: <span class="ruby-ivar">@templates_directory_path</span> = <span class="ruby-keyword kw">nil</span>
161
- 32: <span class="ruby-ivar">@manifest_path</span> = <span class="ruby-keyword kw">nil</span>
162
- 33: <span class="ruby-identifier">$&quot;</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
163
- 34: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">match</span>(<span class="ruby-node">/#{@generator_name_underscore}\.rb$/</span>)
164
- 35: <span class="ruby-ivar">@templates_directory_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">f</span>), <span class="ruby-value str">&quot;templates&quot;</span>)
165
- 36: <span class="ruby-ivar">@manifest_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">f</span>), <span class="ruby-value str">&quot;manifest.yml&quot;</span>)
166
- 37: <span class="ruby-keyword kw">end</span>
167
- 38: <span class="ruby-keyword kw">end</span>
168
- 39: <span class="ruby-identifier">setup</span>
169
- 40: <span class="ruby-keyword kw">end</span>
153
+ <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 25</span>
154
+ 25: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span> = {})
155
+ 26: <span class="ruby-ivar">@options</span> = <span class="ruby-identifier">options</span>
156
+ 27: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">required_params</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
157
+ 28: <span class="ruby-identifier">raise</span> <span class="ruby-operator">::</span><span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;The required parameter '#{p.to_s.upcase}' is missing for this generator!&quot;</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">param</span>(<span class="ruby-identifier">p</span>)
158
+ 29: <span class="ruby-keyword kw">end</span>
159
+ 30: <span class="ruby-ivar">@generator_name</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">name</span>
160
+ 31: <span class="ruby-ivar">@generator_name_underscore</span> = <span class="ruby-ivar">@generator_name</span>.<span class="ruby-identifier">underscore</span>
161
+ 32: <span class="ruby-ivar">@templates_directory_path</span> = <span class="ruby-keyword kw">nil</span>
162
+ 33: <span class="ruby-ivar">@manifest_path</span> = <span class="ruby-keyword kw">nil</span>
163
+ 34: <span class="ruby-identifier">$&quot;</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
164
+ 35: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">match</span>(<span class="ruby-node">/#{@generator_name_underscore}\.rb$/</span>)
165
+ 36: <span class="ruby-ivar">@templates_directory_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">f</span>), <span class="ruby-value str">&quot;templates&quot;</span>)
166
+ 37: <span class="ruby-ivar">@manifest_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">f</span>), <span class="ruby-value str">&quot;manifest.yml&quot;</span>)
167
+ 38: <span class="ruby-keyword kw">end</span>
168
+ 39: <span class="ruby-keyword kw">end</span>
169
+ 40: <span class="ruby-identifier">setup</span>
170
+ 41: <span class="ruby-keyword kw">end</span>
170
171
  </pre>
171
172
  </div>
172
173
  </div>
@@ -245,12 +246,12 @@ returns the <a href="Genosaurus.html">Genosaurus</a> object.
245
246
  onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
246
247
  <div class="method-source-code" id="M000001-source">
247
248
  <pre>
248
- <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 14</span>
249
- 14: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>(<span class="ruby-identifier">options</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">to_hash</span>)
250
- 15: <span class="ruby-identifier">gen</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>)
251
- 16: <span class="ruby-identifier">gen</span>.<span class="ruby-identifier">generate</span>
252
- 17: <span class="ruby-identifier">gen</span>
253
- 18: <span class="ruby-keyword kw">end</span>
249
+ <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 15</span>
250
+ 15: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>(<span class="ruby-identifier">options</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">to_hash</span>)
251
+ 16: <span class="ruby-identifier">gen</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>)
252
+ 17: <span class="ruby-identifier">gen</span>.<span class="ruby-identifier">generate</span>
253
+ 18: <span class="ruby-identifier">gen</span>
254
+ 19: <span class="ruby-keyword kw">end</span>
254
255
  </pre>
255
256
  </div>
256
257
  </div>
@@ -278,9 +279,9 @@ generators.
278
279
  onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
279
280
  <div class="method-source-code" id="M000007-source">
280
281
  <pre>
281
- <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 69</span>
282
- 69: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">after_generate</span>
283
- 70: <span class="ruby-keyword kw">end</span>
282
+ <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 70</span>
283
+ 70: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">after_generate</span>
284
+ 71: <span class="ruby-keyword kw">end</span>
284
285
  </pre>
285
286
  </div>
286
287
  </div>
@@ -305,9 +306,9 @@ href="Genosaurus.html#M000001">run</a>.
305
306
  onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
306
307
  <div class="method-source-code" id="M000006-source">
307
308
  <pre>
308
- <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 64</span>
309
- 64: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">before_generate</span>
310
- 65: <span class="ruby-keyword kw">end</span>
309
+ <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 65</span>
310
+ 65: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">before_generate</span>
311
+ 66: <span class="ruby-keyword kw">end</span>
311
312
  </pre>
312
313
  </div>
313
314
  </div>
@@ -409,31 +410,31 @@ href="Genosaurus.html#M000003">templates_directory_path</a>.
409
410
  onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
410
411
  <div class="method-source-code" id="M000008-source">
411
412
  <pre>
412
- <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 76</span>
413
- 76: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">manifest</span>
414
- 77: <span class="ruby-identifier">ivar_cache</span> <span class="ruby-keyword kw">do</span>
415
- 78: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">manifest_path</span>)
416
- 79: <span class="ruby-comment cmt"># run using the yml file</span>
417
- 80: <span class="ruby-identifier">template</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">manifest_path</span>).<span class="ruby-identifier">read</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-value str">&quot;-&gt;&quot;</span>)
418
- 81: <span class="ruby-identifier">man</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>(<span class="ruby-identifier">template</span>.<span class="ruby-identifier">result</span>(<span class="ruby-identifier">binding</span>))
419
- 82: <span class="ruby-keyword kw">else</span>
420
- 83: <span class="ruby-identifier">files</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">templates_directory_path</span>, <span class="ruby-value str">&quot;**/*.template&quot;</span>))
421
- 84: <span class="ruby-identifier">man</span> = {}
422
- 85: <span class="ruby-identifier">files</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
423
- 86: <span class="ruby-identifier">output_path</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-identifier">templates_directory_path</span>, <span class="ruby-value str">&quot;&quot;</span>)
424
- 87: <span class="ruby-identifier">output_path</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-value str">&quot;.template&quot;</span>, <span class="ruby-value str">&quot;&quot;</span>)
425
- 88: <span class="ruby-identifier">output_path</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/^\//</span>, <span class="ruby-value str">&quot;&quot;</span>)
426
- 89: <span class="ruby-identifier">man</span>[<span class="ruby-node">&quot;template_#{i+1}&quot;</span>] = {
427
- 90: <span class="ruby-value str">&quot;type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">f</span>) <span class="ruby-operator">?</span> <span class="ruby-value str">&quot;directory&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;file&quot;</span>,
428
- 91: <span class="ruby-value str">&quot;template_path&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">f</span>,
429
- 92: <span class="ruby-value str">&quot;output_path&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">ERB</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">output_path</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>)
430
- 93: }
431
- 94: <span class="ruby-keyword kw">end</span>
432
- 95: <span class="ruby-keyword kw">end</span>
433
- 96: <span class="ruby-comment cmt"># puts man.inspect</span>
434
- 97: <span class="ruby-identifier">man</span>
435
- 98: <span class="ruby-keyword kw">end</span>
436
- 99: <span class="ruby-keyword kw">end</span>
413
+ <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 77</span>
414
+ 77: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">manifest</span>
415
+ 78: <span class="ruby-identifier">ivar_cache</span> <span class="ruby-keyword kw">do</span>
416
+ 79: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">manifest_path</span>)
417
+ 80: <span class="ruby-comment cmt"># run using the yml file</span>
418
+ 81: <span class="ruby-identifier">template</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">manifest_path</span>).<span class="ruby-identifier">read</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-value str">&quot;-&gt;&quot;</span>)
419
+ 82: <span class="ruby-identifier">man</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>(<span class="ruby-identifier">template</span>.<span class="ruby-identifier">result</span>(<span class="ruby-identifier">binding</span>))
420
+ 83: <span class="ruby-keyword kw">else</span>
421
+ 84: <span class="ruby-identifier">files</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">templates_directory_path</span>, <span class="ruby-value str">&quot;**/*.template&quot;</span>))
422
+ 85: <span class="ruby-identifier">man</span> = {}
423
+ 86: <span class="ruby-identifier">files</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
424
+ 87: <span class="ruby-identifier">output_path</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-identifier">templates_directory_path</span>, <span class="ruby-value str">&quot;&quot;</span>)
425
+ 88: <span class="ruby-identifier">output_path</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-value str">&quot;.template&quot;</span>, <span class="ruby-value str">&quot;&quot;</span>)
426
+ 89: <span class="ruby-identifier">output_path</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/^\//</span>, <span class="ruby-value str">&quot;&quot;</span>)
427
+ 90: <span class="ruby-identifier">man</span>[<span class="ruby-node">&quot;template_#{i+1}&quot;</span>] = {
428
+ 91: <span class="ruby-value str">&quot;type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">f</span>) <span class="ruby-operator">?</span> <span class="ruby-value str">&quot;directory&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;file&quot;</span>,
429
+ 92: <span class="ruby-value str">&quot;template_path&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">f</span>,
430
+ 93: <span class="ruby-value str">&quot;output_path&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Erubis</span><span class="ruby-operator">::</span><span class="ruby-constant">Eruby</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">output_path</span>, <span class="ruby-identifier">:pattern</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'% %'</span>).<span class="ruby-identifier">result</span>(<span class="ruby-identifier">binding</span>)
431
+ 94: }
432
+ 95: <span class="ruby-keyword kw">end</span>
433
+ 96: <span class="ruby-keyword kw">end</span>
434
+ 97: <span class="ruby-comment cmt"># puts man.inspect</span>
435
+ 98: <span class="ruby-identifier">man</span>
436
+ 99: <span class="ruby-keyword kw">end</span>
437
+ 100: <span class="ruby-keyword kw">end</span>
437
438
  </pre>
438
439
  </div>
439
440
  </div>
@@ -463,10 +464,35 @@ return the correct path.
463
464
  onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
464
465
  <div class="method-source-code" id="M000004-source">
465
466
  <pre>
466
- <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 54</span>
467
- 54: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">manifest_path</span>
468
- 55: <span class="ruby-ivar">@manifest_path</span>
469
- 56: <span class="ruby-keyword kw">end</span>
467
+ <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 55</span>
468
+ 55: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">manifest_path</span>
469
+ 56: <span class="ruby-ivar">@manifest_path</span>
470
+ 57: <span class="ruby-keyword kw">end</span>
471
+ </pre>
472
+ </div>
473
+ </div>
474
+ </div>
475
+
476
+ <div id="method-M000015" class="method-detail">
477
+ <a name="M000015"></a>
478
+
479
+ <div class="method-heading">
480
+ <a href="#M000015" class="method-signature">
481
+ <span class="method-name">method_missing</span><span class="method-args">(sym, *args)</span>
482
+ </a>
483
+ </div>
484
+
485
+ <div class="method-description">
486
+ <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">
489
+ <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>
470
496
  </pre>
471
497
  </div>
472
498
  </div>
@@ -516,10 +542,10 @@ href="Genosaurus.html#M000005">setup</a> work needed by the generator.
516
542
  onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
517
543
  <div class="method-source-code" id="M000005-source">
518
544
  <pre>
519
- <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 59</span>
520
- 59: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">setup</span>
521
- 60: <span class="ruby-comment cmt"># does nothing, unless overridden in subclass.</span>
522
- 61: <span class="ruby-keyword kw">end</span>
545
+ <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 60</span>
546
+ 60: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">setup</span>
547
+ 61: <span class="ruby-comment cmt"># does nothing, unless overridden in subclass.</span>
548
+ 62: <span class="ruby-keyword kw">end</span>
523
549
  </pre>
524
550
  </div>
525
551
  </div>
@@ -590,10 +616,10 @@ return the correct path.
590
616
  onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
591
617
  <div class="method-source-code" id="M000003-source">
592
618
  <pre>
593
- <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 46</span>
594
- 46: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">templates_directory_path</span>
595
- 47: <span class="ruby-ivar">@templates_directory_path</span>
596
- 48: <span class="ruby-keyword kw">end</span>
619
+ <span class="ruby-comment cmt"># File lib/genosaurus.rb, line 47</span>
620
+ 47: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">templates_directory_path</span>
621
+ 48: <span class="ruby-ivar">@templates_directory_path</span>
622
+ 49: <span class="ruby-keyword kw">end</span>
597
623
  </pre>
598
624
  </div>
599
625
  </div>
data/doc/created.rid CHANGED
@@ -1 +1 @@
1
- Tue, 22 Apr 2008 17:04:53 -0400
1
+ Mon, 28 Apr 2008 14:27:30 -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>Tue Apr 22 17:04:13 -0400 2008</td>
59
+ <td>Mon Apr 28 14:26:56 -0400 2008</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -128,7 +128,10 @@ the rest.
128
128
  <p>
129
129
  All the files will go through ERB before they generated, so you can put all
130
130
  your lovely little dynamic goodies in there. File, and folder, names also
131
- get run through ERB so you can even make the file name dynamic too!
131
+ get run through ERB so you can even make the file name dynamic too! The
132
+ caveat to that is that it&#8216;s a modified version of ERB for the file
133
+ names. The syntax is just %= &#8230; % and not &lt;%= &#8230; %&gt;.
134
+ It&#8216;s just a little easier on the file system.
132
135
  </p>
133
136
  <p>
134
137
  Let&#8216;s look at a more complex example:
@@ -139,10 +142,10 @@ Let&#8216;s look at a more complex example:
139
142
  templates:
140
143
  app:
141
144
  views:
142
- &lt;%=param(:name).plural%&gt;.template:
145
+ %=param(:name).plural%.template: # or %=name.plural%.rb.template
143
146
  hello_world.html.erb
144
147
  models:
145
- &lt;%=param(:name)%&gt;.rb.template
148
+ %=param(:name)%.rb.template # or %=name%.rb.template
146
149
  </pre>
147
150
  <p>
148
151
  Let&#8216;s run our complex_generator.rb file:
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Tue Apr 22 17:04:13 -0400 2008</td>
59
+ <td>Mon Apr 28 14:23:38 -0400 2008</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -78,6 +78,7 @@
78
78
  fileutils&nbsp;&nbsp;
79
79
  erb&nbsp;&nbsp;
80
80
  yaml&nbsp;&nbsp;
81
+ erubis&nbsp;&nbsp;
81
82
  </div>
82
83
  </div>
83
84
 
@@ -26,6 +26,7 @@
26
26
  <a href="classes/Genosaurus.html#M000014">generate (Genosaurus)</a><br />
27
27
  <a href="classes/Genosaurus.html#M000008">manifest (Genosaurus)</a><br />
28
28
  <a href="classes/Genosaurus.html#M000004">manifest_path (Genosaurus)</a><br />
29
+ <a href="classes/Genosaurus.html#M000015">method_missing (Genosaurus)</a><br />
29
30
  <a href="classes/Genosaurus.html#M000002">new (Genosaurus)</a><br />
30
31
  <a href="classes/Genosaurus.html#M000011">param (Genosaurus)</a><br />
31
32
  <a href="classes/Genosaurus.html#M000009">require_param (Genosaurus)</a><br />
data/lib/genosaurus.rb CHANGED
@@ -3,6 +3,7 @@ require 'mack_ruby_core_extensions'
3
3
  require 'fileutils'
4
4
  require 'erb'
5
5
  require 'yaml'
6
+ require 'erubis'
6
7
 
7
8
  class Genosaurus
8
9
 
@@ -89,7 +90,7 @@ class Genosaurus
89
90
  man["template_#{i+1}"] = {
90
91
  "type" => File.directory?(f) ? "directory" : "file",
91
92
  "template_path" => f,
92
- "output_path" => ERB.new(output_path, nil, "->").result(binding)
93
+ "output_path" => Erubis::Eruby.new(output_path, :pattern => '% %').result(binding)
93
94
  }
94
95
  end
95
96
  end
@@ -98,7 +99,6 @@ class Genosaurus
98
99
  end
99
100
  end
100
101
 
101
-
102
102
  # Used to define arguments that are required by the generator.
103
103
  def self.require_param(*args)
104
104
  required_params << args
@@ -166,6 +166,12 @@ class Genosaurus
166
166
  end
167
167
  end
168
168
 
169
+ def method_missing(sym, *args)
170
+ p = param(sym)
171
+ return p if p
172
+ raise NoMethodError.new(sym)
173
+ end
174
+
169
175
  private
170
176
  def generate_callbacks
171
177
  before_generate
@@ -66,6 +66,13 @@ class GenosaurusBaseTest < Test::Unit::TestCase
66
66
  assert_equal "beatles/albums/magical_mystery_tour/lyrics/strawberry_fields_forever.lyrics", info["output_path"]
67
67
  end
68
68
 
69
+ def test_directory
70
+ @generator = DirectoryGenerator.run
71
+ assert File.exists?(File.join($genosaurus_output_directory, "months", "january"))
72
+ assert File.exists?(File.join($genosaurus_output_directory, "months", "february"))
73
+ assert File.exists?(File.join($genosaurus_output_directory, "months", "march"))
74
+ end
75
+
69
76
  def clean_tmp
70
77
  FileUtils.rm_rf($genosaurus_output_directory, :verbose => false)
71
78
  end
@@ -0,0 +1,2 @@
1
+ class DirectoryGenerator < Genosaurus
2
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genosaurus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - markbates
@@ -9,7 +9,7 @@ autorequire: genosaurus
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-22 00:00:00 -04:00
12
+ date: 2008-04-28 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -21,6 +21,15 @@ dependencies:
21
21
  - !ruby/object:Gem::Version
22
22
  version: "0"
23
23
  version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: erubis
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: "0"
32
+ version:
24
33
  description: "genosaurus was developed by: markbates"
25
34
  email: mark@markbates.com
26
35
  executables: []
@@ -72,6 +81,7 @@ test_files:
72
81
  - test/genosaurus_test.rb
73
82
  - test/lib
74
83
  - test/lib/directory_generator
84
+ - test/lib/directory_generator/directory_generator.rb
75
85
  - test/lib/directory_generator/templates
76
86
  - test/lib/directory_generator/templates/months
77
87
  - test/lib/directory_generator/templates/months/february.template
@@ -88,7 +98,7 @@ test_files:
88
98
  - test/lib/i_am_the_walrus_generator/templates/beatles
89
99
  - test/lib/i_am_the_walrus_generator/templates/beatles/albums.template
90
100
  - test/lib/i_am_the_walrus_generator/templates/beatles/lyrics
91
- - test/lib/i_am_the_walrus_generator/templates/beatles/lyrics/<%=param(:name)%>.txt.template
101
+ - test/lib/i_am_the_walrus_generator/templates/beatles/lyrics/%=name%.txt.template
92
102
  - test/lib/strawberry_fields_generator
93
103
  - test/lib/strawberry_fields_generator/manifest.yml
94
104
  - test/lib/strawberry_fields_generator/strawberry_fields_generator.rb