semillagen 0.0.1

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.
Files changed (56) hide show
  1. data/README.md +27 -0
  2. data/bin/semillagen +65 -0
  3. data/default_templates/class/default/classTemplate.as.tpl +22 -0
  4. data/default_templates/class/default/info.semilla +8 -0
  5. data/default_templates/class/default/testClassTemplate.as.tpl +30 -0
  6. data/default_templates/project/default/Gemfile +5 -0
  7. data/default_templates/project/default/Gemfile.lock +24 -0
  8. data/default_templates/project/default/MagicBox.as3proj +96 -0
  9. data/default_templates/project/default/lib/flexunit4/FlexUnit1Lib.swc +0 -0
  10. data/default_templates/project/default/lib/flexunit4/flexUnitTasks-4.1.0-8-javadoc.jar +0 -0
  11. data/default_templates/project/default/lib/flexunit4/flexUnitTasks-4.1.0-8-sources.jar +0 -0
  12. data/default_templates/project/default/lib/flexunit4/flexUnitTasks-4.1.0-8.jar +0 -0
  13. data/default_templates/project/default/lib/flexunit4/flexunit-4.1.0-8-as3_4.1.0.16076.swc +0 -0
  14. data/default_templates/project/default/lib/flexunit4/flexunit-cilistener-4.1.0-8-4.1.0.16076.swc +0 -0
  15. data/default_templates/project/default/lib/flexunit4/flexunit-uilistener-4.1.0-8-4.1.0.16076.swc +0 -0
  16. data/default_templates/project/default/lib/flexunit4/fluint-extensions-4.1.0-8-4.1.0.16076.swc +0 -0
  17. data/default_templates/project/default/lib/flexunit4/hamcrest-as3-flex-1.1.3.swc +0 -0
  18. data/default_templates/project/default/rakefile.rb +128 -0
  19. data/default_templates/project/default/src/MagicBox.as +104 -0
  20. data/default_templates/project/default/src/PlainButton.as +72 -0
  21. data/default_templates/project/default/src/transforms/LeetTransform.as +40 -0
  22. data/default_templates/project/default/src/transforms/LowerCaseTransform.as +22 -0
  23. data/default_templates/project/default/src/transforms/ReverseTransform.as +22 -0
  24. data/default_templates/project/default/src/transforms/SplitTransform.as +22 -0
  25. data/default_templates/project/default/src/transforms/UpperCaseTransform.as +22 -0
  26. data/default_templates/project/default/test-src/TestRunner.template +66 -0
  27. data/default_templates/project/default/test-src/TextFieldListener.as +66 -0
  28. data/default_templates/project/default/test-src/listeners/SemillaCIListener.as +389 -0
  29. data/default_templates/project/default/test-src/listeners/TraceListener.as +79 -0
  30. data/default_templates/project/default/test-src/transforms/LeetTransformTest.as +45 -0
  31. data/default_templates/project/default/test-src/transforms/LowerCaseTransformTest.as +44 -0
  32. data/default_templates/project/default/test-src/transforms/ReverseTransformTest.as +31 -0
  33. data/default_templates/project/default/test-src/transforms/SplitTransformTest.as +37 -0
  34. data/default_templates/project/default/test-src/transforms/UpperCaseTransformTest.as +45 -0
  35. data/doc/SemillaGen/TemplateItem.html +340 -0
  36. data/doc/SemillaGen.html +916 -0
  37. data/doc/_index.html +112 -0
  38. data/doc/class_list.html +47 -0
  39. data/doc/css/common.css +1 -0
  40. data/doc/css/full_list.css +55 -0
  41. data/doc/css/style.css +322 -0
  42. data/doc/file_list.html +46 -0
  43. data/doc/frames.html +13 -0
  44. data/doc/index.html +112 -0
  45. data/doc/js/app.js +205 -0
  46. data/doc/js/full_list.js +173 -0
  47. data/doc/js/jquery.js +16 -0
  48. data/doc/method_list.html +110 -0
  49. data/doc/top-level-namespace.html +105 -0
  50. data/lib/semillagen/generator.rb +248 -0
  51. data/lib/semillagen/utils.rb +40 -0
  52. data/lib/semillagen/version.rb +3 -0
  53. data/lib/semillagen.rb +33 -0
  54. data/rakefile.rb +39 -0
  55. data/semillagen.gemspec +76 -0
  56. metadata +136 -0
