ratch 0.2.3 → 0.3.0

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 (129) hide show
  1. data/bin/ratch +60 -47
  2. data/bin/ratch-find +21 -0
  3. data/demo/{README → XR} +0 -0
  4. data/demo/task/stats +0 -2
  5. data/doc/images/clipboard.jpg +0 -0
  6. data/doc/images/clipboard2.png +0 -0
  7. data/doc/images/milles-tn.jpg +0 -0
  8. data/doc/images/mints.png +0 -0
  9. data/doc/images/ratch2.png +0 -0
  10. data/doc/images/ruby-sm.png +0 -0
  11. data/doc/images/silver.gif +0 -0
  12. data/doc/images/toolbox.jpg +0 -0
  13. data/doc/index.html +181 -0
  14. data/doc/notes/original.rb +308 -0
  15. data/doc/rdoc/classes/Array.html +194 -0
  16. data/doc/rdoc/classes/Dir.html +317 -0
  17. data/doc/rdoc/classes/Hash.html +217 -0
  18. data/doc/rdoc/classes/Ratch.html +201 -0
  19. data/doc/rdoc/classes/Ratch/ArgvUtils.html +173 -0
  20. data/doc/rdoc/classes/Ratch/ArgvUtils/Ext.html +285 -0
  21. data/doc/rdoc/classes/Ratch/BatchFile.html +207 -0
  22. data/doc/rdoc/classes/Ratch/BatchManager.html +250 -0
  23. data/doc/rdoc/classes/Ratch/BatchScript.html +127 -0
  24. data/doc/rdoc/classes/Ratch/Batchable.html +373 -0
  25. data/doc/rdoc/classes/Ratch/Build.html +321 -0
  26. data/doc/rdoc/classes/Ratch/BuildManager.html +319 -0
  27. data/doc/rdoc/classes/Ratch/Buildable.html +202 -0
  28. data/doc/rdoc/classes/Ratch/ConfigUtils.html +281 -0
  29. data/doc/rdoc/classes/Ratch/ConsoleUtils.html +189 -0
  30. data/doc/rdoc/classes/Ratch/EmailUtils.html +209 -0
  31. data/doc/rdoc/classes/Ratch/FileUtils.html +674 -0
  32. data/doc/rdoc/classes/Ratch/GeneralOptions.html +430 -0
  33. data/doc/rdoc/classes/Ratch/Task.html +201 -0
  34. data/doc/rdoc/classes/Ratch/TaskManager.html +330 -0
  35. data/doc/rdoc/classes/Ratch/Taskable.html +231 -0
  36. data/doc/rdoc/classes/Ratch/UploadUtils.html +566 -0
  37. data/doc/rdoc/created.rid +1 -0
  38. data/doc/rdoc/files/COPYING.html +1003 -0
  39. data/{demo/doc → doc}/rdoc/files/README.html +36 -5
  40. data/doc/rdoc/files/lib/ratch/argvutils_rb.html +131 -0
  41. data/doc/rdoc/files/lib/ratch/batch_rb.html +155 -0
  42. data/doc/rdoc/files/lib/ratch/batchable_rb.html +131 -0
  43. data/doc/rdoc/files/lib/ratch/batchfile_rb.html +148 -0
  44. data/doc/rdoc/files/lib/ratch/buildable_rb.html +131 -0
  45. data/doc/rdoc/files/lib/ratch/consoleutils_rb.html +131 -0
  46. data/{demo/doc/rdoc/files/lib/foo/foo_rb.html → doc/rdoc/files/lib/ratch/emailutils_rb.html} +35 -41
  47. data/doc/rdoc/files/lib/ratch/facets/multiglob_rb.html +137 -0
  48. data/doc/rdoc/files/lib/ratch/fileutils_rb.html +139 -0
  49. data/doc/rdoc/files/lib/ratch/options_rb.html +131 -0
  50. data/doc/rdoc/files/lib/ratch/taskable_rb.html +131 -0
  51. data/doc/rdoc/files/lib/ratch/uploadutils_rb.html +150 -0
  52. data/doc/rdoc/fr_class_index.html +48 -0
  53. data/doc/rdoc/fr_file_index.html +41 -0
  54. data/doc/rdoc/fr_method_index.html +133 -0
  55. data/{demo/doc → doc}/rdoc/index.html +1 -1
  56. data/{demo/doc → doc}/rdoc/rdoc-style.css +0 -0
  57. data/doc/scrap/flexihead-flip.jpg +0 -0
  58. data/doc/scrap/flexihead.jpg +0 -0
  59. data/doc/scrap/head1.jpg +0 -0
  60. data/doc/scrap/ratch.jpg +0 -0
  61. data/doc/scrap/ratch1.png +0 -0
  62. data/doc/scrap/ratch2.jpg +0 -0
  63. data/doc/scrap/ratch3.png +0 -0
  64. data/doc/scrap/red-ratch.jpg +0 -0
  65. data/doc/scrap/redratchet.jpg +0 -0
  66. data/doc/scrap/ruby-kit/ruby.png +0 -0
  67. data/doc/scrap/scrap.red +256 -0
  68. data/doc/sitemap.yaml +10 -0
  69. data/doc/siteparts/index.red +100 -0
  70. data/doc/siteparts/layout.rhtml +56 -0
  71. data/doc/siteparts/tutorial.red +578 -0
  72. data/doc/style.css +112 -0
  73. data/doc/tutorial.html +722 -0
  74. data/lib/ratch/batch.rb +417 -30
  75. data/lib/ratch/{argvutils.rb → batch/argvutils.rb} +27 -19
  76. data/lib/ratch/batch/build.rb +95 -0
  77. data/lib/ratch/{consoleutils.rb → batch/consoleutils.rb} +0 -0
  78. data/lib/ratch/{emailutils.rb → batch/emailutils.rb} +0 -0
  79. data/lib/ratch/{fileutils.rb → batch/fileutils.rb} +32 -32
  80. data/lib/ratch/{options.rb → batch/options.rb} +0 -0
  81. data/lib/ratch/batch/task.rb +43 -0
  82. data/lib/ratch/manager.rb +34 -0
  83. data/lib/ratch/project/information.rb +257 -0
  84. data/lib/ratch/project/package.rb +82 -0
  85. data/lib/ratch/project/project.rb +531 -0
  86. data/lib/ratch/project/release.rb +112 -0
  87. data/lib/ratch/support/filetest.rb +29 -0
  88. data/lib/ratch/support/setuputils.rb +124 -0
  89. data/lib/ratch/support/signiture.rb +252 -0
  90. data/lib/ratch/support/stage.rb +292 -0
  91. data/lib/ratch/toolset/ruby/pack/gem +85 -0
  92. data/lib/ratch/toolset/ruby/pack/tgz +85 -0
  93. data/lib/ratch/toolset/ruby/{crosstest → test/crosstest} +0 -0
  94. data/lib/ratch/toolset/ruby/{extest → test/extest} +0 -0
  95. data/lib/ratch/toolset/ruby/{isotest → test/isotest} +0 -0
  96. data/lib/ratch/toolset/ruby/{load → test/load} +0 -0
  97. data/lib/ratch/toolset/ruby/{loadtest → test/loadtest} +0 -0
  98. data/lib/ratch/toolset/ruby/{syntax → test/syntax} +0 -0
  99. data/lib/ratch/toolset/ruby/{test → test/test} +0 -0
  100. data/log/{history.rd → history} +6 -0
  101. data/log/{todo.rd → todo} +0 -0
  102. data/meta/MANIFEST +52 -36
  103. data/meta/ROLLRC +2 -0
  104. data/meta/icli.yaml +16 -0
  105. data/meta/{ratch-0.2.3.roll → project.yaml} +1 -7
  106. data/task/release +12 -0
  107. data/{lib/ratch → work/old}/batchfile.rb +0 -0
  108. data/work/project-old.rb +67 -0
  109. data/work/scrap/install +89 -0
  110. data/work/scrap/install.0 +49 -0
  111. data/work/scrap/install.1 +63 -0
  112. data/work/scrap/ludo +25 -0
  113. data/work/scrap/oldtaskable.rb +573 -0
  114. data/work/scrap/ratch.man +39 -0
  115. data/work/scrap/taskable-simple.rb +42 -0
  116. data/work/scrap/taskable.rb +120 -0
  117. metadata +170 -72
  118. data/demo/doc/rdoc/created.rid +0 -1
  119. data/demo/doc/rdoc/fr_class_index.html +0 -26
  120. data/demo/doc/rdoc/fr_file_index.html +0 -28
  121. data/demo/doc/rdoc/fr_method_index.html +0 -27
  122. data/demo/task/config.yaml +0 -2
  123. data/lib/ratch/batchable.rb +0 -169
  124. data/lib/ratch/buildable.rb +0 -182
  125. data/lib/ratch/configutils.rb +0 -132
  126. data/lib/ratch/facets/multiglob.rb +0 -160
  127. data/lib/ratch/taskable.rb +0 -152
  128. data/log/recent.rd +0 -8
  129. data/task/config.yaml +0 -10
