genosaurus 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/doc/classes/Genosaurus.html +300 -236
- data/doc/classes/String.html +6 -6
- data/doc/created.rid +1 -1
- data/doc/files/lib/genosaurus_rb.html +1 -1
- data/doc/fr_method_index.html +18 -16
- data/lib/genosaurus.rb +19 -0
- data/test/genosaurus_spec.rb +8 -0
- data/test/lib/many_requires_generator/many_requires_generator.rb +11 -0
- metadata +1 -1
data/doc/classes/Genosaurus.html
CHANGED
@@ -86,22 +86,24 @@
|
|
86
86
|
<h3 class="section-bar">Methods</h3>
|
87
87
|
|
88
88
|
<div class="name-list">
|
89
|
-
<a href="#
|
90
|
-
<a href="#
|
91
|
-
<a href="#
|
92
|
-
<a href="#
|
93
|
-
<a href="#
|
94
|
-
<a href="#
|
95
|
-
<a href="#
|
96
|
-
<a href="#
|
97
|
-
<a href="#
|
98
|
-
<a href="#
|
99
|
-
<a href="#
|
100
|
-
<a href="#
|
89
|
+
<a href="#M000009">after_generate</a>
|
90
|
+
<a href="#M000008">before_generate</a>
|
91
|
+
<a href="#M000016">copy</a>
|
92
|
+
<a href="#M000002">describe</a>
|
93
|
+
<a href="#M000003">description_detail</a>
|
94
|
+
<a href="#M000015">directory</a>
|
95
|
+
<a href="#M000017">generate</a>
|
96
|
+
<a href="#M000010">manifest</a>
|
97
|
+
<a href="#M000006">manifest_path</a>
|
98
|
+
<a href="#M000018">method_missing</a>
|
99
|
+
<a href="#M000004">new</a>
|
100
|
+
<a href="#M000013">param</a>
|
101
|
+
<a href="#M000011">require_param</a>
|
102
|
+
<a href="#M000012">required_params</a>
|
101
103
|
<a href="#M000001">run</a>
|
102
|
-
<a href="#
|
103
|
-
<a href="#
|
104
|
-
<a href="#
|
104
|
+
<a href="#M000007">setup</a>
|
105
|
+
<a href="#M000014">template</a>
|
106
|
+
<a href="#M000005">templates_directory_path</a>
|
105
107
|
</div>
|
106
108
|
</div>
|
107
109
|
|
@@ -135,6 +137,68 @@
|
|
135
137
|
|
136
138
|
<div class="method-heading">
|
137
139
|
<a href="#M000002" class="method-signature">
|
140
|
+
<span class="method-name">describe</span><span class="method-args">()</span>
|
141
|
+
</a>
|
142
|
+
</div>
|
143
|
+
|
144
|
+
<div class="method-description">
|
145
|
+
<p>
|
146
|
+
Describes the generator.
|
147
|
+
</p>
|
148
|
+
<p><a class="source-toggle" href="#"
|
149
|
+
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
150
|
+
<div class="method-source-code" id="M000002-source">
|
151
|
+
<pre>
|
152
|
+
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line 32</span>
|
153
|
+
32: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">describe</span>
|
154
|
+
33: <span class="ruby-identifier">text</span> = [<span class="ruby-node">"#{self}:"</span>]
|
155
|
+
34: <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
|
+
35: <span class="ruby-identifier">text</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"Required Parameter: '#{p.to_s.downcase}'"</span>
|
157
|
+
36: <span class="ruby-keyword kw">end</span>
|
158
|
+
37: <span class="ruby-identifier">dd</span> = <span class="ruby-identifier">description_detail</span>
|
159
|
+
38: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">dd</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">dd</span> <span class="ruby-operator">==</span> <span class="ruby-value str">''</span>
|
160
|
+
39: <span class="ruby-identifier">text</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"---------------"</span>
|
161
|
+
40: <span class="ruby-identifier">text</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">dd</span>
|
162
|
+
41: <span class="ruby-keyword kw">end</span>
|
163
|
+
42: <span class="ruby-identifier">text</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"\n"</span>)
|
164
|
+
43: <span class="ruby-keyword kw">end</span>
|
165
|
+
</pre>
|
166
|
+
</div>
|
167
|
+
</div>
|
168
|
+
</div>
|
169
|
+
|
170
|
+
<div id="method-M000003" class="method-detail">
|
171
|
+
<a name="M000003"></a>
|
172
|
+
|
173
|
+
<div class="method-heading">
|
174
|
+
<a href="#M000003" class="method-signature">
|
175
|
+
<span class="method-name">description_detail</span><span class="method-args">()</span>
|
176
|
+
</a>
|
177
|
+
</div>
|
178
|
+
|
179
|
+
<div class="method-description">
|
180
|
+
<p>
|
181
|
+
Override this method in your generator to append to the <a
|
182
|
+
href="Genosaurus.html#M000002">describe</a> method.
|
183
|
+
</p>
|
184
|
+
<p><a class="source-toggle" href="#"
|
185
|
+
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
186
|
+
<div class="method-source-code" id="M000003-source">
|
187
|
+
<pre>
|
188
|
+
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line 46</span>
|
189
|
+
46: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">description_detail</span>
|
190
|
+
47: <span class="ruby-value str">''</span>
|
191
|
+
48: <span class="ruby-keyword kw">end</span>
|
192
|
+
</pre>
|
193
|
+
</div>
|
194
|
+
</div>
|
195
|
+
</div>
|
196
|
+
|
197
|
+
<div id="method-M000004" class="method-detail">
|
198
|
+
<a name="M000004"></a>
|
199
|
+
|
200
|
+
<div class="method-heading">
|
201
|
+
<a href="#M000004" class="method-signature">
|
138
202
|
<span class="method-name">new</span><span class="method-args">(options = {})</span>
|
139
203
|
</a>
|
140
204
|
</div>
|
@@ -144,48 +208,48 @@
|
|
144
208
|
Takes any options needed for this generator. If the generator requires any
|
145
209
|
parameters an ArgumentError exception will be raised if those parameters
|
146
210
|
are found in the options Hash. The <a
|
147
|
-
href="Genosaurus.html#
|
211
|
+
href="Genosaurus.html#M000007">setup</a> method is called at the end of the
|
148
212
|
initialization.
|
149
213
|
</p>
|
150
214
|
<p><a class="source-toggle" href="#"
|
151
|
-
onclick="toggleCode('
|
152
|
-
<div class="method-source-code" id="
|
215
|
+
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
216
|
+
<div class="method-source-code" id="M000004-source">
|
153
217
|
<pre>
|
154
|
-
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
218
|
+
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line 54</span>
|
219
|
+
54: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span> = {})
|
220
|
+
55: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
221
|
+
56: <span class="ruby-identifier">opts</span> = [<span class="ruby-identifier">options</span>].<span class="ruby-identifier">flatten</span>
|
222
|
+
57: <span class="ruby-identifier">options</span> = {}
|
223
|
+
58: <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_with_index</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
|
224
|
+
59: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">p</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">i</span>]
|
225
|
+
60: <span class="ruby-keyword kw">end</span>
|
226
|
+
61: <span class="ruby-keyword kw">end</span>
|
227
|
+
62: <span class="ruby-ivar">@options</span> = <span class="ruby-identifier">options</span>
|
228
|
+
63: <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>
|
229
|
+
64: <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">"The required parameter '#{p.to_s.upcase}' is missing for this generator!"</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">param</span>(<span class="ruby-identifier">p</span>)
|
230
|
+
65: <span class="ruby-keyword kw">end</span>
|
231
|
+
66: <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>
|
232
|
+
67: <span class="ruby-ivar">@generator_name_underscore</span> = <span class="ruby-ivar">@generator_name</span>.<span class="ruby-identifier">underscore</span> <span class="ruby-comment cmt">#String::Style.underscore(@generator_name)#.underscore</span>
|
233
|
+
68: <span class="ruby-ivar">@templates_directory_path</span> = <span class="ruby-keyword kw">nil</span>
|
234
|
+
69: <span class="ruby-ivar">@manifest_path</span> = <span class="ruby-keyword kw">nil</span>
|
235
|
+
70: <span class="ruby-identifier">$"</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>
|
236
|
+
71: <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>)
|
237
|
+
72: <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">"templates"</span>)
|
238
|
+
73: <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">"manifest.yml"</span>)
|
239
|
+
74: <span class="ruby-keyword kw">end</span>
|
240
|
+
75: <span class="ruby-keyword kw">end</span>
|
241
|
+
76: <span class="ruby-identifier">setup</span>
|
242
|
+
77: <span class="ruby-keyword kw">end</span>
|
179
243
|
</pre>
|
180
244
|
</div>
|
181
245
|
</div>
|
182
246
|
</div>
|
183
247
|
|
184
|
-
<div id="method-
|
185
|
-
<a name="
|
248
|
+
<div id="method-M000011" class="method-detail">
|
249
|
+
<a name="M000011"></a>
|
186
250
|
|
187
251
|
<div class="method-heading">
|
188
|
-
<a href="#
|
252
|
+
<a href="#M000011" class="method-signature">
|
189
253
|
<span class="method-name">require_param</span><span class="method-args">(*args)</span>
|
190
254
|
</a>
|
191
255
|
</div>
|
@@ -195,40 +259,40 @@ initialization.
|
|
195
259
|
Used to define arguments that are required by the generator.
|
196
260
|
</p>
|
197
261
|
<p><a class="source-toggle" href="#"
|
198
|
-
onclick="toggleCode('
|
199
|
-
<div class="method-source-code" id="
|
262
|
+
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
263
|
+
<div class="method-source-code" id="M000011-source">
|
200
264
|
<pre>
|
201
|
-
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
265
|
+
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line 140</span>
|
266
|
+
140: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">require_param</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
267
|
+
141: <span class="ruby-identifier">required_params</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">args</span>
|
268
|
+
142: <span class="ruby-identifier">required_params</span>.<span class="ruby-identifier">flatten!</span>
|
269
|
+
143: <span class="ruby-keyword kw">end</span>
|
206
270
|
</pre>
|
207
271
|
</div>
|
208
272
|
</div>
|
209
273
|
</div>
|
210
274
|
|
211
|
-
<div id="method-
|
212
|
-
<a name="
|
275
|
+
<div id="method-M000012" class="method-detail">
|
276
|
+
<a name="M000012"></a>
|
213
277
|
|
214
278
|
<div class="method-heading">
|
215
|
-
<a href="#
|
279
|
+
<a href="#M000012" class="method-signature">
|
216
280
|
<span class="method-name">required_params</span><span class="method-args">()</span>
|
217
281
|
</a>
|
218
282
|
</div>
|
219
283
|
|
220
284
|
<div class="method-description">
|
221
285
|
<p>
|
222
|
-
Returns the <a href="Genosaurus.html#
|
286
|
+
Returns the <a href="Genosaurus.html#M000012">required_params</a> array.
|
223
287
|
</p>
|
224
288
|
<p><a class="source-toggle" href="#"
|
225
|
-
onclick="toggleCode('
|
226
|
-
<div class="method-source-code" id="
|
289
|
+
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
290
|
+
<div class="method-source-code" id="M000012-source">
|
227
291
|
<pre>
|
228
|
-
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line
|
229
|
-
|
230
|
-
|
231
|
-
|
292
|
+
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line 146</span>
|
293
|
+
146: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">required_params</span>
|
294
|
+
147: <span class="ruby-ivar">@required_params</span> <span class="ruby-operator">||=</span> []
|
295
|
+
148: <span class="ruby-keyword kw">end</span>
|
232
296
|
</pre>
|
233
297
|
</div>
|
234
298
|
</div>
|
@@ -245,9 +309,9 @@ Returns the <a href="Genosaurus.html#M000010">required_params</a> array.
|
|
245
309
|
|
246
310
|
<div class="method-description">
|
247
311
|
<p>
|
248
|
-
Instantiates a <a href="Genosaurus.html#
|
312
|
+
Instantiates a <a href="Genosaurus.html#M000004">new</a> <a
|
249
313
|
href="Genosaurus.html">Genosaurus</a>, passing the ENV hash as options into
|
250
|
-
it, runs the <a href="Genosaurus.html#
|
314
|
+
it, runs the <a href="Genosaurus.html#M000017">generate</a> method, and
|
251
315
|
returns the <a href="Genosaurus.html">Genosaurus</a> object.
|
252
316
|
</p>
|
253
317
|
<p><a class="source-toggle" href="#"
|
@@ -267,11 +331,11 @@ returns the <a href="Genosaurus.html">Genosaurus</a> object.
|
|
267
331
|
|
268
332
|
<h3 class="section-bar">Public Instance methods</h3>
|
269
333
|
|
270
|
-
<div id="method-
|
271
|
-
<a name="
|
334
|
+
<div id="method-M000009" class="method-detail">
|
335
|
+
<a name="M000009"></a>
|
272
336
|
|
273
337
|
<div class="method-heading">
|
274
|
-
<a href="#
|
338
|
+
<a href="#M000009" class="method-signature">
|
275
339
|
<span class="method-name">after_generate</span><span class="method-args">()</span>
|
276
340
|
</a>
|
277
341
|
</div>
|
@@ -279,27 +343,27 @@ returns the <a href="Genosaurus.html">Genosaurus</a> object.
|
|
279
343
|
<div class="method-description">
|
280
344
|
<p>
|
281
345
|
To be overridden in subclasses to do work after the <a
|
282
|
-
href="Genosaurus.html#
|
346
|
+
href="Genosaurus.html#M000017">generate</a> method is <a
|
283
347
|
href="Genosaurus.html#M000001">run</a>. This is a simple way to call other
|
284
348
|
generators.
|
285
349
|
</p>
|
286
350
|
<p><a class="source-toggle" href="#"
|
287
|
-
onclick="toggleCode('
|
288
|
-
<div class="method-source-code" id="
|
351
|
+
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
352
|
+
<div class="method-source-code" id="M000009-source">
|
289
353
|
<pre>
|
290
|
-
|
291
|
-
|
292
|
-
|
354
|
+
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line 106</span>
|
355
|
+
106: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">after_generate</span>
|
356
|
+
107: <span class="ruby-keyword kw">end</span>
|
293
357
|
</pre>
|
294
358
|
</div>
|
295
359
|
</div>
|
296
360
|
</div>
|
297
361
|
|
298
|
-
<div id="method-
|
299
|
-
<a name="
|
362
|
+
<div id="method-M000008" class="method-detail">
|
363
|
+
<a name="M000008"></a>
|
300
364
|
|
301
365
|
<div class="method-heading">
|
302
|
-
<a href="#
|
366
|
+
<a href="#M000008" class="method-signature">
|
303
367
|
<span class="method-name">before_generate</span><span class="method-args">()</span>
|
304
368
|
</a>
|
305
369
|
</div>
|
@@ -307,85 +371,85 @@ generators.
|
|
307
371
|
<div class="method-description">
|
308
372
|
<p>
|
309
373
|
To be overridden in subclasses to do work before the <a
|
310
|
-
href="Genosaurus.html#
|
374
|
+
href="Genosaurus.html#M000017">generate</a> method is <a
|
311
375
|
href="Genosaurus.html#M000001">run</a>.
|
312
376
|
</p>
|
313
377
|
<p><a class="source-toggle" href="#"
|
314
|
-
onclick="toggleCode('
|
315
|
-
<div class="method-source-code" id="
|
378
|
+
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
379
|
+
<div class="method-source-code" id="M000008-source">
|
316
380
|
<pre>
|
317
|
-
|
318
|
-
|
319
|
-
|
381
|
+
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line 101</span>
|
382
|
+
101: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">before_generate</span>
|
383
|
+
102: <span class="ruby-keyword kw">end</span>
|
320
384
|
</pre>
|
321
385
|
</div>
|
322
386
|
</div>
|
323
387
|
</div>
|
324
388
|
|
325
|
-
<div id="method-
|
326
|
-
<a name="
|
389
|
+
<div id="method-M000016" class="method-detail">
|
390
|
+
<a name="M000016"></a>
|
327
391
|
|
328
392
|
<div class="method-heading">
|
329
|
-
<a href="#
|
393
|
+
<a href="#M000016" class="method-signature">
|
330
394
|
<span class="method-name">copy</span><span class="method-args">(input_file, output_file, options = @options)</span>
|
331
395
|
</a>
|
332
396
|
</div>
|
333
397
|
|
334
398
|
<div class="method-description">
|
335
399
|
<p><a class="source-toggle" href="#"
|
336
|
-
onclick="toggleCode('
|
337
|
-
<div class="method-source-code" id="
|
400
|
+
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
|
401
|
+
<div class="method-source-code" id="M000016-source">
|
338
402
|
<pre>
|
339
|
-
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
403
|
+
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line 181</span>
|
404
|
+
181: <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>)
|
405
|
+
182: <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>)
|
406
|
+
183: <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>)
|
407
|
+
184: <span class="ruby-identifier">puts</span> <span class="ruby-node">"Copied: #{output_file}"</span>
|
408
|
+
185: <span class="ruby-keyword kw">end</span>
|
345
409
|
</pre>
|
346
410
|
</div>
|
347
411
|
</div>
|
348
412
|
</div>
|
349
413
|
|
350
|
-
<div id="method-
|
351
|
-
<a name="
|
414
|
+
<div id="method-M000015" class="method-detail">
|
415
|
+
<a name="M000015"></a>
|
352
416
|
|
353
417
|
<div class="method-heading">
|
354
|
-
<a href="#
|
418
|
+
<a href="#M000015" class="method-signature">
|
355
419
|
<span class="method-name">directory</span><span class="method-args">(output_dir, options = @options)</span>
|
356
420
|
</a>
|
357
421
|
</div>
|
358
422
|
|
359
423
|
<div class="method-description">
|
360
424
|
<p>
|
361
|
-
Creates the specified <a href="Genosaurus.html#
|
425
|
+
Creates the specified <a href="Genosaurus.html#M000015">directory</a>.
|
362
426
|
</p>
|
363
427
|
<p><a class="source-toggle" href="#"
|
364
|
-
onclick="toggleCode('
|
365
|
-
<div class="method-source-code" id="
|
428
|
+
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
429
|
+
<div class="method-source-code" id="M000015-source">
|
366
430
|
<pre>
|
367
|
-
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
431
|
+
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line 169</span>
|
432
|
+
169: <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>)
|
433
|
+
170: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$genosaurus_output_directory</span>
|
434
|
+
171: <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>)
|
435
|
+
172: <span class="ruby-keyword kw">end</span>
|
436
|
+
173: <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>)
|
437
|
+
174: <span class="ruby-identifier">puts</span> <span class="ruby-node">"Exists: #{output_dir}"</span>
|
438
|
+
175: <span class="ruby-keyword kw">return</span>
|
439
|
+
176: <span class="ruby-keyword kw">end</span>
|
440
|
+
177: <span class="ruby-identifier">mkdir_p</span>(<span class="ruby-identifier">output_dir</span>)
|
441
|
+
178: <span class="ruby-identifier">puts</span> <span class="ruby-node">"Created: #{output_dir}"</span>
|
442
|
+
179: <span class="ruby-keyword kw">end</span>
|
379
443
|
</pre>
|
380
444
|
</div>
|
381
445
|
</div>
|
382
446
|
</div>
|
383
447
|
|
384
|
-
<div id="method-
|
385
|
-
<a name="
|
448
|
+
<div id="method-M000017" class="method-detail">
|
449
|
+
<a name="M000017"></a>
|
386
450
|
|
387
451
|
<div class="method-heading">
|
388
|
-
<a href="#
|
452
|
+
<a href="#M000017" class="method-signature">
|
389
453
|
<span class="method-name">generate</span><span class="method-args">()</span>
|
390
454
|
</a>
|
391
455
|
</div>
|
@@ -395,92 +459,92 @@ Creates the specified <a href="Genosaurus.html#M000013">directory</a>.
|
|
395
459
|
This does the dirty work of generation.
|
396
460
|
</p>
|
397
461
|
<p><a class="source-toggle" href="#"
|
398
|
-
onclick="toggleCode('
|
399
|
-
<div class="method-source-code" id="
|
462
|
+
onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
|
463
|
+
<div class="method-source-code" id="M000017-source">
|
400
464
|
<pre>
|
401
|
-
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
465
|
+
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line 188</span>
|
466
|
+
188: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">generate</span>
|
467
|
+
189: <span class="ruby-identifier">generate_callbacks</span> <span class="ruby-keyword kw">do</span>
|
468
|
+
190: <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>
|
469
|
+
191: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">info</span>[<span class="ruby-value str">"type"</span>]
|
470
|
+
192: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"file"</span>
|
471
|
+
193: <span class="ruby-identifier">template</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">info</span>[<span class="ruby-value str">"template_path"</span>]).<span class="ruby-identifier">read</span>, <span class="ruby-identifier">info</span>[<span class="ruby-value str">"output_path"</span>])
|
472
|
+
194: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"directory"</span>
|
473
|
+
195: <span class="ruby-identifier">directory</span>(<span class="ruby-identifier">info</span>[<span class="ruby-value str">"output_path"</span>])
|
474
|
+
196: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"copy"</span>
|
475
|
+
197: <span class="ruby-identifier">copy</span>(<span class="ruby-identifier">info</span>[<span class="ruby-value str">"template_path"</span>], <span class="ruby-identifier">info</span>[<span class="ruby-value str">"output_path"</span>])
|
476
|
+
198: <span class="ruby-keyword kw">else</span>
|
477
|
+
199: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Unknown 'type': #{info["type"]}!"</span>
|
478
|
+
200: <span class="ruby-keyword kw">end</span>
|
479
|
+
201: <span class="ruby-keyword kw">end</span>
|
480
|
+
202: <span class="ruby-keyword kw">end</span>
|
481
|
+
203: <span class="ruby-keyword kw">end</span>
|
418
482
|
</pre>
|
419
483
|
</div>
|
420
484
|
</div>
|
421
485
|
</div>
|
422
486
|
|
423
|
-
<div id="method-
|
424
|
-
<a name="
|
487
|
+
<div id="method-M000010" class="method-detail">
|
488
|
+
<a name="M000010"></a>
|
425
489
|
|
426
490
|
<div class="method-heading">
|
427
|
-
<a href="#
|
491
|
+
<a href="#M000010" class="method-signature">
|
428
492
|
<span class="method-name">manifest</span><span class="method-args">()</span>
|
429
493
|
</a>
|
430
494
|
</div>
|
431
495
|
|
432
496
|
<div class="method-description">
|
433
497
|
<p>
|
434
|
-
Returns the <a href="Genosaurus.html#
|
498
|
+
Returns the <a href="Genosaurus.html#M000010">manifest</a> for this
|
435
499
|
generator, which is used by the <a
|
436
|
-
href="Genosaurus.html#
|
500
|
+
href="Genosaurus.html#M000017">generate</a> method to do the dirty work. If
|
437
501
|
there is a manifest.yml, defined by the <a
|
438
|
-
href="Genosaurus.html#
|
502
|
+
href="Genosaurus.html#M000006">manifest_path</a> method, then the contents
|
439
503
|
of that file are processed with ERB and returned. If there is not
|
440
|
-
manifest.yml then an implied <a href="Genosaurus.html#
|
504
|
+
manifest.yml then an implied <a href="Genosaurus.html#M000010">manifest</a>
|
441
505
|
is generated from the contents of the <a
|
442
|
-
href="Genosaurus.html#
|
506
|
+
href="Genosaurus.html#M000005">templates_directory_path</a>.
|
443
507
|
</p>
|
444
508
|
<p><a class="source-toggle" href="#"
|
445
|
-
onclick="toggleCode('
|
446
|
-
<div class="method-source-code" id="
|
509
|
+
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
510
|
+
<div class="method-source-code" id="M000010-source">
|
447
511
|
<pre>
|
448
|
-
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
512
|
+
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line 113</span>
|
513
|
+
113: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">manifest</span>
|
514
|
+
114: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">templates_directory_path</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">manifest_path</span>.<span class="ruby-identifier">nil?</span>
|
515
|
+
115: <span class="ruby-identifier">raise</span> <span class="ruby-value str">"Unable to dynamically figure out your templates_directory_path and manifest_path!\nPlease implement these methods and let Genosaurus know where to find these things. Thanks."</span>
|
516
|
+
116: <span class="ruby-keyword kw">end</span>
|
517
|
+
117: <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>)
|
518
|
+
118: <span class="ruby-comment cmt"># run using the yml file</span>
|
519
|
+
119: <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">"->"</span>)
|
520
|
+
120: <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>))
|
521
|
+
121: <span class="ruby-keyword kw">else</span>
|
522
|
+
122: <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">"**/*.template"</span>))
|
523
|
+
123: <span class="ruby-identifier">man</span> = {}
|
524
|
+
124: <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>
|
525
|
+
125: <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">""</span>)
|
526
|
+
126: <span class="ruby-identifier">output_path</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-value str">".template"</span>, <span class="ruby-value str">""</span>)
|
527
|
+
127: <span class="ruby-identifier">output_path</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/^\//</span>, <span class="ruby-value str">""</span>)
|
528
|
+
128: <span class="ruby-identifier">man</span>[<span class="ruby-node">"template_#{i+1}"</span>] = {
|
529
|
+
129: <span class="ruby-value str">"type"</span> =<span class="ruby-operator">></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">"directory"</span> <span class="ruby-operator">:</span> <span class="ruby-value str">"file"</span>,
|
530
|
+
130: <span class="ruby-value str">"template_path"</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">f</span>,
|
531
|
+
131: <span class="ruby-value str">"output_path"</span> =<span class="ruby-operator">></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">></span> <span class="ruby-value str">'% %'</span>).<span class="ruby-identifier">result</span>(<span class="ruby-identifier">binding</span>)
|
532
|
+
132: }
|
533
|
+
133: <span class="ruby-keyword kw">end</span>
|
534
|
+
134: <span class="ruby-keyword kw">end</span>
|
535
|
+
135: <span class="ruby-comment cmt"># puts man.inspect</span>
|
536
|
+
136: <span class="ruby-identifier">man</span>
|
537
|
+
137: <span class="ruby-keyword kw">end</span>
|
474
538
|
</pre>
|
475
539
|
</div>
|
476
540
|
</div>
|
477
541
|
</div>
|
478
542
|
|
479
|
-
<div id="method-
|
480
|
-
<a name="
|
543
|
+
<div id="method-M000006" class="method-detail">
|
544
|
+
<a name="M000006"></a>
|
481
545
|
|
482
546
|
<div class="method-heading">
|
483
|
-
<a href="#
|
547
|
+
<a href="#M000006" class="method-signature">
|
484
548
|
<span class="method-name">manifest_path</span><span class="method-args">()</span>
|
485
549
|
</a>
|
486
550
|
</div>
|
@@ -489,56 +553,56 @@ href="Genosaurus.html#M000003">templates_directory_path</a>.
|
|
489
553
|
<p>
|
490
554
|
Returns the path to the manifest.yml. This is only used if you have a
|
491
555
|
manifest.yml file, if there is no file, or this method returns nil, then an
|
492
|
-
implied <a href="Genosaurus.html#
|
493
|
-
<a href="Genosaurus.html#
|
556
|
+
implied <a href="Genosaurus.html#M000010">manifest</a> is used based on the
|
557
|
+
<a href="Genosaurus.html#M000005">templates_directory_path</a> contents.
|
494
558
|
IMPORTANT: <a href="Genosaurus.html">Genosaurus</a> will attempt to find
|
495
559
|
this location automatically, HOWEVER, if there is a problem, or you want to
|
496
560
|
be special, you can override this method in your generator and have it
|
497
561
|
return the correct path.
|
498
562
|
</p>
|
499
563
|
<p><a class="source-toggle" href="#"
|
500
|
-
onclick="toggleCode('
|
501
|
-
<div class="method-source-code" id="
|
564
|
+
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
565
|
+
<div class="method-source-code" id="M000006-source">
|
502
566
|
<pre>
|
503
|
-
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line
|
504
|
-
|
505
|
-
|
506
|
-
|
567
|
+
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line 91</span>
|
568
|
+
91: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">manifest_path</span>
|
569
|
+
92: <span class="ruby-ivar">@manifest_path</span>
|
570
|
+
93: <span class="ruby-keyword kw">end</span>
|
507
571
|
</pre>
|
508
572
|
</div>
|
509
573
|
</div>
|
510
574
|
</div>
|
511
575
|
|
512
|
-
<div id="method-
|
513
|
-
<a name="
|
576
|
+
<div id="method-M000018" class="method-detail">
|
577
|
+
<a name="M000018"></a>
|
514
578
|
|
515
579
|
<div class="method-heading">
|
516
|
-
<a href="#
|
580
|
+
<a href="#M000018" class="method-signature">
|
517
581
|
<span class="method-name">method_missing</span><span class="method-args">(sym, *args)</span>
|
518
582
|
</a>
|
519
583
|
</div>
|
520
584
|
|
521
585
|
<div class="method-description">
|
522
586
|
<p><a class="source-toggle" href="#"
|
523
|
-
onclick="toggleCode('
|
524
|
-
<div class="method-source-code" id="
|
587
|
+
onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
|
588
|
+
<div class="method-source-code" id="M000018-source">
|
525
589
|
<pre>
|
526
|
-
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
590
|
+
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line 205</span>
|
591
|
+
205: <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>)
|
592
|
+
206: <span class="ruby-identifier">p</span> = <span class="ruby-identifier">param</span>(<span class="ruby-identifier">sym</span>)
|
593
|
+
207: <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>
|
594
|
+
208: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NoMethodError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">sym</span>)
|
595
|
+
209: <span class="ruby-keyword kw">end</span>
|
532
596
|
</pre>
|
533
597
|
</div>
|
534
598
|
</div>
|
535
599
|
</div>
|
536
600
|
|
537
|
-
<div id="method-
|
538
|
-
<a name="
|
601
|
+
<div id="method-M000013" class="method-detail">
|
602
|
+
<a name="M000013"></a>
|
539
603
|
|
540
604
|
<div class="method-heading">
|
541
|
-
<a href="#
|
605
|
+
<a href="#M000013" class="method-signature">
|
542
606
|
<span class="method-name">param</span><span class="method-args">(key)</span>
|
543
607
|
</a>
|
544
608
|
</div>
|
@@ -548,23 +612,23 @@ return the correct path.
|
|
548
612
|
Returns a parameter from the initial Hash of parameters.
|
549
613
|
</p>
|
550
614
|
<p><a class="source-toggle" href="#"
|
551
|
-
onclick="toggleCode('
|
552
|
-
<div class="method-source-code" id="
|
615
|
+
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
616
|
+
<div class="method-source-code" id="M000013-source">
|
553
617
|
<pre>
|
554
|
-
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line
|
555
|
-
|
556
|
-
|
557
|
-
|
618
|
+
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line 151</span>
|
619
|
+
151: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">param</span>(<span class="ruby-identifier">key</span>)
|
620
|
+
152: (<span class="ruby-ivar">@options</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">downcase</span>] <span class="ruby-operator">||=</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">upcase</span>])
|
621
|
+
153: <span class="ruby-keyword kw">end</span>
|
558
622
|
</pre>
|
559
623
|
</div>
|
560
624
|
</div>
|
561
625
|
</div>
|
562
626
|
|
563
|
-
<div id="method-
|
564
|
-
<a name="
|
627
|
+
<div id="method-M000007" class="method-detail">
|
628
|
+
<a name="M000007"></a>
|
565
629
|
|
566
630
|
<div class="method-heading">
|
567
|
-
<a href="#
|
631
|
+
<a href="#M000007" class="method-signature">
|
568
632
|
<span class="method-name">setup</span><span class="method-args">()</span>
|
569
633
|
</a>
|
570
634
|
</div>
|
@@ -572,26 +636,26 @@ Returns a parameter from the initial Hash of parameters.
|
|
572
636
|
<div class="method-description">
|
573
637
|
<p>
|
574
638
|
To be overridden in subclasses to do any <a
|
575
|
-
href="Genosaurus.html#
|
639
|
+
href="Genosaurus.html#M000007">setup</a> work needed by the generator.
|
576
640
|
</p>
|
577
641
|
<p><a class="source-toggle" href="#"
|
578
|
-
onclick="toggleCode('
|
579
|
-
<div class="method-source-code" id="
|
642
|
+
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
643
|
+
<div class="method-source-code" id="M000007-source">
|
580
644
|
<pre>
|
581
|
-
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line
|
582
|
-
|
583
|
-
|
584
|
-
|
645
|
+
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line 96</span>
|
646
|
+
96: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">setup</span>
|
647
|
+
97: <span class="ruby-comment cmt"># does nothing, unless overridden in subclass.</span>
|
648
|
+
98: <span class="ruby-keyword kw">end</span>
|
585
649
|
</pre>
|
586
650
|
</div>
|
587
651
|
</div>
|
588
652
|
</div>
|
589
653
|
|
590
|
-
<div id="method-
|
591
|
-
<a name="
|
654
|
+
<div id="method-M000014" class="method-detail">
|
655
|
+
<a name="M000014"></a>
|
592
656
|
|
593
657
|
<div class="method-heading">
|
594
|
-
<a href="#
|
658
|
+
<a href="#M000014" class="method-signature">
|
595
659
|
<span class="method-name">template</span><span class="method-args">(input_file, output_file, options = @options)</span>
|
596
660
|
</a>
|
597
661
|
</div>
|
@@ -603,28 +667,28 @@ output_file. If the output_file exists it will be skipped. If you would
|
|
603
667
|
like to force the writing of the file, use the :force => true option.
|
604
668
|
</p>
|
605
669
|
<p><a class="source-toggle" href="#"
|
606
|
-
onclick="toggleCode('
|
607
|
-
<div class="method-source-code" id="
|
670
|
+
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
671
|
+
<div class="method-source-code" id="M000014-source">
|
608
672
|
<pre>
|
609
|
-
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
673
|
+
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line 159</span>
|
674
|
+
159: <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>)
|
675
|
+
160: <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>)
|
676
|
+
161: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">output_file</span>.<span class="ruby-identifier">nil?</span>
|
677
|
+
162: <span class="ruby-comment cmt"># File.open(output_file, "w") {|f| f.puts ERB.new(File.open(input_file).read, nil, "->").result(binding)}</span>
|
678
|
+
163: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">output_file</span>, <span class="ruby-value str">"w"</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-identifier">input_file</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-value str">"->"</span>).<span class="ruby-identifier">result</span>(<span class="ruby-identifier">binding</span>)}
|
679
|
+
164: <span class="ruby-identifier">puts</span> <span class="ruby-node">"Wrote: #{output_file}"</span>
|
680
|
+
165: <span class="ruby-keyword kw">end</span>
|
681
|
+
166: <span class="ruby-keyword kw">end</span>
|
618
682
|
</pre>
|
619
683
|
</div>
|
620
684
|
</div>
|
621
685
|
</div>
|
622
686
|
|
623
|
-
<div id="method-
|
624
|
-
<a name="
|
687
|
+
<div id="method-M000005" class="method-detail">
|
688
|
+
<a name="M000005"></a>
|
625
689
|
|
626
690
|
<div class="method-heading">
|
627
|
-
<a href="#
|
691
|
+
<a href="#M000005" class="method-signature">
|
628
692
|
<span class="method-name">templates_directory_path</span><span class="method-args">()</span>
|
629
693
|
</a>
|
630
694
|
</div>
|
@@ -632,21 +696,21 @@ like to force the writing of the file, use the :force => true option.
|
|
632
696
|
<div class="method-description">
|
633
697
|
<p>
|
634
698
|
Returns the path to the templates <a
|
635
|
-
href="Genosaurus.html#
|
636
|
-
the <a href="Genosaurus.html#
|
699
|
+
href="Genosaurus.html#M000015">directory</a>. IMPORTANT: The location of
|
700
|
+
the <a href="Genosaurus.html#M000005">templates_directory_path</a> is VERY
|
637
701
|
important! <a href="Genosaurus.html">Genosaurus</a> will attempt to find
|
638
702
|
this location automatically, HOWEVER, if there is a problem, or you want to
|
639
703
|
be special, you can override this method in your generator and have it
|
640
704
|
return the correct path.
|
641
705
|
</p>
|
642
706
|
<p><a class="source-toggle" href="#"
|
643
|
-
onclick="toggleCode('
|
644
|
-
<div class="method-source-code" id="
|
707
|
+
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
708
|
+
<div class="method-source-code" id="M000005-source">
|
645
709
|
<pre>
|
646
|
-
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line
|
647
|
-
|
648
|
-
|
649
|
-
|
710
|
+
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line 83</span>
|
711
|
+
83: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">templates_directory_path</span>
|
712
|
+
84: <span class="ruby-ivar">@templates_directory_path</span>
|
713
|
+
85: <span class="ruby-keyword kw">end</span>
|
650
714
|
</pre>
|
651
715
|
</div>
|
652
716
|
</div>
|
data/doc/classes/String.html
CHANGED
@@ -86,7 +86,7 @@
|
|
86
86
|
<h3 class="section-bar">Methods</h3>
|
87
87
|
|
88
88
|
<div class="name-list">
|
89
|
-
<a href="#
|
89
|
+
<a href="#M000019">underscore</a>
|
90
90
|
</div>
|
91
91
|
</div>
|
92
92
|
|
@@ -108,19 +108,19 @@
|
|
108
108
|
<div id="methods">
|
109
109
|
<h3 class="section-bar">Public Instance methods</h3>
|
110
110
|
|
111
|
-
<div id="method-
|
112
|
-
<a name="
|
111
|
+
<div id="method-M000019" class="method-detail">
|
112
|
+
<a name="M000019"></a>
|
113
113
|
|
114
114
|
<div class="method-heading">
|
115
|
-
<a href="#
|
115
|
+
<a href="#M000019" class="method-signature">
|
116
116
|
<span class="method-name">underscore</span><span class="method-args">()</span>
|
117
117
|
</a>
|
118
118
|
</div>
|
119
119
|
|
120
120
|
<div class="method-description">
|
121
121
|
<p><a class="source-toggle" href="#"
|
122
|
-
onclick="toggleCode('
|
123
|
-
<div class="method-source-code" id="
|
122
|
+
onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
|
123
|
+
<div class="method-source-code" id="M000019-source">
|
124
124
|
<pre>
|
125
125
|
<span class="ruby-comment cmt"># File lib/genosaurus.rb, line 8</span>
|
126
126
|
8: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">underscore</span>
|
data/doc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Fri, 29 Aug 2008 14:
|
1
|
+
Fri, 29 Aug 2008 14:57:43 -0400
|
data/doc/fr_method_index.html
CHANGED
@@ -20,23 +20,25 @@
|
|
20
20
|
<div id="index">
|
21
21
|
<h1 class="section-bar">Methods</h1>
|
22
22
|
<div id="index-entries">
|
23
|
-
<a href="classes/Genosaurus.html#
|
24
|
-
<a href="classes/Genosaurus.html#
|
25
|
-
<a href="classes/Genosaurus.html#
|
26
|
-
<a href="classes/Genosaurus.html#
|
27
|
-
<a href="classes/Genosaurus.html#
|
28
|
-
<a href="classes/Genosaurus.html#
|
29
|
-
<a href="classes/Genosaurus.html#
|
30
|
-
<a href="classes/Genosaurus.html#
|
31
|
-
<a href="classes/Genosaurus.html#
|
32
|
-
<a href="classes/Genosaurus.html#
|
33
|
-
<a href="classes/Genosaurus.html#
|
34
|
-
<a href="classes/Genosaurus.html#
|
23
|
+
<a href="classes/Genosaurus.html#M000009">after_generate (Genosaurus)</a><br />
|
24
|
+
<a href="classes/Genosaurus.html#M000008">before_generate (Genosaurus)</a><br />
|
25
|
+
<a href="classes/Genosaurus.html#M000016">copy (Genosaurus)</a><br />
|
26
|
+
<a href="classes/Genosaurus.html#M000002">describe (Genosaurus)</a><br />
|
27
|
+
<a href="classes/Genosaurus.html#M000003">description_detail (Genosaurus)</a><br />
|
28
|
+
<a href="classes/Genosaurus.html#M000015">directory (Genosaurus)</a><br />
|
29
|
+
<a href="classes/Genosaurus.html#M000017">generate (Genosaurus)</a><br />
|
30
|
+
<a href="classes/Genosaurus.html#M000010">manifest (Genosaurus)</a><br />
|
31
|
+
<a href="classes/Genosaurus.html#M000006">manifest_path (Genosaurus)</a><br />
|
32
|
+
<a href="classes/Genosaurus.html#M000018">method_missing (Genosaurus)</a><br />
|
33
|
+
<a href="classes/Genosaurus.html#M000004">new (Genosaurus)</a><br />
|
34
|
+
<a href="classes/Genosaurus.html#M000013">param (Genosaurus)</a><br />
|
35
|
+
<a href="classes/Genosaurus.html#M000011">require_param (Genosaurus)</a><br />
|
36
|
+
<a href="classes/Genosaurus.html#M000012">required_params (Genosaurus)</a><br />
|
35
37
|
<a href="classes/Genosaurus.html#M000001">run (Genosaurus)</a><br />
|
36
|
-
<a href="classes/Genosaurus.html#
|
37
|
-
<a href="classes/Genosaurus.html#
|
38
|
-
<a href="classes/Genosaurus.html#
|
39
|
-
<a href="classes/String.html#
|
38
|
+
<a href="classes/Genosaurus.html#M000007">setup (Genosaurus)</a><br />
|
39
|
+
<a href="classes/Genosaurus.html#M000014">template (Genosaurus)</a><br />
|
40
|
+
<a href="classes/Genosaurus.html#M000005">templates_directory_path (Genosaurus)</a><br />
|
41
|
+
<a href="classes/String.html#M000019">underscore (String)</a><br />
|
40
42
|
</div>
|
41
43
|
</div>
|
42
44
|
</body>
|
data/lib/genosaurus.rb
CHANGED
@@ -28,6 +28,25 @@ class Genosaurus
|
|
28
28
|
gen
|
29
29
|
end
|
30
30
|
|
31
|
+
# Describes the generator.
|
32
|
+
def describe
|
33
|
+
text = ["#{self}:"]
|
34
|
+
required_params.each do |p|
|
35
|
+
text << "Required Parameter: '#{p.to_s.downcase}'"
|
36
|
+
end
|
37
|
+
dd = description_detail
|
38
|
+
unless dd.nil? || dd == ''
|
39
|
+
text << "---------------"
|
40
|
+
text << dd
|
41
|
+
end
|
42
|
+
text.join("\n")
|
43
|
+
end
|
44
|
+
|
45
|
+
# Override this method in your generator to append to the describe method.
|
46
|
+
def description_detail
|
47
|
+
''
|
48
|
+
end
|
49
|
+
|
31
50
|
end
|
32
51
|
|
33
52
|
# Takes any options needed for this generator. If the generator requires any parameters an ArgumentError exception will be
|
data/test/genosaurus_spec.rb
CHANGED
@@ -10,6 +10,14 @@ describe Genosaurus do
|
|
10
10
|
clean_tmp
|
11
11
|
end
|
12
12
|
|
13
|
+
it "should describe it's required parameters" do
|
14
|
+
desc = ManyRequiresGenerator.describe
|
15
|
+
desc.should match(/ManyRequiresGenerator/)
|
16
|
+
desc.should match(/Required Parameter: 'first_name'/)
|
17
|
+
desc.should match(/Required Parameter: 'last_name'/)
|
18
|
+
desc.should match(/This generator requires many things/)
|
19
|
+
end
|
20
|
+
|
13
21
|
it "test_simple_implied_generator" do
|
14
22
|
hello_file = File.join($genosaurus_output_directory, "hello_world.rb")
|
15
23
|
goodbye_file = File.join($genosaurus_output_directory, "goodbye_world.rb")
|
@@ -1,4 +1,15 @@
|
|
1
1
|
class ManyRequiresGenerator < Genosaurus
|
2
2
|
require_param :first_name
|
3
3
|
require_param :last_name
|
4
|
+
|
5
|
+
def self.description_detail
|
6
|
+
%{
|
7
|
+
This generator requires many things.
|
8
|
+
These things can be used like such:
|
9
|
+
|
10
|
+
first_name=Mark
|
11
|
+
last_name=Bates
|
12
|
+
}.strip
|
13
|
+
end
|
14
|
+
|
4
15
|
end
|