@@ -0,0 +1,916 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Module: SemillaGen
8
+
9
+ &mdash; Documentation by YARD 0.7.5
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ relpath = '';
19
+ if (relpath != '') relpath += '/';
20
+ </script>
21
+
22
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
25
+
26
+
27
+ </head>
28
+ <body>
29
+ <script type="text/javascript" charset="utf-8">
30
+ if (window.top.frames.main) document.body.className = 'frames';
31
+ </script>
32
+
33
+ <div id="header">
34
+ <div id="menu">
35
+
36
+ <a href="_index.html">Index (S)</a> &raquo;
37
+
38
+
39
+ <span class="title">SemillaGen</span>
40
+
41
+
42
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
43
+ </div>
44
+
45
+ <div id="search">
46
+
47
+ <a id="class_list_link" href="#">Class List</a>
48
+
49
+ <a id="method_list_link" href="#">Method List</a>
50
+
51
+ <a id="file_list_link" href="#">File List</a>
52
+
53
+ </div>
54
+ <div class="clear"></div>
55
+ </div>
56
+
57
+ <iframe id="search_frame"></iframe>
58
+
59
+ <div id="content"><h1>Module: SemillaGen
60
+
61
+
62
+
63
+ </h1>
64
+
65
+ <dl class="box">
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+ <dt class="r1 last">Defined in:</dt>
75
+ <dd class="r1 last">lib/semilla_gen.rb<span class="defines">,<br />
76
+ lib/semilla_gen/utils.rb,<br /> lib/semilla_gen/version.rb,<br /> lib/semilla_gen/generator.rb</span>
77
+ </dd>
78
+
79
+ </dl>
80
+ <div class="clear"></div>
81
+
82
+ <h2>Defined Under Namespace</h2>
83
+ <p class="children">
84
+
85
+
86
+
87
+
88
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="SemillaGen/TemplateItem.html" title="SemillaGen::TemplateItem (class)">TemplateItem</a></span>
89
+
90
+
91
+ </p>
92
+
93
+ <h2>Constant Summary</h2>
94
+
95
+ <dl class="constants">
96
+
97
+ <dt id="DEFAULT_TEMPLATE_FOLDER-constant" class="">DEFAULT_TEMPLATE_FOLDER =
98
+
99
+ </dt>
100
+ <dd><pre class="code"><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_expand_path'>expand_path</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>../default_templates</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span><span class='lparen'>(</span><span class='kw'>__FILE__</span><span class='rparen'>)</span><span class='rparen'>)</span></pre></dd>
101
+
102
+ <dt id="TEMPLATE_FOLDER-constant" class="">TEMPLATE_FOLDER =
103
+
104
+ </dt>
105
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>semilla_templates</span><span class='tstring_end'>&quot;</span></span></pre></dd>
106
+
107
+ <dt id="VERSION-constant" class="">VERSION =
108
+
109
+ </dt>
110
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>0.0.1</span><span class='tstring_end'>'</span></span></pre></dd>
111
+
112
+ </dl>
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+ <h2>
123
+ Class Method Summary
124
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
125
+ </h2>
126
+
127
+ <ul class="summary">
128
+
129
+ <li class="public ">
130
+ <span class="summary_signature">
131
+
132
+ <a href="#findTemplate-class_method" title="findTemplate (class method)">+ (Object) <strong>findTemplate</strong>(itemtype, templatename) </a>
133
+
134
+
135
+
136
+ </span>
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+ <span class="summary_desc"><div class='inline'>
146
+ <p>Find the template for the specified item type and template name.</p>
147
+ </div></span>
148
+
149
+ </li>
150
+
151
+
152
+ <li class="public ">
153
+ <span class="summary_signature">
154
+
155
+ <a href="#generate-class_method" title="generate (class method)">+ (Object) <strong>generate</strong>(itemtype, template, name) </a>
156
+
157
+
158
+
159
+ </span>
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+ <span class="summary_desc"><div class='inline'>
169
+ <p>Generates items (Projects or Classes) using the specified template and
170
+ name.</p>
171
+ </div></span>
172
+
173
+ </li>
174
+
175
+
176
+ <li class="public ">
177
+ <span class="summary_signature">
178
+
179
+ <a href="#generateFiles-class_method" title="generateFiles (class method)">+ (Object) <strong>generateFiles</strong>(templateFolder, fileList, qualifiedName) </a>
180
+
181
+
182
+
183
+ </span>
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+ <span class="summary_desc"><div class='inline'>
193
+ <p>Generates files for a class.</p>
194
+ </div></span>
195
+
196
+ </li>
197
+
198
+
199
+ <li class="public ">
200
+ <span class="summary_signature">
201
+
202
+ <a href="#parseInfoFile-class_method" title="parseInfoFile (class method)">+ (Array of TemplateItem) <strong>parseInfoFile</strong>(path) </a>
203
+
204
+
205
+
206
+ </span>
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+
215
+ <span class="summary_desc"><div class='inline'>
216
+ <p>Read a info.semilla file.</p>
217
+ </div></span>
218
+
219
+ </li>
220
+
221
+
222
+ <li class="public ">
223
+ <span class="summary_signature">
224
+
225
+ <a href="#recursive_mkdir-class_method" title="recursive_mkdir (class method)">+ (Object) <strong>recursive_mkdir</strong>(path) </a>
226
+
227
+
228
+
229
+ </span>
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+ <span class="summary_desc"><div class='inline'>
239
+ <p>Creates a directory hierarchy for the given directory path if the
240
+ directories do not exist.</p>
241
+ </div></span>
242
+
243
+ </li>
244
+
245
+
246
+ </ul>
247
+
248
+
249
+
250
+
251
+ <div id="class_method_details" class="method_details_list">
252
+ <h2>Class Method Details</h2>
253
+
254
+
255
+ <div class="method_details first">
256
+ <p class="signature first" id="findTemplate-class_method">
257
+
258
+ + (<tt>Object</tt>) <strong>findTemplate</strong>(itemtype, templatename)
259
+
260
+
261
+
262
+ </p><div class="docstring">
263
+ <div class="discussion">
264
+
265
+ <p>Find the template for the specified item type and template name. Ex: Find a
266
+ template for projects, named ClassicMVVMProjectTemplate</p>
267
+
268
+
269
+ </div>
270
+ </div>
271
+ <div class="tags">
272
+ <h3>Parameters:</h3>
273
+ <ul class="param">
274
+
275
+ <li>
276
+
277
+ <span class='name'>can</span>
278
+
279
+
280
+ <span class='type'>(<tt>itemtype</tt>)</span>
281
+
282
+
283
+
284
+ &mdash;
285
+ <div class='inline'>
286
+ <p>be ‘:class’ or ‘:project’</p>
287
+ </div>
288
+
289
+ </li>
290
+
291
+ <li>
292
+
293
+ <span class='name'></span>
294
+
295
+
296
+ <span class='type'>(<tt>templatename</tt>)</span>
297
+
298
+
299
+
300
+ </li>
301
+
302
+ </ul>
303
+
304
+
305
+ </div><table class="source_code">
306
+ <tr>
307
+ <td>
308
+ <pre class="lines">
309
+
310
+
311
+ 13
312
+ 14
313
+ 15
314
+ 16
315
+ 17
316
+ 18
317
+ 19
318
+ 20
319
+ 21
320
+ 22
321
+ 23
322
+ 24
323
+ 25
324
+ 26
325
+ 27
326
+ 28
327
+ 29
328
+ 30
329
+ 31
330
+ 32
331
+ 33
332
+ 34
333
+ 35
334
+ 36
335
+ 37
336
+ 38</pre>
337
+ </td>
338
+ <td>
339
+ <pre class="code"><span class="info file"># File 'lib/semilla_gen/utils.rb', line 13</span>
340
+
341
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_findTemplate'>findTemplate</span><span class='lparen'>(</span><span class='id identifier rubyid_itemtype'>itemtype</span><span class='comma'>,</span> <span class='id identifier rubyid_templatename'>templatename</span><span class='rparen'>)</span>
342
+
343
+ <span class='id identifier rubyid_dirs'>dirs</span> <span class='op'>=</span> <span class='lbracket'>[</span>
344
+ <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_expand_path'>expand_path</span><span class='lparen'>(</span><span class='const'>TEMPLATE_FOLDER</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='comment'>#current folder
345
+ </span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_expand_path'>expand_path</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>~/</span><span class='embexpr_beg'>#{</span><span class='const'>TEMPLATE_FOLDER</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='comma'>,</span> <span class='comment'>#home folder
346
+ </span> <span class='const'>SemillaGen</span><span class='op'>::</span><span class='const'>DEFAULT_TEMPLATE_FOLDER</span> <span class='comment'>#gem lib folder
347
+ </span> <span class='rbracket'>]</span>
348
+
349
+ <span class='id identifier rubyid_absolute_path'>absolute_path</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='semicolon'>;</span>
350
+ <span class='id identifier rubyid_location'>location</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='id identifier rubyid_itemtype'>itemtype</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='comma'>,</span> <span class='id identifier rubyid_templatename'>templatename</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
351
+ <span class='comment'>#puts &quot;location #{location}&quot;
352
+ </span>
353
+ <span class='id identifier rubyid_dirs'>dirs</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_dir'>dir</span><span class='op'>|</span>
354
+ <span class='comment'>#Look for location in dir
355
+ </span> <span class='id identifier rubyid_currentlocation'>currentlocation</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='id identifier rubyid_dir'>dir</span><span class='comma'>,</span> <span class='id identifier rubyid_location'>location</span><span class='rparen'>)</span>
356
+ <span class='comment'>#puts currentlocation
357
+ </span> <span class='kw'>if</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_directory?'>directory?</span> <span class='id identifier rubyid_currentlocation'>currentlocation</span>
358
+ <span class='id identifier rubyid_absolute_path'>absolute_path</span> <span class='op'>=</span> <span class='id identifier rubyid_currentlocation'>currentlocation</span>
359
+ <span class='kw'>break</span><span class='semicolon'>;</span>
360
+ <span class='kw'>end</span>
361
+ <span class='kw'>end</span>
362
+
363
+ <span class='comment'>#If we found the template, absolute_path should not be nil
364
+ </span> <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Template found at: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span>
365
+ <span class='kw'>return</span> <span class='id identifier rubyid_absolute_path'>absolute_path</span>
366
+ <span class='kw'>end</span></pre>
367
+ </td>
368
+ </tr>
369
+ </table>
370
+ </div>
371
+
372
+ <div class="method_details ">
373
+ <p class="signature " id="generate-class_method">
374
+
375
+ + (<tt>Object</tt>) <strong>generate</strong>(itemtype, template, name)
376
+
377
+
378
+
379
+ </p><div class="docstring">
380
+ <div class="discussion">
381
+
382
+ <p>Generates items (Projects or Classes) using the specified template and
383
+ name.</p>
384
+
385
+
386
+ </div>
387
+ </div>
388
+ <div class="tags">
389
+ <h3>Parameters:</h3>
390
+ <ul class="param">
391
+
392
+ <li>
393
+
394
+ <span class='name'>The</span>
395
+
396
+
397
+ <span class='type'>(<tt>itemtype</tt>)</span>
398
+
399
+
400
+
401
+ &mdash;
402
+ <div class='inline'>
403
+ <p>kind of item to create, ‘:class’ or ‘:project’.</p>
404
+ </div>
405
+
406
+ </li>
407
+
408
+ <li>
409
+
410
+ <span class='name'>The</span>
411
+
412
+
413
+ <span class='type'>(<tt>template</tt>)</span>
414
+
415
+
416
+
417
+ &mdash;
418
+ <div class='inline'>
419
+ <p>name of the template to use.</p>
420
+ </div>
421
+
422
+ </li>
423
+
424
+ <li>
425
+
426
+ <span class='name'>The</span>
427
+
428
+
429
+ <span class='type'>(<tt>name</tt>)</span>
430
+
431
+
432
+
433
+ &mdash;
434
+ <div class='inline'>
435
+ <p>name of project or qualified class name to generate.</p>
436
+ </div>
437
+
438
+ </li>
439
+
440
+ </ul>
441
+
442
+
443
+ </div><table class="source_code">
444
+ <tr>
445
+ <td>
446
+ <pre class="lines">
447
+
448
+
449
+ 21
450
+ 22
451
+ 23
452
+ 24
453
+ 25
454
+ 26
455
+ 27
456
+ 28
457
+ 29
458
+ 30
459
+ 31
460
+ 32
461
+ 33
462
+ 34
463
+ 35
464
+ 36
465
+ 37
466
+ 38
467
+ 39
468
+ 40
469
+ 41</pre>
470
+ </td>
471
+ <td>
472
+ <pre class="code"><span class="info file"># File 'lib/semilla_gen/generator.rb', line 21</span>
473
+
474
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_generate'>generate</span><span class='lparen'>(</span><span class='id identifier rubyid_itemtype'>itemtype</span><span class='comma'>,</span> <span class='id identifier rubyid_template'>template</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
475
+
476
+ <span class='comment'>#find the template folder
477
+ </span> <span class='id identifier rubyid_template_folder'>template_folder</span> <span class='op'>=</span> <span class='const'>SemillaGen</span><span class='op'>::</span><span class='id identifier rubyid_findTemplate'>findTemplate</span><span class='lparen'>(</span><span class='id identifier rubyid_itemtype'>itemtype</span><span class='comma'>,</span> <span class='id identifier rubyid_template'>template</span><span class='rparen'>)</span>
478
+
479
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Template not found.</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_template_folder'>template_folder</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
480
+
481
+
482
+ <span class='kw'>if</span> <span class='id identifier rubyid_itemtype'>itemtype</span> <span class='op'>==</span> <span class='symbol'>:class</span>
483
+ <span class='comment'>#When item is a class type
484
+ </span>
485
+ <span class='comment'>#Read the info.semilla file
486
+ </span> <span class='id identifier rubyid_files'>files</span> <span class='op'>=</span> <span class='const'>SemillaGen</span><span class='op'>::</span><span class='id identifier rubyid_parseInfoFile'>parseInfoFile</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='id identifier rubyid_template_folder'>template_folder</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>info.semilla</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
487
+ <span class='const'>SemillaGen</span><span class='op'>::</span><span class='id identifier rubyid_generateFiles'>generateFiles</span><span class='lparen'>(</span><span class='id identifier rubyid_template_folder'>template_folder</span><span class='comma'>,</span> <span class='id identifier rubyid_files'>files</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
488
+
489
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_itemtype'>itemtype</span> <span class='op'>==</span> <span class='symbol'>:project</span>
490
+ <span class='comment'>#when item is a project type
491
+ </span>
492
+ <span class='const'>SemillaGen</span><span class='op'>::</span><span class='id identifier rubyid_generateProject'>generateProject</span><span class='lparen'>(</span><span class='id identifier rubyid_template_folder'>template_folder</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
493
+ <span class='kw'>end</span>
494
+ <span class='kw'>end</span></pre>
495
+ </td>
496
+ </tr>
497
+ </table>
498
+ </div>
499
+
500
+ <div class="method_details ">
501
+ <p class="signature " id="generateFiles-class_method">
502
+
503
+ + (<tt>Object</tt>) <strong>generateFiles</strong>(templateFolder, fileList, qualifiedName)
504
+
505
+
506
+
507
+ </p><div class="docstring">
508
+ <div class="discussion">
509
+
510
+ <p>Generates files for a class.</p>
511
+
512
+
513
+ </div>
514
+ </div>
515
+ <div class="tags">
516
+ <h3>Parameters:</h3>
517
+ <ul class="param">
518
+
519
+ <li>
520
+
521
+ <span class='name'>The</span>
522
+
523
+
524
+ <span class='type'>(<tt>templateFolder</tt>)</span>
525
+
526
+
527
+
528
+ &mdash;
529
+ <div class='inline'>
530
+ <p>folder where the template to be used is located.</p>
531
+ </div>
532
+
533
+ </li>
534
+
535
+ <li>
536
+
537
+ <span class='name'>The</span>
538
+
539
+
540
+ <span class='type'>(<tt>fileList</tt>)</span>
541
+
542
+
543
+
544
+ &mdash;
545
+ <div class='inline'>
546
+ <p>collection of TemplateItems to be generated.</p>
547
+ </div>
548
+
549
+ </li>
550
+
551
+ <li>
552
+
553
+ <span class='name'>The</span>
554
+
555
+
556
+ <span class='type'>(<tt>qualifiedName</tt>)</span>
557
+
558
+
559
+
560
+ &mdash;
561
+ <div class='inline'>
562
+ <p>qualified name of the class to be generated (includes namespaces)</p>
563
+ </div>
564
+
565
+ </li>
566
+
567
+ </ul>
568
+
569
+
570
+ </div><table class="source_code">
571
+ <tr>
572
+ <td>
573
+ <pre class="lines">
574
+
575
+
576
+ 120
577
+ 121
578
+ 122
579
+ 123
580
+ 124
581
+ 125
582
+ 126
583
+ 127
584
+ 128
585
+ 129
586
+ 130
587
+ 131
588
+ 132
589
+ 133
590
+ 134
591
+ 135
592
+ 136
593
+ 137
594
+ 138
595
+ 139
596
+ 140
597
+ 141
598
+ 142
599
+ 143
600
+ 144
601
+ 145
602
+ 146
603
+ 147
604
+ 148
605
+ 149
606
+ 150
607
+ 151
608
+ 152
609
+ 153
610
+ 154
611
+ 155
612
+ 156
613
+ 157
614
+ 158
615
+ 159
616
+ 160
617
+ 161
618
+ 162
619
+ 163
620
+ 164
621
+ 165</pre>
622
+ </td>
623
+ <td>
624
+ <pre class="code"><span class="info file"># File 'lib/semilla_gen/generator.rb', line 120</span>
625
+
626
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_generateFiles'>generateFiles</span><span class='lparen'>(</span><span class='id identifier rubyid_templateFolder'>templateFolder</span><span class='comma'>,</span> <span class='id identifier rubyid_fileList'>fileList</span><span class='comma'>,</span> <span class='id identifier rubyid_qualifiedName'>qualifiedName</span><span class='rparen'>)</span>
627
+ <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Generating files for: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_qualifiedName'>qualifiedName</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span>
628
+
629
+ <span class='id identifier rubyid_fileList'>fileList</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_item'>item</span><span class='op'>|</span>
630
+ <span class='comment'>#puts &quot;----------#{key}&quot;
631
+ </span>
632
+ <span class='comment'>#Check that the sourceFile exists
633
+ </span> <span class='id identifier rubyid_source_full_path'>source_full_path</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_absolute_path'>absolute_path</span><span class='lparen'>(</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='id identifier rubyid_templateFolder'>templateFolder</span><span class='comma'>,</span> <span class='id identifier rubyid_item'>item</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='rparen'>)</span><span class='rparen'>)</span>
634
+ <span class='kw'>if</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_exists?'>exists?</span> <span class='id identifier rubyid_source_full_path'>source_full_path</span>
635
+ <span class='comment'>#Obtain namespaces
636
+ </span> <span class='id identifier rubyid_namespaces'>namespaces</span> <span class='op'>=</span> <span class='id identifier rubyid_qualifiedName'>qualifiedName</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>.</span><span class='tstring_end'>'</span></span> <span class='comment'>#Separate all the qualified name components
637
+ </span> <span class='id identifier rubyid_itemName'>itemName</span> <span class='op'>=</span> <span class='id identifier rubyid_namespaces'>namespaces</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span> <span class='comment'>#the last component is the class name
638
+ </span> <span class='id identifier rubyid_namespaces'>namespaces</span> <span class='op'>=</span> <span class='id identifier rubyid_namespaces'>namespaces</span><span class='period'>.</span><span class='id identifier rubyid_take'>take</span><span class='lparen'>(</span><span class='id identifier rubyid_namespaces'>namespaces</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='op'>-</span><span class='int'>1</span><span class='rparen'>)</span> <span class='comment'>#The rest is the namespace (as array)
639
+ </span> <span class='id identifier rubyid_namespace_text'>namespace_text</span> <span class='op'>=</span> <span class='id identifier rubyid_namespaces'>namespaces</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>.</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#the namespace in ActionScript notation
640
+ </span>
641
+ <span class='comment'>#Append to the target path, the namespaces as folders
642
+ </span> <span class='id identifier rubyid_final_path'>final_path</span> <span class='op'>=</span> <span class='id identifier rubyid_namespaces'>namespaces</span><span class='period'>.</span><span class='id identifier rubyid_unshift'>unshift</span><span class='lparen'>(</span><span class='id identifier rubyid_item'>item</span><span class='period'>.</span><span class='id identifier rubyid_target'>target</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='const'>File</span><span class='op'>::</span><span class='const'>SEPARATOR</span><span class='rparen'>)</span>
643
+ <span class='comment'>#Make sure the final_path directories exist
644
+ </span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_recursive_mkdir'>recursive_mkdir</span> <span class='id identifier rubyid_final_path'>final_path</span>
645
+
646
+ <span class='comment'>#Generate the new name
647
+ </span> <span class='id identifier rubyid_fileName'>fileName</span> <span class='op'>=</span> <span class='id identifier rubyid_item'>item</span><span class='period'>.</span><span class='id identifier rubyid_name_pattern'>name_pattern</span><span class='period'>.</span><span class='id identifier rubyid_sub'>sub</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>@@</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='id identifier rubyid_itemName'>itemName</span><span class='rparen'>)</span>
648
+
649
+ <span class='comment'>#Read the source file
650
+ </span> <span class='id identifier rubyid_source_text'>source_text</span> <span class='op'>=</span> <span class='const'>IO</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span> <span class='id identifier rubyid_source_full_path'>source_full_path</span>
651
+
652
+ <span class='comment'>#Define the keywords to be replaced in the template
653
+ </span> <span class='id identifier rubyid_keywords'>keywords</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
654
+ <span class='id identifier rubyid_keywords'>keywords</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>@@PACKAGE@@</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_namespace_text'>namespace_text</span>
655
+ <span class='id identifier rubyid_keywords'>keywords</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>@@NAME@@</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_itemName'>itemName</span>
656
+ <span class='comment'>#Replace the keywords in the source text
657
+ </span> <span class='id identifier rubyid_keywords'>keywords</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span>
658
+ <span class='id identifier rubyid_source_text'>source_text</span><span class='period'>.</span><span class='id identifier rubyid_gsub!'>gsub!</span> <span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span> <span class='comment'>#use gsub to teplace all ocurrences
659
+ </span> <span class='kw'>end</span>
660
+ <span class='comment'>#Write out the file
661
+ </span> <span class='id identifier rubyid_outpath'>outpath</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='id identifier rubyid_final_path'>final_path</span><span class='comma'>,</span> <span class='id identifier rubyid_fileName'>fileName</span><span class='rparen'>)</span>
662
+ <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'> =&gt; </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_outpath'>outpath</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span>
663
+ <span class='const'>IO</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span> <span class='id identifier rubyid_outpath'>outpath</span><span class='comma'>,</span> <span class='id identifier rubyid_source_text'>source_text</span>
664
+
665
+ <span class='kw'>else</span> <span class='comment'>#The source file is not found but it was specified in the info.semilla file.
666
+ </span> <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Template file is missing: [</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_item'>item</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='rbrace'>}</span><span class='tstring_content'>]</span><span class='tstring_end'>&quot;</span></span>
667
+ <span class='kw'>end</span>
668
+
669
+ <span class='kw'>end</span>
670
+
671
+ <span class='kw'>end</span></pre>
672
+ </td>
673
+ </tr>
674
+ </table>
675
+ </div>
676
+
677
+ <div class="method_details ">
678
+ <p class="signature " id="parseInfoFile-class_method">
679
+
680
+ + (<tt>Array of <span class='object_link'><a href="SemillaGen/TemplateItem.html" title="SemillaGen::TemplateItem (class)">TemplateItem</a></span></tt>) <strong>parseInfoFile</strong>(path)
681
+
682
+
683
+
684
+ </p><div class="docstring">
685
+ <div class="discussion">
686
+
687
+ <p>Read a info.semilla file. This file contains a description of the files to
688
+ create. Each line has the following format:</p>
689
+
690
+ <pre class="code ruby"><code>filename_pattern : template_file =&gt; target_path
691
+
692
+ filename_pattern = How the generated file should be named.
693
+ template_file = The file whose contents will be used to generate the new file.
694
+ Some keywords inside the text will be replaced
695
+ (@@PACKAGE@@, @@NAME@@)
696
+ target_path = The folder where the file should be created.</code></pre>
697
+
698
+
699
+ </div>
700
+ </div>
701
+ <div class="tags">
702
+ <h3>Parameters:</h3>
703
+ <ul class="param">
704
+
705
+ <li>
706
+
707
+ <span class='name'>The</span>
708
+
709
+
710
+ <span class='type'>(<tt>path</tt>)</span>
711
+
712
+
713
+
714
+ &mdash;
715
+ <div class='inline'>
716
+ <p>path to the info.semilla file to read.</p>
717
+ </div>
718
+
719
+ </li>
720
+
721
+ </ul>
722
+
723
+ <h3>Returns:</h3>
724
+ <ul class="return">
725
+
726
+ <li>
727
+
728
+
729
+ <span class='type'>(<tt>Array of <span class='object_link'><a href="SemillaGen/TemplateItem.html" title="SemillaGen::TemplateItem (class)">TemplateItem</a></span></tt>)</span>
730
+
731
+
732
+
733
+ &mdash;
734
+ <div class='inline'>
735
+ <p>The collection of TemplateItem parsed.</p>
736
+ </div>
737
+
738
+ </li>
739
+
740
+ </ul>
741
+
742
+ </div><table class="source_code">
743
+ <tr>
744
+ <td>
745
+ <pre class="lines">
746
+
747
+
748
+ 59
749
+ 60
750
+ 61
751
+ 62
752
+ 63
753
+ 64
754
+ 65
755
+ 66
756
+ 67
757
+ 68
758
+ 69
759
+ 70
760
+ 71
761
+ 72
762
+ 73
763
+ 74
764
+ 75
765
+ 76
766
+ 77
767
+ 78
768
+ 79
769
+ 80
770
+ 81
771
+ 82
772
+ 83
773
+ 84
774
+ 85
775
+ 86
776
+ 87
777
+ 88</pre>
778
+ </td>
779
+ <td>
780
+ <pre class="code"><span class="info file"># File 'lib/semilla_gen/generator.rb', line 59</span>
781
+
782
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_parseInfoFile'>parseInfoFile</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
783
+
784
+ <span class='id identifier rubyid_files'>files</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
785
+
786
+ <span class='kw'>if</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_exists?'>exists?</span> <span class='id identifier rubyid_path'>path</span>
787
+ <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>r</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span>
788
+ <span class='kw'>while</span><span class='lparen'>(</span><span class='id identifier rubyid_line'>line</span> <span class='op'>=</span> <span class='id identifier rubyid_f'>f</span><span class='period'>.</span><span class='id identifier rubyid_gets'>gets</span><span class='rparen'>)</span>
789
+ <span class='id identifier rubyid_line'>line</span><span class='period'>.</span><span class='id identifier rubyid_strip!'>strip!</span> <span class='comment'>#Remove white space
790
+ </span>
791
+ <span class='kw'>next</span> <span class='kw'>if</span> <span class='id identifier rubyid_line'>line</span><span class='period'>.</span><span class='id identifier rubyid_start_with?'>start_with?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>#</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>or</span> <span class='id identifier rubyid_line'>line</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='comment'>#Skip comments or blank lines
792
+ </span>
793
+ <span class='comment'>#Match &quot;FILENAME =&gt; PATH&quot;
794
+ </span> <span class='id identifier rubyid_line'>line</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>([@\w.\-]+)\s*:\s*([\w.\-]+\.tpl) =&gt; ([\w.\-\/]+)</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_m'>m</span><span class='op'>|</span>
795
+ <span class='id identifier rubyid_nameFormat'>nameFormat</span><span class='comma'>,</span> <span class='id identifier rubyid_sourceFile'>sourceFile</span><span class='comma'>,</span> <span class='id identifier rubyid_targetPath'>targetPath</span> <span class='op'>=</span> <span class='id identifier rubyid_m'>m</span><span class='period'>.</span><span class='id identifier rubyid_captures'>captures</span>
796
+
797
+ <span class='id identifier rubyid_item'>item</span> <span class='op'>=</span> <span class='const'>SemillaGen</span><span class='op'>::</span><span class='const'>TemplateItem</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
798
+ <span class='id identifier rubyid_item'>item</span><span class='period'>.</span><span class='id identifier rubyid_target'>target</span> <span class='op'>=</span> <span class='id identifier rubyid_targetPath'>targetPath</span>
799
+ <span class='id identifier rubyid_item'>item</span><span class='period'>.</span><span class='id identifier rubyid_name_pattern'>name_pattern</span> <span class='op'>=</span> <span class='id identifier rubyid_nameFormat'>nameFormat</span>
800
+ <span class='id identifier rubyid_item'>item</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span> <span class='op'>=</span> <span class='id identifier rubyid_sourceFile'>sourceFile</span>
801
+
802
+ <span class='id identifier rubyid_files'>files</span><span class='lbracket'>[</span><span class='id identifier rubyid_sourceFile'>sourceFile</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_item'>item</span>
803
+ <span class='kw'>end</span>
804
+
805
+ <span class='kw'>end</span>
806
+ <span class='kw'>end</span>
807
+ <span class='kw'>end</span>
808
+
809
+ <span class='kw'>return</span> <span class='id identifier rubyid_files'>files</span>
810
+
811
+ <span class='kw'>end</span></pre>
812
+ </td>
813
+ </tr>
814
+ </table>
815
+ </div>
816
+
817
+ <div class="method_details ">
818
+ <p class="signature " id="recursive_mkdir-class_method">
819
+
820
+ + (<tt>Object</tt>) <strong>recursive_mkdir</strong>(path)
821
+
822
+
823
+
824
+ </p><div class="docstring">
825
+ <div class="discussion">
826
+
827
+ <p>Creates a directory hierarchy for the given directory path if the
828
+ directories do not exist.</p>
829
+
830
+
831
+ </div>
832
+ </div>
833
+ <div class="tags">
834
+ <h3>Parameters:</h3>
835
+ <ul class="param">
836
+
837
+ <li>
838
+
839
+ <span class='name'>The</span>
840
+
841
+
842
+ <span class='type'>(<tt>path</tt>)</span>
843
+
844
+
845
+
846
+ &mdash;
847
+ <div class='inline'>
848
+ <p>path to create if it does not exist already.</p>
849
+ </div>
850
+
851
+ </li>
852
+
853
+ </ul>
854
+
855
+
856
+ </div><table class="source_code">
857
+ <tr>
858
+ <td>
859
+ <pre class="lines">
860
+
861
+
862
+ 96
863
+ 97
864
+ 98
865
+ 99
866
+ 100
867
+ 101
868
+ 102
869
+ 103
870
+ 104
871
+ 105
872
+ 106
873
+ 107
874
+ 108
875
+ 109
876
+ 110
877
+ 111
878
+ 112</pre>
879
+ </td>
880
+ <td>
881
+ <pre class="code"><span class="info file"># File 'lib/semilla_gen/generator.rb', line 96</span>
882
+
883
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_recursive_mkdir'>recursive_mkdir</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
884
+ <span class='id identifier rubyid_steps'>steps</span> <span class='op'>=</span> <span class='id identifier rubyid_path'>path</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span> <span class='const'>File</span><span class='op'>::</span><span class='const'>SEPARATOR</span>
885
+
886
+ <span class='id identifier rubyid_original_dir'>original_dir</span> <span class='op'>=</span> <span class='const'>Dir</span><span class='period'>.</span><span class='id identifier rubyid_pwd'>pwd</span>
887
+
888
+ <span class='id identifier rubyid_steps'>steps</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_s'>s</span><span class='op'>|</span>
889
+ <span class='comment'>#Make dir if it does not exist
890
+ </span> <span class='kw'>if</span> <span class='op'>!</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_directory?'>directory?</span> <span class='id identifier rubyid_s'>s</span>
891
+ <span class='const'>Dir</span><span class='period'>.</span><span class='id identifier rubyid_mkdir'>mkdir</span> <span class='id identifier rubyid_s'>s</span>
892
+ <span class='comment'>#puts &quot;mkdir #{s}&quot;
893
+ </span> <span class='kw'>end</span>
894
+ <span class='const'>Dir</span><span class='period'>.</span><span class='id identifier rubyid_chdir'>chdir</span> <span class='id identifier rubyid_s'>s</span>
895
+ <span class='kw'>end</span>
896
+
897
+ <span class='const'>Dir</span><span class='period'>.</span><span class='id identifier rubyid_chdir'>chdir</span> <span class='id identifier rubyid_original_dir'>original_dir</span>
898
+
899
+ <span class='kw'>end</span></pre>
900
+ </td>
901
+ </tr>
902
+ </table>
903
+ </div>
904
+
905
+ </div>
906
+
907
+ </div>
908
+
909
+ <div id="footer">
910
+ Generated on Fri Mar 30 15:12:43 2012 by
911
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
912
+ 0.7.5 (ruby-1.9.3).
913
+ </div>
914
+
915
+ </body>
916
+ </html>