@@ -0,0 +1,112 @@
1
+
2
+ body {
3
+ padding: 0; margin: 5px;
4
+ background: silver;
5
+ font-size: 1em;
6
+ font-family: microsoft sans-serif, sans-serif, helvetica;
7
+ text-align: center;
8
+ }
9
+
10
+ h1 {
11
+ margin-top: 25px;
12
+ font-size: 2.5em;
13
+ }
14
+
15
+ h1.top {
16
+ margin-top: -10px;
17
+ }
18
+
19
+ h2 {
20
+ margin-top: 25px;
21
+ }
22
+
23
+ p {
24
+ font-size: 1em;
25
+ line-height: 16pt;
26
+ }
27
+
28
+ pre {
29
+ padding: 10px 10px 10px 10px;
30
+ font-size: 0.9em;
31
+ background-color: black;
32
+ color: #00FF00;
33
+ font-weight: bold;
34
+ }
35
+
36
+ a { text-decoration: none; color: #CC0000; }
37
+ a:hover { text-decoration: underline; }
38
+
39
+ pre.script { background-color: #DDFFDD; color: black; }
40
+
41
+ .promenu { font-weight: bold; color: #CC1133; padding-bottom: 5px; }
42
+ .promenu a { color: white; }
43
+
44
+ .container {
45
+ margin: 0 auto;
46
+ width: 740px;
47
+ border: 2px solid #999999;
48
+ }
49
+
50
+ .banner {
51
+ padding: 36px 0px 36px 20px;
52
+ background: transparent;
53
+ text-align: left;
54
+ color: white;
55
+ font-size: 76px;
56
+ font-weight: bold;
57
+ background: url(images/ratch2.png) 300px -10px no-repeat #666666;
58
+ }
59
+
60
+ .menu {
61
+ background: white;
62
+ border-bottom: 1px solid #aaaaaa;
63
+ font-size: 1.2em;
64
+ text-align: left;
65
+ padding-left: 20px;
66
+ line-height: 40px;
67
+ }
68
+
69
+ .menu a {
70
+ color: black;
71
+ text-decoration: none;
72
+ padding: 5px;
73
+ }
74
+
75
+ .menu a:hover {
76
+ color: #CC0000;
77
+ text-decoration: underline;
78
+ }
79
+
80
+ .ad {
81
+ background: white;
82
+ padding-top: 10px;
83
+ }
84
+
85
+ .content {
86
+ padding: 30px;
87
+ text-align: left;
88
+ background: white;
89
+ }
90
+
91
+ .date {
92
+ float:right; color:gray; margin: 0;
93
+ }
94
+
95
+ .copyright {
96
+ text-align: center;
97
+ color: white;
98
+ margin: 0 auto;
99
+ font-size: 0.9em;
100
+ font-weight: bold;
101
+ padding: 30px;
102
+ background: url(images/ratch2.png) -300px -20px no-repeat #666666;
103
+ }
104
+
105
+ .copyright a {
106
+ color: pink;
107
+ }
108
+
109
+ .important {
110
+ color: #FF0033;
111
+ font-weight: bold;
112
+ }
@@ -0,0 +1,722 @@
1
+ <html>
2
+ <head>
3
+ <title>Ratch</title>
4
+ <link href="style.css" rel="stylesheet" type="text/css"/>
5
+ <LINK REL="SHORTCUT ICON" HREF="images/ratch1.png"/>
6
+ </head>
7
+ <body>
8
+
9
+ <div class="promenu">
10
+ ProUtils :: <a href="http://proutils.rubyforge.org/">Home</a> &middot;
11
+ <a href="http://rubyforge.org/news/?group_id=4438">News</a> &middot;
12
+ <a href="http://rubyforge.org/frs/?group_id=4438">Download</a> &middot;
13
+ <a href="http://rubyforge.org/mail/?group_id=4438">Mail</a> &middot;
14
+ <a href="http://rubyforge.org/forum/?group_id=4438">Forum</a> &middot;
15
+ <a href="http://rubyforge.org/scm/?group_id=4438">Source</a> &middot;
16
+ <a href="http://rubyforge.org/tracker/?group_id=4438">Ticket</a>
17
+ </div>
18
+
19
+ <div class="container">
20
+
21
+ <div class="banner">
22
+ RATCH &nbsp;<img src="images/ruby-sm.png"/>
23
+ </div>
24
+
25
+ <div class="menu">
26
+ <a href="index.html">Welcome</a>
27
+ <a href="tutorial.html">Tutorial</a>
28
+ <a href="rdoc/index.html">Library</a>
29
+ </div>
30
+
31
+ <div class="ad">
32
+ <script type="text/javascript"><!--
33
+ google_ad_client = "pub-1126154564663472";
34
+ //RATCH 728x90, 11/8/07
35
+ google_ad_slot = "6500283279";
36
+ google_ad_width = 728;
37
+ google_ad_height = 90;
38
+ //--></script>
39
+ <script type="text/javascript"
40
+ src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
41
+ </script>
42
+ </div>
43
+
44
+ <div class="content">
45
+ <p style="float: right;" class="rev">rev. 9</p>
46
+
47
+
48
+ <h1 class="top">Ratch Tutorial</h1>
49
+
50
+
51
+ <p class="copy">Copyright &copy; 2006 7rans. All Rights Reserved.</p>
52
+
53
+
54
+ <p class="important"><span class="caps">IMPORTANT</span>
55
+ Ratch is still in it&#8217;s infancy as a project. While mostly functional
56
+ in its present state, it is still under going a good bit of design
57
+ considerations, so methods and certain aspects of functionality may
58
+ change. Likewise, documentation is not 100% current.</p>
59
+
60
+
61
+ <h1>Introduction</h1>
62
+
63
+
64
+ <p>Ratch is a Ruby-based batch file system specially designed for handling
65
+ project support and build tasks.</p>
66
+
67
+
68
+ <p>The creation of support and build tools for a project enatils the
69
+ question of whether to simply use shell scripts or rely on a specialized
70
+ build system. The later is almost always the prefered choice. Why?
71
+ Two reasons in particular stand out. First, and perhaps most importantly,
72
+ shell scripts are generally not cross-platform. A shell script on a Linux
73
+ machine may well fail on a Mac X system, and will certainly fail on a Windows
74
+ system. Second, shell scripting lacks dedicated support for the creation of
75
+ build tasks. This is the reason we have tools like Make&#8212;a build tool built
76
+ on top of the Unix shell commands.</p>
77
+
78
+
79
+ <p>Ratch solves these two issues by providing a cross-platform shell scripting
80
+ <span class="caps">DSL</span> based on Ruby. Ratch scripts are really just Ruby scripts. What sets them
81
+ apart from plain Ruby is the convenient Domain Specific Language (DSL) that
82
+ Ratch provides geared specifically toward the needs of project task and
83
+ build task scripting. With Ratch, scripting becomes a viable option again.</p>
84
+
85
+
86
+ <p>Individual task scripts have some clear advantages over monolithic build systems:</p>
87
+
88
+
89
+ <ul>
90
+ <li>Tasks are clearly enumerable and can be viewed like any other file-system folder.</li>
91
+ <li>And like any system script, permissions can be restricted&#8212;per individual task.</li>
92
+ <li>Individual tasks can be easily edited w/o sorting through large &#8220;Makefiles&#8221;.</li>
93
+ <li>Shell-based tools and scripts written in other languages easily coexist.</li>
94
+ </ul>
95
+
96
+
97
+ <p>The only signifficant disadvantage to the script appraoch is the focus on <em>tasks</em>
98
+ rather than <em>builds</em>. In other words one can&#8217;t ask that a particular file be built
99
+ unless some task provides an interface for doing so.</p>
100
+
101
+
102
+ <p>But Ratch provides some</p>
103
+
104
+
105
+ <h2>Getting Started</h2>
106
+
107
+
108
+ <p>If you haven&#8217;t already done so, you&#8217;ll first need to install Ratch.
109
+ The process is straight-forward with RubyGems.</p>
110
+
111
+
112
+ <pre><code>$ gem install ratch</code></pre>
113
+
114
+
115
+ <p>Alternatively you can install from source. Simply, download the package file,
116
+ decompress it, &#8216;cd&#8217; into the package directory and run <code>task/setup</code>.</p>
117
+
118
+
119
+ <pre><code>$ tar -xvzf ratch-1.0.0.gzip
120
+ $ cd ratch-1.0.0
121
+ $ sudo task/setup</code></pre>
122
+
123
+
124
+ <p>Once installed, you can immediately start using Ratch. However, to make life even
125
+ easier, two other tools augment Ratch very nicely. So we recommend that you also
126
+ install <a href="http://reap.rubyforge.org/box">Box</a> and <a href="http://reap.rubyforge.org/mint">Mint</a>.
127
+ Box is meta-packaging system and Mint is managed copy tool. They are optional,
128
+ but parts of this tutorial will also cover their use in relation to Ratch.</p>
129
+
130
+
131
+ <p><img src="images/toolbox.jpg" style="float: right; width: 150px;;" alt="" /></p>
132
+
133
+
134
+ <h1>Task Creation</h1>
135
+
136
+
137
+ <h2>Creating Your First Task</h2>
138
+
139
+
140
+ <p>Let jump right in by creating a Ratch script so you can see just how easy it is.
141
+ First create a faux project dirctory in which to conduct our tutorial. We&#8217;ll call it
142
+ <code>myproject/</code>.</p>
143
+
144
+
145
+ <pre><code>$ mkdir myproject</code></pre>
146
+
147
+
148
+ <p>Now <code>cd</code> into it and create a directory to store your ratch scripts. The name of the directory
149
+ can be anything you like. Ratch doesn&#8217;t require that it have a special name. For the purposes
150
+ of this tutorial we will call it <code>task/</code>.</p>
151
+
152
+
153
+ <pre><code>$ cd myproject
154
+ $ mkdir task</code></pre>
155
+
156
+
157
+ <p>Now lets create a ratch script.</p>
158
+
159
+
160
+ <pre><code>$ vi task/list</code></pre>
161
+
162
+
163
+ <p>This example uses <code>vi</code>. You can use your favorite editor, of course. Now, edit the file to read:</p>
164
+
165
+
166
+ <pre class="script">
167
+ #!/usr/bin/env ratch
168
+
169
+ # List project files
170
+
171
+ puts glob('**/*')
172
+ </pre>
173
+
174
+ <p>Save the file. If you are using a Unix-based operating system, also change the file&#8217;s
175
+ mode to be user executable<sup><a href="#fn2">2</a></sup>.</p>
176
+
177
+
178
+ <pre><code>$ chmod u+x task/list</code></pre>
179
+
180
+
181
+ <p>Now run it like you might any executable file on your system:</p>
182
+
183
+
184
+ <pre><code>$ task/list</code></pre>
185
+
186
+
187
+ <p id="fn2"><sup>2</sup> On Windows systems you do this a little differntly. Instead you need to run the task
188
+ via either of the <code>ruby</code> command. Ie. <code>ruby task/list</code>. You&#8217;ll need to keep
189
+ that in mind throughout this tutorial.</p>
190
+
191
+
192
+ <p>And, as you might have expected, our first task printed a listing of every file in our
193
+ project directory. Pretty simple. Yet there are a few things to notice about this example.</p>
194
+
195
+
196
+ <p>First, the <code>glob</code> command. <code>glob</code> is not a standard main method in Ruby. So this method
197
+ comes instead from the Ratch <span class="caps">DSL</span>. In normal Ruby you&#8217;d have to use <code>Dir.glob</code> to do the same
198
+ thing. Wile a minor difference, this is a simple example of how Ratch makes building project
199
+ tasks easier than just using normal Ruby scripts. There are many more methods provided by
200
+ Ratch&#8217;s <span class="caps">DSL</span>, and we will cover many of them later in this tutorial.</p>
201
+
202
+
203
+ <p>The other thing to notice is that we executed our script like we would any local command,
204
+ and we did so <em>from the project&#8217;s root directory</em>. This is very important. <i>The task will
205
+ act on the directory from which it is called</i>. This can be useful if a task provides
206
+ behavior effective relative to the call location, but it also means we must remain aware
207
+ this versitility, and use our task accordinginly. However, often a task is designed to be
208
+ run only from the project&#8217;s root directory, as we did in our example. In those cases it
209
+ is not uncommon for the task to perform <em>sanity</em> checks to make sure that&#8217;s indeed were a
210
+ task is being run. One thing you should not do though, but may at first be tempted to do,
211
+ is <code>cd</code> down into that task directory and run the tasks from there. Do not do that.
212
+ It won&#8217;t work!!!</p>
213
+
214
+
215
+ <h2>Task and System Calls</h2>
216
+
217
+
218
+ <p>Okay, that&#8217;s our first teeny tiny example. Now&#8217;s its time to dig a little deeper into the
219
+ Ratch <span class="caps">DSL</span>.</p>
220
+
221
+
222
+ <p>One of more unique aspects of Ratch scripts is the way in polymophizes internal method calls,
223
+ external task calls and external command calls. To demonstrate lets define a second task
224
+ called &#8216;list2&#8217;.</p>
225
+
226
+
227
+ <pre><code>$ vi task/list2</code></pre>
228
+
229
+
230
+ <p>Make it read:</p>
231
+
232
+
233
+ <pre class="script">
234
+ #!/usr/bin/env ratch
235
+
236
+ # List project files
237
+
238
+ puts "How many lists?"
239
+ list
240
+ list
241
+ list
242
+ </pre>
243
+
244
+ <p>Be sure to change the mode to user executable, then run it.</p>
245
+
246
+
247
+ <pre><code>$ task/list2</code></pre>
248
+
249
+
250
+ <p>You will notice that calling <code>list2</code>, in turn, calls our first script, <code>list</code>. But it didn&#8217;t generate
251
+ a list three times, as you may have expected, but only once. That&#8217;s because tasks, by definition, are
252
+ only supposed to run once in a given run session. Internally, task results are cached to facilitate this.</p>
253
+
254
+
255
+ <p>Now lets try another example. First, rename <code>last2</code> to <code>rdoc</code></p>
256
+
257
+
258
+ <pre><code>$ mv task/list2 task/rdoc</code></pre>
259
+
260
+
261
+ <p>Then edit it to read:</p>
262
+
263
+
264
+ <pre class="script">
265
+ #!/usr/bin/env ratch
266
+
267
+ # Generate RDocs
268
+
269
+ rdoc "README", 'm' =&gt; true, 'op' =&gt; 'doc'
270
+ </pre>
271
+
272
+ <p>For this example to work we&#8217;ll need to create a <code>README</code> file in project&#8217;s root directory.
273
+ Anything content will do:</p>
274
+
275
+
276
+ <pre><code>$ echo "= Welcome" &gt; README</code></pre>
277
+
278
+
279
+ <p>Now, rather than run the task outright, let&#8217;s see what it would do without actually running the task.
280
+ Ratch provieds a&#8212;dryrun global flag that allows you to check/debug scripts easily.</p>
281
+
282
+
283
+ <pre><code>$ task/rdoc --dryrun
284
+ rdoc -m --op doc lib</code></pre>
285
+
286
+
287
+ <p>Ratch prints out the command that would have been run without the&#8212;dryrun flag. Notice how
288
+ Ratch interpreted the Ruby-esque method call as a commandline tool. It knew this b/c
289
+ 1) there were no methods defined with then name &#8216;rdoc&#8217;, 2) there were not other local tasks
290
+ with the name rdoc (the task&#8217;s own filename does not count), and 3) it looked up the
291
+ systems list of executable files and found &#8216;rdoc&#8217; listed. It then interprets the arguments
292
+ accordingly, the main trick being that any trailing keyword arguments will be truned into
293
+ flag options of the command. However sometimes an external command will have an argument
294
+ usage that Ratch can&#8217;t handle. In thos cases simple trail along argument text. For instance
295
+ the above #rdoc call could have been written in any number of ways:</p>
296
+
297
+
298
+ <pre>
299
+ rdoc "-m --op doc "README"
300
+ rdoc "-m --op doc", "README"
301
+ rdoc "-m", "--op doc", "README"
302
+ </pre>
303
+
304
+ <p>Occasionally, there may be a name conflict bwetween a method and an external task
305
+ or command you wish to use. In those cases you can invoke the task or command using
306
+ either the <code>target</code> or <code>system</code> reference object, respectively. For instance the above
307
+ could have also been written:</p>
308
+
309
+
310
+ <pre><code>system.rdoc "README", 'm' =&gt; true, 'op' =&gt; 'doc'</code></pre>
311
+
312
+
313
+ <p>The two forms are completely equivalent. The former is simply using <code>system</code>
314
+ behined the scenes.</p>
315
+
316
+
317
+ <h2>Integrated Build Tools</h2>
318
+
319
+
320
+ <p>Well Ratch wouldn&#8217;t be much a build tool if it didn&#8217;t facilitate the defintion
321
+ of file creation tasks, beyond simply running shell commands on demand. Ratch
322
+ provides a <span class="caps">DSL</span> method, <code>file</code>, just for this purpose. With it we can rewrite
323
+ the above RDoc task more robustly as:</p>
324
+
325
+
326
+ <pre class="script">
327
+ #!/usr/bin/env ratch
328
+
329
+ # Generate RDocs
330
+
331
+ file 'doc' =&gt; ['README'] do
332
+ rdoc "README", 'm' =&gt; true, 'op' =&gt; 'doc'
333
+ end
334
+
335
+ target 'doc'
336
+ </pre>
337
+
338
+ <p>If you are familiar with Rake or Rant what this does is clear. It says that the
339
+ construction of a target file, in this case a directory called &#8216;doc&#8217;, depends on
340
+ a file &#8216;README&#8217;. What this does in practice is compare the modification times
341
+ of the target and it&#8217;s dependsencies. If <em>any</em> of the dependencies
342
+ have a modification time <em>after</em> the target file&#8217;s, then the target clearly
343
+ needs to be regenerated and so the task will execute. But if <em>none</em> of the
344
+ the dependecies have a last modification time <em>after</em> the targets, the the
345
+ target is considered upto date, and will not be rebuilt.</p>
346
+
347
+
348
+ <p>Note the last line <code>target :doc</code>, which invokes an <em>internal target</em>,
349
+ as opposed to external target which is another task script.</p>
350
+
351
+
352
+ <h2>Task Configuration</h2>
353
+
354
+
355
+ <p>Often a task proves useful enough to be reused in other projects, but to do this requires
356
+ some level of generalization and configurability. Ratch makes this easy to do via the
357
+ #config_load method. With it you can load a set of configuration options tied to a specific
358
+ name. The information can then be an entry in a central <code>config.yaml</code> file in your task
359
+ directory, or it can be in a file by that name, ie. <code>_name_.yaml</code>.</p>
360
+
361
+
362
+ <p>For example, a <code>config.yaml</code> file might look something like:</p>
363
+
364
+
365
+ <pre class="script">
366
+ ---
367
+
368
+ rdoc:
369
+ dir : 'doc/rdoc'
370
+ main : README
371
+
372
+ publish:
373
+ target : rubyforge
374
+ type : web
375
+ host : rubyforge.org
376
+ username : transami
377
+ dir : web
378
+
379
+ release:
380
+ host : rubyforge.org
381
+ username : transami
382
+ project : reap
383
+ groupid : 811
384
+ package : ratch
385
+ dir : pkg
386
+ </pre>
387
+
388
+ <p>In a script one can access this information easily. With it we can define our rdoc task
389
+ like so:</p>
390
+
391
+
392
+ <pre class="script">
393
+ #!/usr/bin/env ratch
394
+
395
+ # Generate RDocs
396
+
397
+ config = load_config('rdoc')
398
+
399
+ output = config['dir']
400
+ include = config['include'] || ['README']
401
+
402
+ file ouput =&gt; include do
403
+ rdoc include, 'm' =&gt; true, 'op' =&gt; output
404
+ end
405
+
406
+ target 'doc'
407
+ </pre>
408
+
409
+ <p>Now our rdoc task is perfectly general (albiet a bit simplistic), we can reuse the same
410
+ task in any project. We only need to change the config.yaml settings per project instead
411
+ of having to make isolated changes to the task itself. In turn this makes it possible to
412
+ readily share task with other project developers.</p>
413
+
414
+
415
+ <h2>Project Info via Box</h2>
416
+
417
+
418
+ <p><img src="images/box.jpg" style="float: left; width: 100px;;" alt="" /></p>
419
+
420
+
421
+ <p>Notice the reference to &#8216;info&#8217;. This is an OpenStruct-like interface to the project information.</p>
422
+
423
+
424
+ <p>It&#8217;s a good idea to take some time and learn all the standard properties of a project&#8217;s information file
425
+ which you can draw on for your own tools. Looking at the RDoc <span class="caps">API</span> documentation will elucidate most of them.
426
+ And, of course you can also invent your own if needed.</p>
427
+
428
+
429
+ <p>As you can see this creates a <i>project information file</i> called <code>ProjectInfo</code>.
430
+ Another, and perhaps better way to create a ProjectInfo file is to copy one from some
431
+ other project and modify it to suit your needs. That makes it easier to learn how to fill
432
+ them out. But if you don&#8217;t have that option or you are already familiar with the layout,
433
+ then you can use <code>mint</code> to copy a new template.</p>
434
+
435
+
436
+ The name of the project information file has some flexibility. Capitalization, for
437
+ instance, is insignifficant; <code>projectinfo</code> would do just as well. Also
438
+ a few alternative namings are supported, namely, <code>project.yaml</code> or just
439
+ <code>PROJECT</code> (again capitalization doesn&#8217;t matter). For simplicity sake we will refer
440
+ to this file as the ProjectInfo file throughout the documentation. Just remember that you
441
+ can substitue any of these other supported names in it&#8217;s place to suit your personal preference.
442
+ If you prefer one of the alternate names when creating the file, you can specify it as
443
+ a parameter of the <code>--info</code> option.
444
+
445
+ $ project new&#8212;info project.yaml
446
+
447
+ <p>Rather then &#8216;ProjectInfo&#8217;, the file will be called &#8216;project.yaml&#8217;. Ratchets will let you know
448
+ if you pick a name it does not recognize.</p>
449
+
450
+
451
+ Once you have edited the ProjectInfo file (more on this in the next section), subsequnelty running
452
+ <code>project new</code> will create the same project layout as before, but it will add
453
+ enhanced details to further ease the creation of the new project. For instance, the lib
454
+ directory will already have subdirectory named appropriately and if you use the&#8212;web option,
455
+ the index.html page will be suitably labeled. And so on.
456
+
457
+ <div class="special"><b><span class="caps">NOTE</span></b> The enhanced information scaffolding is barely
458
+ implemented as of yet. But will continue to improve with future releases.</div>
459
+
460
+ <p>Of course, if you already have a project with which you wish to use Ratchets, rather than
461
+ create a whole new project layout you will probably just want to add the <code>&lt;i&gt;ProjectInfo&lt;/i&gt;</code>
462
+ file to it. In that case you simply run <code>project new --info</code>. The project information file
463
+ will be added and the rest of your project will be undisturbed. Running <code>project new</code> on
464
+ a pre-existing project will have no effect. It will simply report an error that your project
465
+ already has content.</p>
466
+
467
+
468
+ <p>The project file is of central importance to Ratchets and the <code>project</code> command.
469
+ The file is a <span class="caps">YAML</span>-formatted file storing shared information from which Ratchets&#8217; tools gather
470
+ default information on how to perform their actions. Most subsequent activity will largely
471
+ depend on the content of this file. So lets now turn our attention squarely to it.</p>
472
+
473
+
474
+ <p>The structure of the ProjectInfo file is fairly self-explanitory. The header is devoted to
475
+ common information. This is generally followed by deafult tool settings. And lastly
476
+ a <i>tasks</i> section is used to define user tasks. Each task entry is a <span class="caps">YAML</span> map where the
477
+ key represent the task name followed by a private type (!!) which identifies the tool
478
+ it invokes. The next line begins the indented attributes the tool needs to do the job.
479
+ To a detailed list of parameters each tool accepts have a look at the RDoc <span class="caps">API</span>.</p>
480
+
481
+
482
+ <p>Example ProjectInfo File</p>
483
+
484
+
485
+ <pre class="script">
486
+ --- %YAML:1.0
487
+
488
+ title : Reap
489
+ name : reap
490
+
491
+ version : 6.0.0
492
+ status : 'beta'
493
+
494
+ author : Thomas Sawyer
495
+ created : '2004-04-01'
496
+ email : transfirz@zmail.com
497
+ homepage : "http://reap.rubyforge.org"
498
+
499
+ summary : A Ruby Project Management Assistant
500
+
501
+ description: &gt;
502
+ Reap comprises a set of tasks commonly needed by
503
+ Ruby package developers/deployers, such as testing,
504
+ packaging, releasing, etc. You can also use Reap
505
+ to create your own custom tasks. Reap utilizes a
506
+ YAML configuration file to harvest common project
507
+ information, significantly simplifying these chores.
508
+
509
+ rubyforge:
510
+ project : reap
511
+ username : transami
512
+
513
+ revision:
514
+ tool: darcs
515
+ exclude:
516
+ - doc/api
517
+
518
+ executables : [ reap, rubytest ]
519
+
520
+ dependencies:
521
+ - [ facets, '&gt; 1.5' ]
522
+
523
+ exclude:
524
+ - snip
525
+ - doc/api
526
+ </pre>
527
+
528
+ <p>As you can the top portion is fairly self-explainitory. After that we see entries related to
529
+ specific Ratchet tools like package. This entry specifies default parameters to use for any
530
+ subsequent call of the package tool. We will cover this in more detail in the
531
+ <a href="tool.html">Tool Utilization</a> documention.</p>
532
+
533
+
534
+ <p>Following this is the tasks section with which we can define our own user-defined
535
+ tasks. Typically these are specializtions of the buil-in tools,
536
+ but as you can see by our &#8220;silly example&#8221; arbitary tasks can be written as well. We will
537
+ cover this in more detail in the <a href="task.html">Task Management</a> documentation.</p>
538
+
539
+
540
+ <h2>Verifying Project Information</h2>
541
+
542
+
543
+ <p>When Ratchets searches for a ProjectInfo file it will move up the
544
+ directory hierarchy from the current working directory until it finds a ProjectInfo file
545
+ and will assume the location of that file is your project&#8217;s source directory unless the file
546
+ itself specifes that another directory is the source root.</p>
547
+
548
+
549
+ <p>Project has one other subcommand that can be used to verify the project information: <code>info</code>.
550
+ This simply dumps the parsed contents of the ProjectInfo file to stdout.</p>
551
+
552
+
553
+ <pre><code>$ box --dump</code></pre>
554
+
555
+
556
+ <p>This may seem trivial, but it can be sometimes be useful to quicky insure information
557
+ is correct and that you are calling <code>project</code> from an appropriate location. [ed-
558
+ the order of information is arbitrary, so it looks a bit messy. This will be improved
559
+ in a future release.]</p>
560
+
561
+
562
+ <h2>On Your Own</h2>
563
+
564
+
565
+ <p>The rest of building a task is just a matter of writing the code to have
566
+ it do what you want. If you develop any nice tasks, be sure to pass them along!</p>
567
+
568
+
569
+ <p><img src="images/clipboard.jpg" style="float: right; width: 128px;;" alt="" /></p>
570
+
571
+
572
+ <h1>Task Management</h1>
573
+
574
+
575
+ <h2>Listings Tasks</h2>
576
+
577
+
578
+ <p>Of course, it&#8217;s not enough to just create tasks and run them willy-nilly. A good build tool
579
+ will let us see what tasks we have available and what they do. It&#8217;s eay enough to use <code>ls</code>
580
+ or <code>dir</code> to list the targets in the task directory.</p>
581
+
582
+
583
+ <pre><code>$ ls task/
584
+ list</code></pre>
585
+
586
+
587
+ <p>But that only tells us the names of avaialble tasks. What about what the tasks do? Ratch
588
+ comes with a command line tool to faciltiate this called <code>lt</code>. It works much like <code>ls</code>.
589
+ Try it:</p>
590
+
591
+
592
+ <pre><code>$ lt task/
593
+ [/home/me/projects/foo]
594
+ task/list # List project files</code></pre>
595
+
596
+
597
+ <p>So now we know waht the task does as well. Didi you notice where lt got that information?
598
+ It&#8217;s form the first comment line of the ratch script. <code>lt</code> is enven a bit smater than
599
+ this. If you give it an actual script, it will output full help-details, if the script
600
+ provides it. In our case, the <code>list</code> task doesn&#8217;t have further details (it doesn&#8217;t
601
+ really need them), but ew can add some for sample sake.</p>
602
+
603
+
604
+ <p>Edit the <code>list</code> file to look like:</p>
605
+
606
+
607
+ <pre class="script">
608
+ #!/usr/bin/env ratch
609
+
610
+ # List project files
611
+
612
+ # This task simply prints out a list
613
+ # of all the files in the project.
614
+
615
+ puts glob('**/*')
616
+ </pre>
617
+
618
+ <p>Now try:</p>
619
+
620
+
621
+ <pre>
622
+ $ lt task/list
623
+
624
+ List project files
625
+
626
+ This task simply prints out a list
627
+ of all the files in the project.
628
+ </pre>
629
+
630
+ <p>As you can see, in the mode, <code>lt</code> outputs all the comments line at the top of script.
631
+ It stops at the first non-blank, non-commnet line.</p>
632
+
633
+
634
+ <h2>Lookup and Do</h2>
635
+
636
+
637
+ What if I want to run a task script, but I&#8217;m currently way down in the
638
+ project&#8217;s directory tree. I dont want to <code>cd</code> all the way up or type
639
+ <code>../</code> a bunch of times.
640
+
641
+ <p>Sake provides a utility called <code>ludo</code> which stands for
642
+ <i>lookup and do</i>. Just prepend that command to your invocation and it
643
+ will find the executable and execute it.</p>
644
+
645
+
646
+ <pre><code>% ludo task/list</code></pre>
647
+
648
+
649
+ <p>By the way, the <code>ludo</code> command can be used anywhere you like, it is
650
+ not dependent on Sake to work. Albeit you should exercise some caution when doing
651
+ so since <code>ludo</code> actively searches up the directory tree for a script
652
+ to execute.</p>
653
+
654
+
655
+ <p>Sometimes, you may want to lookup and run a command but rather than change directories to
656
+ the where the command match was made you want the task will be run from the current
657
+ directory. You can do that with the&#8212;here switch (or -h for short).</p>
658
+
659
+
660
+ <pre><code>$ ludo -h task/list</code></pre>
661
+
662
+
663
+ <p>This will list all the files relative to the current directory.</p>
664
+
665
+
666
+ <p><img src="images/mints.png" style="float: right;;" alt="" /></p>
667
+
668
+
669
+ <h2>Task Trading via Mint</h2>
670
+
671
+
672
+ <p>Mint is another ProUtil, like Ratch, taht is extermely useful for distributing and resusing Ratch tasks.
673
+ In fact Racth comes with a dozen or so general purpose tasks that you can install to you&#8217;re projects
674
+ right aay using <code>mint</code>.</p>
675
+
676
+
677
+ <pre><code>$ mint -s ratch/setup</code></pre>
678
+
679
+
680
+ <p><img src="images/appendix.png" alt="" /></p>
681
+
682
+
683
+ <h1>Appendix</h1>
684
+
685
+
686
+ <h2>License</h2>
687
+
688
+
689
+ <p>
690
+ Ratcehts<br/>
691
+ Copyright &copy; 2006 Thomas Sawyer</br>
692
+ </p>
693
+
694
+ <p>Ruby/GPL License</p>
695
+
696
+
697
+ <p>This program is free software; you can redistribute it and/or modify
698
+ it under the terms of the Ruby License or <span class="caps">GNU</span> General Public License
699
+ as published by the Free Software Foundation; either version 2 of the
700
+ License, or (at your option) any later version.</p>
701
+
702
+
703
+ <p>This program is distributed in the hope that it will be useful,
704
+ but <span class="caps">WITHOUT ANY WARRANTY</span>; without even the implied warranty of
705
+ <span class="caps">MERCHANTABILITY</span> or <span class="caps">FITNESS FOR A PARTICULAR PURPOSE</span>. See the
706
+ <span class="caps">GNU</span> General Public License for more details.</p>
707
+
708
+
709
+ <p>You should have received a copy of the <span class="caps">GNU</span> General Public License
710
+ along with this program; if not, write to the Free Software
711
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, <span class="caps">MA 02111</span>-1307 <span class="caps">USA</span></p>
712
+ </div>
713
+
714
+ <div class="copyright">
715
+ Ratch, Copyright &copy; 2007 <a href="http://psytower.info">&Psi; &Tau; Corp.</a> <br/><br/>
716
+ Website design by <a href="http://psytower.info/transcode/">TransCrankItOut</a> using <a href="">Webrite</a>!
717
+ </div>
718
+
719
+ </div>
720
+
721
+ </body>
722
+ </html>