quarry 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 (112) hide show
  1. data/CHANGES +6 -0
  2. data/COPYING +344 -0
  3. data/MANIFEST +151 -0
  4. data/METADATA +22 -0
  5. data/NEWS +8 -0
  6. data/README +75 -0
  7. data/VERSION +1 -0
  8. data/bin/rubybreak +3 -0
  9. data/bin/xact-ruby +6 -0
  10. data/demo/spec/demo_check.rb +21 -0
  11. data/demo/spec/demo_outline.rb +25 -0
  12. data/demo/test/demo_run.rb +21 -0
  13. data/doc/manual.html2 +1416 -0
  14. data/doc/rdoc/classes/Assertion.html +101 -0
  15. data/doc/rdoc/classes/Assertion/False.html +132 -0
  16. data/doc/rdoc/classes/Assertion/True.html +137 -0
  17. data/doc/rdoc/classes/Kernel.html +86 -0
  18. data/doc/rdoc/classes/Method.html +137 -0
  19. data/doc/rdoc/classes/Module.html +165 -0
  20. data/doc/rdoc/classes/Object.html +154 -0
  21. data/doc/rdoc/classes/Quarry.html +177 -0
  22. data/doc/rdoc/classes/Quarry/Design.html +170 -0
  23. data/doc/rdoc/classes/Quarry/Design/Specification.html +265 -0
  24. data/doc/rdoc/classes/Quarry/Design/Specification/Context.html +174 -0
  25. data/doc/rdoc/classes/Quarry/MethodProbe.html +267 -0
  26. data/doc/rdoc/classes/Quarry/Mock.html +89 -0
  27. data/doc/rdoc/classes/Quarry/Mock/Object.html +276 -0
  28. data/doc/rdoc/created.rid +1 -0
  29. data/doc/rdoc/files/CHANGES.html +100 -0
  30. data/doc/rdoc/files/COPYING.html +457 -0
  31. data/doc/rdoc/files/MANIFEST.html +630 -0
  32. data/doc/rdoc/files/METADATA.html +92 -0
  33. data/doc/rdoc/files/NEWS.html +99 -0
  34. data/doc/rdoc/files/README.html +171 -0
  35. data/doc/rdoc/files/VERSION.html +96 -0
  36. data/doc/rdoc/files/bin/rubybreak.html +96 -0
  37. data/doc/rdoc/files/bin/xact-ruby.html +92 -0
  38. data/doc/rdoc/files/lib/quarry/assert/must_rb.html +96 -0
  39. data/doc/rdoc/files/lib/quarry/assert/should_rb.html +96 -0
  40. data/doc/rdoc/files/lib/quarry/assertion_rb.html +96 -0
  41. data/doc/rdoc/files/lib/quarry/breakout_rb.html +144 -0
  42. data/doc/rdoc/files/lib/quarry/design/spec_rb.html +100 -0
  43. data/doc/rdoc/files/lib/quarry/document_rb.html +92 -0
  44. data/doc/rdoc/files/lib/quarry/loadmonitor_rb.html +92 -0
  45. data/doc/rdoc/files/lib/quarry/methodprobe_rb.html +111 -0
  46. data/doc/rdoc/files/lib/quarry/mock/object_rb.html +123 -0
  47. data/doc/rdoc/files/lib/quarry/mockery_rb.html +115 -0
  48. data/doc/rdoc/fr_class_index.html +60 -0
  49. data/doc/rdoc/fr_file_index.html +65 -0
  50. data/doc/rdoc/fr_method_index.html +77 -0
  51. data/doc/rdoc/index.html +26 -0
  52. data/doc/rdoc/rdoc-style.css +175 -0
  53. data/doc/ri/Assertion/False/assert-i.yaml +10 -0
  54. data/doc/ri/Assertion/False/cdesc-False.yaml +19 -0
  55. data/doc/ri/Assertion/False/message-i.yaml +10 -0
  56. data/doc/ri/Assertion/True/assert-i.yaml +11 -0
  57. data/doc/ri/Assertion/True/cdesc-True.yaml +24 -0
  58. data/doc/ri/Assertion/True/message-c.yaml +11 -0
  59. data/doc/ri/Assertion/True/message-i.yaml +11 -0
  60. data/doc/ri/Assertion/True/method_missing-i.yaml +11 -0
  61. data/doc/ri/Assertion/True/new-c.yaml +11 -0
  62. data/doc/ri/Assertion/cdesc-Assertion.yaml +17 -0
  63. data/doc/ri/Kernel/cdesc-Kernel.yaml +15 -0
  64. data/doc/ri/Method/cdesc-Method.yaml +18 -0
  65. data/doc/ri/Method/migration-i.yaml +12 -0
  66. data/doc/ri/Method/signature-i.yaml +12 -0
  67. data/doc/ri/Module/cdesc-Module.yaml +21 -0
  68. data/doc/ri/Module/doc-i.yaml +16 -0
  69. data/doc/ri/Module/method_added-i.yaml +10 -0
  70. data/doc/ri/Object/assert%21-i.yaml +14 -0
  71. data/doc/ri/Object/assert-i.yaml +14 -0
  72. data/doc/ri/Object/cdesc-Object.yaml +20 -0
  73. data/doc/ri/Quarry/Design/Specification/Context/after-i.yaml +10 -0
  74. data/doc/ri/Quarry/Design/Specification/Context/before-i.yaml +10 -0
  75. data/doc/ri/Quarry/Design/Specification/Context/cdesc-Context.yaml +24 -0
  76. data/doc/ri/Quarry/Design/Specification/Context/method_missing-i.yaml +10 -0
  77. data/doc/ri/Quarry/Design/Specification/Context/specifications-i.yaml +10 -0
  78. data/doc/ri/Quarry/Design/Specification/cdesc-Specification.yaml +44 -0
  79. data/doc/ri/Quarry/Design/Specification/check-i.yaml +12 -0
  80. data/doc/ri/Quarry/Design/Specification/new-c.yaml +12 -0
  81. data/doc/ri/Quarry/Design/Specification/outline-i.yaml +12 -0
  82. data/doc/ri/Quarry/Design/cdesc-Design.yaml +22 -0
  83. data/doc/ri/Quarry/Design/check-c.yaml +12 -0
  84. data/doc/ri/Quarry/Design/outline-c.yaml +10 -0
  85. data/doc/ri/Quarry/Design/specification-c.yaml +10 -0
  86. data/doc/ri/Quarry/Design/specifications-c.yaml +10 -0
  87. data/doc/ri/Quarry/MethodProbe/cdesc-MethodProbe.yaml +46 -0
  88. data/doc/ri/Quarry/MethodProbe/duckcall-c.yaml +10 -0
  89. data/doc/ri/Quarry/MethodProbe/initialize_copy-i.yaml +10 -0
  90. data/doc/ri/Quarry/MethodProbe/method_missing-i.yaml +10 -0
  91. data/doc/ri/Quarry/MethodProbe/new-c.yaml +10 -0
  92. data/doc/ri/Quarry/Mock/Object/cdesc-Object.yaml +52 -0
  93. data/doc/ri/Quarry/Mock/Object/echo-c.yaml +12 -0
  94. data/doc/ri/Quarry/Mock/Object/keys-c.yaml +12 -0
  95. data/doc/ri/Quarry/Mock/Object/mock-c.yaml +12 -0
  96. data/doc/ri/Quarry/Mock/Object/mocks-c.yaml +10 -0
  97. data/doc/ri/Quarry/Mock/Object/spin-c.yaml +12 -0
  98. data/doc/ri/Quarry/Mock/cdesc-Mock.yaml +15 -0
  99. data/doc/ri/Quarry/Mockery-i.yaml +12 -0
  100. data/doc/ri/Quarry/cdesc-Quarry.yaml +17 -0
  101. data/doc/ri/created.rid +1 -0
  102. data/lib/quarry/assert/must.rb +8 -0
  103. data/lib/quarry/assert/should.rb +9 -0
  104. data/lib/quarry/assertion.rb +95 -0
  105. data/lib/quarry/breakout.rb +45 -0
  106. data/lib/quarry/design/spec.rb +197 -0
  107. data/lib/quarry/document.rb +35 -0
  108. data/lib/quarry/loadmonitor.rb +14 -0
  109. data/lib/quarry/methodprobe.rb +216 -0
  110. data/lib/quarry/mock/object.rb +169 -0
  111. data/lib/quarry/mockery.rb +85 -0
  112. metadata +214 -0
data/METADATA ADDED
@@ -0,0 +1,22 @@
1
+ ---
2
+ project : quarry
3
+ version : 0.3.0
4
+ status : beta
5
+
6
+ title : Quarry
7
+ subtitle : Ruby Development Libraries
8
+ slogan : ALL YOUR BASE ARE BELONG TO RUBY!
9
+ created : 2006-12-16
10
+
11
+
12
+ abstract :
13
+ Quarry is a small collection of libraries to facilitate
14
+ Ruby project development, testing and debugging.
15
+
16
+ copyright : (c) 2007 Tiger Ops & 7rans
17
+
18
+ author : Thomas Sawyer <transfire@gmail.com>
19
+ #email : facets-universal@rubyforge.org
20
+ homepage : 'http://quarry.rubyforge.org'
21
+ download : 'http://rubyforge.org/projects/quarry'
22
+
data/NEWS ADDED
@@ -0,0 +1,8 @@
1
+ = News & Release Notes
2
+
3
+ == 0.3.0 // 2008-08-18
4
+
5
+ This is the first release of quarry. It is still
6
+ quite betaware, however the BDD specification
7
+ system is in a usable state.
8
+
data/README ADDED
@@ -0,0 +1,75 @@
1
+ = Ruby Quarry
2
+
3
+ http://quarry.rubyforge.org
4
+
5
+
6
+ == Introduction
7
+
8
+ Ruby Quarry is a developers testing and debuging suite.
9
+ It features a flexible BDD specification system and
10
+ a number of useful tools.
11
+
12
+
13
+ == Features
14
+
15
+ === Design::Specification
16
+
17
+ Quarry's BBD system is uniqe in two ways. First it utilizes Ruby's
18
+ Execption system to catch Assertions which are define via
19
+ with assertion <i>functors</i>. Eg.
20
+
21
+ require 'quarry/assertion'
22
+
23
+ 4.assert = 5
24
+
25
+ This will raise ans Assertion error. Quarry's design specification
26
+ then is just a measn of outlining and capturing these
27
+ assertions.
28
+
29
+ The sepcification themeleleves are completely freewform. There is
30
+ no enforced nomenclature. Eg.
31
+
32
+ Quarry::Design.spec "Example Specification" do
33
+
34
+ i_will_show "concerning the number 5" do
35
+
36
+ that "5 != 4" do
37
+ 5.assert! == 4
38
+ end
39
+
40
+ but_that "5 == 5" do
41
+ 5.assert == 5
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+
48
+ If you were to run this specification, you would simply see an outline.
49
+
50
+ = Example Specification
51
+ == i_will_show concerning the number 5
52
+ === that 5 != 4
53
+ === but_that 5 == 5
54
+
55
+ If there were errors, we say *-items detaling each.
56
+
57
+
58
+ === MethodProbe
59
+
60
+ MethodProbe (aka the Duck Hunter) is an expiremental project --
61
+ not meant for production use, that can dip-down into a method
62
+ and provide a read-out of the methods it uses. Thus it
63
+ provides a (duck-)signiture of a method. Keep in mind, that
64
+ becuase it is runtime bound it is not perfect. It can miss
65
+ some parts of a method due to conditionals and, albiet rare,
66
+ it can get stung by the halting problem.
67
+
68
+
69
+ == Copying
70
+
71
+ Copyright (c) 2007 Tiger Ops / Thomas Sawyer
72
+
73
+ Quarry is distributed under the terms of the GPLv3.
74
+
75
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ quarry 0.3.0 beta 2008-08-21
data/bin/rubybreak ADDED
@@ -0,0 +1,3 @@
1
+ #! /usr/bin/ruby1.8
2
+
3
+ require 'ratchets/test/break'
data/bin/xact-ruby ADDED
@@ -0,0 +1,6 @@
1
+ #! /usr/bin/ruby
2
+
3
+ load 'rivets/commands/xacto-ruby.rb'
4
+
5
+ Rivets::Xact::RubyCommand.run
6
+
@@ -0,0 +1,21 @@
1
+ require 'quarry/test/spec'
2
+
3
+ Quarry::Design.specification "Example Specification" do
4
+
5
+ demonstrate "basic assertions" do
6
+
7
+ notice_that "4 != 3" do
8
+ 4.must == 3
9
+ end
10
+
11
+ and_that "4.must_not == 4 is false" do
12
+ 4.must_not == 4
13
+ end
14
+
15
+ as_well_as_that "raise ArgumentError does not raise a SyntaxError" do
16
+ lambda{raise ArgumentError}.must.raise? SyntaxError
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,25 @@
1
+ require 'ratchets/spec/design'
2
+
3
+ Ratchets::Design.specification "Example Specification" do
4
+
5
+ demonstrate "basic assertions" do
6
+
7
+ that "4.must == 3 fails" do
8
+ 4.must == 3
9
+ end
10
+
11
+ that "4.must_not == 4 fails" do
12
+ 4.must_not == 4
13
+ end
14
+
15
+ that "raise ArgumentError does not raise a SyntaxError" do
16
+ lambda{raise ArgumentError}.must.raise? SyntaxError
17
+ end
18
+
19
+ end
20
+
21
+ end
22
+
23
+ $no_autocheck = true
24
+
25
+ Ratchets::Design.outline
@@ -0,0 +1,21 @@
1
+ require 'ratchets/test/case'
2
+
3
+ Ratchets::Test.suite "example suite" do
4
+
5
+ test_case "example case" do
6
+
7
+ test "4 should equal 3" do
8
+ 4.assert == 3
9
+ end
10
+
11
+ test "4 should not equal 4" do
12
+ 4.assert_not == 4
13
+ end
14
+
15
+ test "raises syntax error" do
16
+ lambda{raise SyntaxError}.should.raise? SyntaxError
17
+ end
18
+
19
+ end
20
+
21
+ end
data/doc/manual.html2 ADDED
@@ -0,0 +1,1416 @@
1
+ <HTML>
2
+
3
+ <HEAD>
4
+
5
+ <TITLE>Ratchets - User Manual</TITLE>
6
+
7
+ <LINK REL="SHORTCUT ICON" HREF="img/ruby.gif"/>
8
+ <LINK REL="StyleSheet" HREF="style.css" TITLE="Times" TYPE="text/css">
9
+
10
+ <SCRIPT language="javascript" src="js/jquery.js"></script>
11
+
12
+ <SCRIPT type="text/javascript">
13
+ var chapter_count = 0;
14
+
15
+ function chapter(name) {
16
+ chapter_count++;
17
+ document.write('<h1 id="ch' + chapter_count + '">' + chapter_count + '. ' + name + '</h1>');
18
+ $('#table_of_contents').append('<li><a href="#ch' + chapter_count + '">' + name + '</a></li>');
19
+ };
20
+
21
+ var view_mode = false;
22
+
23
+ function toc_toggle() {
24
+ if(view_mode) {
25
+ $('#text').css('margin-left','260px');
26
+ $('#toc').show();
27
+ view_mode = false;
28
+ } else {
29
+ $('#toc').hide();
30
+ $('#text').css('margin-left','20px');
31
+ view_mode = true;
32
+ };
33
+ };
34
+ </SCRIPT>
35
+
36
+ </HEAD>
37
+ <BODY>
38
+
39
+ <div id="toggle" style="position: fixed; top: 0; left: 0;">
40
+ <a href="javascript: toc_toggle();"><img src="img/icon/book.jpg" height="30px;" style="border: none;"/></a>
41
+ </div>
42
+
43
+
44
+ <!-- Side Table of Contents -->
45
+
46
+ <div id="toc">
47
+ <img src="img/icon/book.jpg" align="left" style="padding-right: 10px;"/>
48
+ <h1>Ratchets</h1>
49
+ <h2>User Manual</h2><br/>
50
+ <b>Table of Contents</b>
51
+ <ol id="table_of_contents"></ol>
52
+ <div id="copy">Copyright &copy; 2006 Thomas Sawyer.<br/>All Rights Reserved.</div>
53
+ </div>
54
+
55
+
56
+
57
+ <div id="text">
58
+
59
+ <!-- Title -->
60
+
61
+ <div id="booktitle" style="text-align: left;">
62
+ <div id="title1">RATCHETS</div>
63
+ <div id="title2">User Manual</div>
64
+ <br/>
65
+ <div>&nbsp;rev. <span id="rev">9</span> (~<span id="rev">75%</span>) </div>
66
+ </div>
67
+
68
+ <div id="copy">Copyright &copy; 2006 Thomas Sawyer. All Rights Reserved.</div>
69
+
70
+
71
+ <!-- Introduction -->
72
+
73
+ <div id="intro" class="section" style="margin-top: 40px;">
74
+
75
+ <div class="part">Introduction</div>
76
+
77
+
78
+ <script type="text/javascript"> chapter('Introducing Ratchets'); </script>
79
+
80
+ <p>Ratchets started life as <i>Reap</i>, a project assistant application born of a complex Rakefile.
81
+ Rake is the most widely used task tool for Ruby, but over time, small implementations details led
82
+ Reap to become it's own independent build system. Reap was a great tool, but it was still very much
83
+ a work in progress... a program in search of it's source.</p>
84
+
85
+ <p>Then one day, while working on Ratchets' sister project <a href="http://facets.rubyforge.org">Facets</a>
86
+ inspiration struck. The key to the "new Reap" is the same as Facets. Just as Facets is a collection of
87
+ programming tools, so too the "new Reap" would be a collection of project tools. These tools could
88
+ be called upon by any program, including utilities Ratcehts would provide, but first and foremost
89
+ it would be a library. And thus Ratchets was born.</p>
90
+
91
+ <p>Ratchet's features:</p>
92
+
93
+ <ul>
94
+ <li>Reuable collection of project management tools.</li>
95
+ <li>Tools can get settings from a central project information store.</li>
96
+ <li>Tools are accessable via a command-line utility.</li>
97
+ <li>Promotes convention over configuration, but still remains flexible.</li>
98
+ </ul>
99
+
100
+ <div class="special"><b>IMPORTANT!</b> This documentation is not yet complete. If you look at the
101
+ header at the top of the page, you will see a rev. number. Beside the rev. number is an approx.
102
+ percentage of completion. Keep that in figure in mind as you read through the documentation.
103
+ Thanks.</div>
104
+
105
+
106
+ <script type="text/javascript"> chapter('Getting Started'); </script>
107
+
108
+ <p>If you haven't already done so, you'll first need to install Ratchets.
109
+ The process is straight-forward. Download the package file, decompress it,
110
+ 'cd' into the package directory and run <code>setup.rb</code>. Eg.</p>
111
+
112
+ <pre>
113
+ $ tar -xvzf ratchets-0.7.0.gzip
114
+ $ cd ratchets-0.7.0
115
+ $ sudo ruby setup.rb
116
+ </pre>
117
+
118
+ <p>Alternatively you can install the gem.</p>
119
+
120
+ <pre>
121
+ $ gem install ratchets
122
+ </pre>
123
+
124
+ <p>Once installed you can immediately start using Ratchets. Here's the down low.</p>
125
+
126
+ <p>Rathcets has a command line tool called, simply enough, <code>project</code>.
127
+ While there are a few other commands you'll eventually want to know about, this
128
+ is the main facility. You can use <code>project --help</code> to familiarize yourself
129
+ with some of it's capability.</p>
130
+
131
+ <p>In general the first argument given to <code>project</code> is either the name
132
+ of a built-in tool or the name of a user-defined task, followed by any extra
133
+ information to effect the results of the script/task.</p>
134
+
135
+ <!--
136
+ TODO!!!!
137
+ <p>While you can use the project command as a fully independent command,
138
+ a <i>ProjectInfo</i> file ...
139
+ </p>
140
+ -->
141
+
142
+ </div>
143
+
144
+
145
+ <!-- Project Generation -->
146
+
147
+ <div id="proj" class="section">
148
+
149
+ <img src="img/radio_earth.jpg" align="right" style="padding: 0 10px;"/>
150
+
151
+ <div class="part">Part I</div> <div id="title1" style="color: #44ee33;">Project Generation</div>
152
+
153
+
154
+ <script type="text/javascript"> chapter('Creating a New Project'); </script>
155
+
156
+ <p>As mentioned at the end of the previous chapter, Ratchets is utilized primarily through
157
+ the <code>project</code> command-line interface. By supplying this command the name of a
158
+ "ratchet" with subsequent options we activate various build procedures.</p>
159
+
160
+ <p>The first "ratchet" we will cover, as it is likely the first anyone will need,
161
+ is <code>new</code>. The new tool is be used to generate new project scaffolding
162
+ or add additional <i>parts</i> to an existing project.</p>
163
+
164
+ <p>Let look at creating a whole new project. To do this, first create a directory for the
165
+ new project, <code>cd</code> into it, then invoke <code>project new</code>.</p>
166
+
167
+ <pre>
168
+ $ mkdir myproject
169
+ $ cd myproject
170
+ $ project new
171
+ Project ready.
172
+ </pre>
173
+
174
+ <p>And just like that, a standard Ruby project layout is created. If you look at the contents of the directory
175
+ you will see conventional folders like <code>bin/ lib/</code> and <code>data/</code>. The conventions
176
+ followed are according to those established by Minero Akoi's
177
+ <a href="http://i.loveruby.net/en/projects/setup/doc/">setup.rb</a>. If you are relatively new to Ruby
178
+ it is a good idea to familiarize yourself with this material.</p>
179
+
180
+ <p>Besides the standard layout, <code>new</code> can also create a subversion layout which includes
181
+ the associated <code>branches tags trunk</code> tier. Simply specify the option as <code>--svn</code>
182
+ or <code>--subversion</code> after <code>new</code>.
183
+
184
+ <pre>
185
+ $ project new --svn
186
+ </pre>
187
+
188
+ <p>With or without the subversion tier, <code>new</code> also has a website layout option,
189
+ <code>--web</code>, which will create an additional tier with an <code>index.html</code> file and
190
+ some other website related structure, placing the source repository in a <code>src</code> subdirectory.
191
+ This is a great way to layout a project, btw.</p>
192
+
193
+ <p>The <code>new</code> command can create even better project scaffolding if we first provide
194
+ some information about our project. To do that we must first create a <i>project information file</i>.
195
+ The information in this file can then be used by Ratchets to enhance the new project's scaffolding.</p>
196
+
197
+ <pre>
198
+ $ mkdir myproject
199
+ $ cd myproject
200
+ $ project new --info
201
+ CREATED: ProjectInfo
202
+ Please edit the file to suit your project.
203
+ </pre>
204
+
205
+ <p>As you can see this creates a <i>project information file</i> called <code>ProjectInfo</code>.
206
+ Another, and perhaps better way to create a ProjectInfo file is to copy one from some
207
+ other project and modify it to suit your needs. That makes it easier to learn how to fill
208
+ them out. But if you don't have that option or you are already familiar with the layout,
209
+ then you can use the <code>new</code> command create a blank template.</p>
210
+
211
+ <p>The name of the project information file has some flexibility. Capitalization, for
212
+ instance, is insignifficant; <code>projectinfo</code> would do just as well. Also
213
+ a few alternative namings are supported, namely, <code>project.yaml</code> or just
214
+ <code>PROJECT</code> (again capitalization doesn't matter). For simplicity sake we will refer
215
+ to this file as the ProjectInfo file throughout the documentation. Just remember that you
216
+ can substitue any of these other supported names in it's place to suit your personal preference.
217
+ If you prefer one of the alternate names when creating the file, you can specify it as
218
+ a parameter of the <code>--info</code> option.</p>
219
+
220
+ <pre>
221
+ $ project new --info project.yaml
222
+ </pre>
223
+
224
+ <p>Rather then 'ProjectInfo', the file will be called 'project.yaml'. Ratchets will let you know
225
+ if you pick a name it does not recognize.</p>
226
+
227
+ <p>Once you have edited the ProjectInfo file (more on this in the next section), subsequnelty running
228
+ <code>project new</code> will create the same project layout as before, but it will add
229
+ enhanced details to further ease the creation of the new project. For instance, the lib
230
+ directory will already have subdirectory named appropriately and if you use the --web option,
231
+ the index.html page will be suitably labeled. And so on.</p>
232
+
233
+ <div class="special"><b>NOTE</b> The enhanced information scaffolding is barely
234
+ implemented as of yet. But will continue to improve with future releases.</div>
235
+
236
+ <p>Of course, if you already have a project with which you wish to use Ratchets, rather than
237
+ create a whole new project layout you will probably just want to add the <code><i>ProjectInfo</i></code>
238
+ file to it. In that case you simply run <code>project new --info</code>. The project information file
239
+ will be added and the rest of your project will be undisturbed. Running <code>project new</code> on
240
+ a pre-existing project will have no effect. It will simply report an error that your project
241
+ already has content.</p>
242
+
243
+ <div class="special"><b>IMPORTANT!</b> Currently there is a small
244
+ problem with automatic scaffolding. If you are using an <code>svn</code> and/or a <code>web</code>
245
+ project layout be sure to add <code>basedir: src</code>, <code>basedir: trunk</code> or
246
+ <code>basedir: src/trunk</code> to the project information file depending on which combination
247
+ of layout you are using. Or opionally you can move the project information file to the source
248
+ directory and utilize it from there rather than the top-most tier. We will fix this issue in a
249
+ future release.</div>
250
+
251
+ <p>The project file is of central importance to Ratchets and the <code>project</code> command.
252
+ The file is a YAML-formatted file storing shared information from which Ratchets' tools gather
253
+ default information on how to perform their actions. Most subsequent activity will largely
254
+ depend on the content of this file. So lets now turn our attention squarely to it.</p>
255
+
256
+
257
+ <script type="text/javascript"> chapter('The ProjectInfo File'); </script>
258
+
259
+ <p>The structure of the ProjectInfo file is fairly self-explanitory. The header is devoted to
260
+ common information. This is generally followed by deafult tool settings. And lastly
261
+ a <i>tasks</i> section is used to define user tasks. Each task entry is a YAML map where the
262
+ key represent the task name followed by a private type (!!) which identifies the tool
263
+ it invokes. The next line begins the indented attributes the tool needs to do the job.
264
+ To a detailed list of parameters each tool accepts have a look at the RDoc API.</p>
265
+
266
+ <b>Example ProjectInfo File</b><br/>
267
+
268
+ <pre>
269
+ --- %YAML:1.0
270
+
271
+ title : Reap
272
+ name : reap
273
+
274
+ version : 6.0.0
275
+ status : 'beta'
276
+
277
+ author : Thomas Sawyer
278
+ created : '2004-04-01'
279
+ email : transfirz@zmail.com
280
+ homepage : "http://reap.rubyforge.org"
281
+
282
+ summary : A Ruby Project Management Assistant
283
+
284
+ description: >
285
+ Reap comprises a set of tasks commonly needed by
286
+ Ruby package developers/deployers, such as testing,
287
+ packaging, releasing, etc. You can also use Reap
288
+ to create your own custom tasks. Reap utilizes a
289
+ YAML configuration file to harvest common project
290
+ information, significantly simplifying these chores.
291
+
292
+ rubyforge:
293
+ project : reap
294
+ username : transami
295
+
296
+ revision:
297
+ tool: darcs
298
+ exclude:
299
+ - doc/api
300
+
301
+ package:
302
+ executables : [ reap, rubytest ]
303
+ dependencies:
304
+ - [ facets, '> 1.5' ]
305
+ exclude:
306
+ - snip
307
+ - doc/api
308
+
309
+ tasks:
310
+
311
+ foo: !!ruby
312
+ script: |
313
+ puts "Foo it is!"
314
+
315
+ </pre>
316
+
317
+ <p>As you can the top portion is fairly self-explainitory. After that we see entries related to
318
+ specific Ratchet tools like package. This entry specifies default parameters to use for any
319
+ subsequent call of the package tool. We will cover this in more detail in the
320
+ <a href="tool.html">Tool Utilization</a> documention.</p>
321
+
322
+ <p>Following this is the tasks section with which we can
323
+ define our own user-defined tasks. Typically these are specializtions of the buil-in tools,
324
+ but as you can see by our "silly example" arbitary tasks can be written as well. We will
325
+ cover this in more detail in the <a href="task.html">Task Management</a> documentation.</p>
326
+
327
+
328
+ <script type="text/javascript"> chapter('Verifying Project Information'); </script>
329
+
330
+ <p>When Ratchets searches for a ProjectInfo file it will move up the
331
+ directory hierarchy from the current working directory until it finds a ProjectInfo file
332
+ and will assume the location of that file is your project's source directory unless the file
333
+ itself specifes that another directory is the source root.</p>
334
+
335
+ <p>Project has one other subcommand that can be used to verify the project information: <code>info</code>.
336
+ This simply dumps the parsed contents of the ProjectInfo file to stdout.</p>
337
+
338
+ <pre>
339
+ $ project info
340
+ </pre>
341
+
342
+ <p>This may seem trivial, but it can be sometimes be useful to quicky insure information
343
+ is correct and that you are calling <code>project</code> from an appropriate location. [ed-
344
+ the order of information is arbitrary, so it looks a bit messy. This will be improved
345
+ in a future release.]</p>
346
+
347
+ </div>
348
+
349
+
350
+ <!-- Task Management -->
351
+
352
+ <div id="task" class="section">
353
+
354
+ <img src="img/clipboard2.png" align="right" style="margin-top: -75px; padding: 10px;"/>
355
+
356
+ <div class="part">Part II</div>
357
+
358
+ <div id="title1" style="color: #884444;">Task Management</div>
359
+
360
+
361
+ <script type="text/javascript"> chapter('Task Versitility'); </script>
362
+
363
+ <p>Ratchets is a very versitile application. Ratchets supports a number of techniques
364
+ for utilizing it's built-in tools and defining new tasks. Depedending on the desired usage,
365
+ Ratchets can be a build tool <i>library</i>, or taking advantage of it's own system, can
366
+ be used as a build tool in its own right.</p>
367
+
368
+ <p>One easily adopted usage of Ratchets is as a build library invoked from Rake.
369
+ Rake is the prevalent build tool for Ruby, and an excellent one at that. Ratchets
370
+ tools can be easily called from any application, so calling them from a Rake task
371
+ is a natural endeavor. Ratchets goes a step further in its support of Rake however
372
+ by allowing the built-in tools to be setup as Rake tasks automatically.
373
+ If this is intended usage jump down to <a href="#ch4">Ratchets a la Rake</a>
374
+ to learn more.</p>
375
+
376
+ <p>On the other hand, forgoing a separate build tool, tasks can instead be defined
377
+ as YAML descriptors and invoked via thae <code>project</code> command-line utility.
378
+ This makes tasks extremely easy to read and write, and allows project information
379
+ and task definitions to be jointly located but still universally accessible as
380
+ pure data. We will cover this usage in <a href="#ch2">Describing Tasks
381
+ via YAML</a>.</p>
382
+
383
+ <p>The other alternative, which we will discuss last, is for tasks to be defined as
384
+ stand-alone executables. This approach is in the spirit of Unix --it's favor of many
385
+ small tools over single monolithic applications. Ratchets provides strong support
386
+ for this mode of operation, which we have dubbed the <a href="#ch3">Sake Technique</a>.
387
+ [ed- In fact, it is my prefered usage.]</p>
388
+
389
+ <p>In any case, no matter which technique is used. The centralized data resource
390
+ for project information is readily available. This <i>reapability</i> of
391
+ information, probably more than any other feature, makes Ratchets so effective.</p>
392
+
393
+ <div class="special">
394
+ <b>SIDE NOTE</b> The terms <i>tool</i> and <i>task</i> are often used interchangably.
395
+ Loosly speaking a tool is a built-in task, and a task is a user-defined tool.
396
+ Furthermore, <i>tool</i> will generally be the term used when calling upon
397
+ Ratchets as a library, whereas <i>task</i> is used when referring to an invocation
398
+ of the Ratchets command-line utility <code>project</code>. In other words, these are
399
+ rules of thumb and not hard distinctions.
400
+ </div>
401
+
402
+
403
+ <!--
404
+
405
+ <p>The conversion is almost seemless. The task class needs only conform to some simple conventions (in this case
406
+ for example you can see the package_file.include needs to be reduced to a single 'include' attribnute) which are farily
407
+ trivial to implement. This format has been a big hit with Reap's users. Of course it's optional, one can still do
408
+ everything through the Reapfile (but why?).</p>
409
+
410
+
411
+ <h2>Sake may have some nice built-in tasks, but we use Rake. So what good is it?</h2>
412
+
413
+ <p>Sake's unix style of many small scripts is fairly orthongonal to Rake's,
414
+ So you can still call upon Sake's built-in scripts in your Rakefile, if you so prefer.
415
+ Check it out:</p>
416
+
417
+ <pre>
418
+ require 'sake/project'
419
+
420
+ desc "Generate RDocs"
421
+
422
+ task :rdoc do
423
+ Automation.rdoc do |s|
424
+ s.template = 'jamis'
425
+ s.include = 'lib/**/*'
426
+ end
427
+ end
428
+ </pre>
429
+
430
+ <p>Of course, you don't have to use Reap's task system. You can still use Rake's for all your project tasks if
431
+ you prefer or for some reason must, and you can still get Reap's task functionality. Reap provides a simple interface
432
+ for doing this. Here's an example of a Rakefile using Reap.</p>
433
+
434
+ <pre>
435
+ require 'reap/reap'
436
+
437
+ task_package 'pack' do |pkg|
438
+ pkg.distribute = [ 'gem' ]
439
+ pkg.dependencies = [ facets ]
440
+ end
441
+ </pre>
442
+
443
+ <p>In the above, all information is provided directly via the Ruby task code. No information is coming from the
444
+ projectinfo file (same is tru for a Reapfile). But you can also use Rake while utilizing the projectinfo file if
445
+ you wish. In your Rakefile simple put:</p>
446
+
447
+ <pre>
448
+ require 'reap/rake'
449
+ </pre>
450
+
451
+ <p>Then all the tasks defined in the projectinfo file will be available via Rake. You can still add additional
452
+ Rake tasks, of course.</p>
453
+
454
+ <p>Reap can be used in the same fashion as Rake. Simply create a Reapfile and use the <code>reap</code>
455
+ command to utilize your tasks.</p>
456
+
457
+ <p>Adding a extra Reap task is pretty easy. Just define a task in a the special <i>meta/reapfile</i>.
458
+ If you have ever created a task in Rake's 'Rakefile' then you know how to do it here too. A simple
459
+ task would look like this:</p>
460
+
461
+ <pre>
462
+ desc "My special task"
463
+ task :hello do
464
+ puts "Hello, World!"
465
+ end
466
+ </pre>
467
+
468
+ <p>You may not like keeping a "monolithic" file of tasks and instead prefer to keep a collection of
469
+ individual task scripts. You can do this by placing your script in the <i>meta/tasks</i> folder and
470
+ encapsulating your task defintion in the Tasks module.</p>
471
+
472
+ <pre>
473
+ module Tasks
474
+
475
+ desc "My special task"
476
+ task :hello do
477
+ puts "Hello, World!"
478
+ end
479
+
480
+ end
481
+ </pre>
482
+
483
+ -->
484
+
485
+
486
+ <script type="text/javascript"> chapter('Describing Tasks with YAML'); </script>
487
+
488
+ <!-- <h2 id="ch3">YAML Task Descriptors</h2> -->
489
+
490
+ <p>You can define tasks using YAML <i>descriptors</i>. These can be placed directly in
491
+ the ProjectInfo file unders a <code>tasks:</code> section. Or kept in a separate file
492
+ called <code>tasks</code>.</p>
493
+
494
+ <pre>
495
+
496
+ # Example tasks file
497
+
498
+ --- %YAML:1.0
499
+
500
+ package: !!package
501
+ distribute : [ tar.bz2, gem, deb ]
502
+ dir: '../package'
503
+
504
+ release: !!release
505
+ host : rubyforge.org
506
+ username : transami
507
+ project : reap
508
+ groupid : 811
509
+ package : Reap
510
+ dir : '../DISTRIBUTION'
511
+
512
+ publish: !!publish
513
+ target : rubyforge
514
+ type : web
515
+ host : rubyforge.org
516
+ username : transami
517
+ dir : web
518
+
519
+ rdoc: !!rdoc
520
+ dir: 'web/doc/api'
521
+ main: README
522
+
523
+ announce: !!announce
524
+ to : ruby-talk@ruby-lang.org
525
+ from : &amp;email transfirz@zmail.com
526
+ domain : unit.rubyforge.org
527
+ server : smtp.gmail.com
528
+ port : 587
529
+ account : *email
530
+ type : login # cram_md5, plain
531
+ security : tls # ~, tls, ssl (not working yet)
532
+ file : doc/LATEST # file contains announcement
533
+ slogan : REAP THE REWARDS!
534
+ links : []
535
+
536
+ </pre>
537
+
538
+ <p>Once you tasks are defined you can see what tasks are ready to run simply by
539
+ typing <code>project</code> without any arguments into the command line.
540
+ For example you might see something like:</p>
541
+
542
+ <pre>
543
+ ~/myproj$ project
544
+ [from /home/foome/myprojects/foosys]
545
+ announce Email project announcement.
546
+ doap Generate DOAP project file.
547
+ extest Extract unit-tests from script comments.
548
+ info Display the ProjectInfo file.
549
+ install Locally install package using setup.rb.
550
+ package Build distribution packages.
551
+ publish Publish documents to the web.
552
+ rdoc Generate API Documentation.
553
+ release Release distribution files.
554
+ test Run unit-tests (each in a separate process).
555
+ </pre>
556
+
557
+ <p>To run a task specifiy the name of the task to project, eg. <code>project announce</code>.
558
+ Task names take precedence over build script names.</p>
559
+
560
+
561
+ <script type="text/javascript"> chapter('Ratchets a la Rake'); </script>
562
+
563
+ <p>Using Ratchets via Rake is staright-forward, but can be approached in either of two ways.</p>
564
+
565
+ <p>Since Ratchets' project tools are designed as stand-alone reusable modules, one can
566
+ access them directly. For instance let's define an RDoc task by calling directly on
567
+ Ratcehts' <code>Doc.rdoc</code> module method.</p>
568
+
569
+ <pre>
570
+ require 'ratchets/doc'
571
+
572
+ desc 'rdoc the project'
573
+
574
+ task :rdoc do
575
+ Ratchets::Doc.rdoc do |r|
576
+ r.title = "MyApplication"
577
+ r.main = "README"
578
+ r.template = "html"
579
+ r.options = ["--all", "--inline-source"]
580
+ r.include = ["lib/**/*", "bin/*", "[A-Z]*"]
581
+ r.basedir = "src"
582
+ r.output = "rdoc"
583
+ end
584
+ end
585
+ </pre>
586
+
587
+ <p>This usage leaves everything up to the the Rake file. Although most of these fields have reasonable
588
+ defaults. Nonetheless, no information is being provided to the tool via a project information file,
589
+ becuase we are invoking Ratchet's underlying rdoc tool directly.</p>
590
+
591
+ <p>Now let's do the same thing, but via the Project class.</p>
592
+
593
+ <pre>
594
+ require 'ratchets/project'
595
+
596
+ project = Project.new do |info|
597
+ info.title = "MyApplication"
598
+ info.basedir = "src"
599
+ end
600
+
601
+
602
+ desc 'rdoc the project'
603
+
604
+ task :rdoc do
605
+ project.rdoc do |r|
606
+ r.main = "README"
607
+ r.template = "html"
608
+ r.options = ["--all", "--inline-source"]
609
+ r.include = ["lib/**/*", "bin/*", "[A-Z]*"]
610
+ r.output = "rdoc"
611
+ end
612
+ end
613
+ </pre>
614
+
615
+ <p>Here we have created a new Project object and have invoked the rdoc tool <i>via</i> it's interface.
616
+ This automatically incorporates general information about the project of use to the tool --in this case
617
+ the project's title and it's basedir. The other fields are rdoc specific so they cannot be shared.
618
+ But we can go a step further and define a set of <i>tool specific defaults</i> for any rdoc task.</p>
619
+
620
+ <pre>
621
+ require 'ratchets/project'
622
+
623
+ project = Project.new(
624
+ :title => "MyApplication"
625
+ :basedir => "src"
626
+ :rdoc => {
627
+ :main => 'README'
628
+ :template => "html"
629
+ :options => ["--all", "--inline-source"]
630
+ :include => ["lib/**/*", "bin/*", "[A-Z]*"]
631
+ :output => "rdoc"
632
+ }
633
+ )
634
+
635
+
636
+ desc 'rdoc the project'
637
+
638
+ task :rdoc do
639
+ project.rdoc
640
+ end
641
+ </pre>
642
+
643
+ <p>You'll also notice that we are demonstrating Ratchet's versitility in accepting arguments.
644
+ The <code>Project.new</code> method can take either a hash <u>or</u> a block. In fact, this is
645
+ a widely used pattern throughout Ratchets.</p>
646
+
647
+ <p>One final step. It's is likely we don't need to fuss with each and every tool Ratchets
648
+ provides us. All-in-all we will probably want most, if not all, of them avaialble to us, and
649
+ since Ratcehts generally provides reasonable defaults for most fields, we will rarely have
650
+ to explicitly fill out each one. In fact, every field we gave thus far for rdoc, except
651
+ title and basedir, are the default settings. So to facilitate this, the project class has an
652
+ <code>autonew</code> method which automatically generates all the tasks for every project tool
653
+ Ratchets offers.</p>
654
+
655
+ <pre>
656
+ require 'ratchets/project'
657
+
658
+ project = Project.autonew(
659
+ :title => "MyApplication"
660
+ :basedir => "src"
661
+ )
662
+ </pre>
663
+
664
+ <p>Now when you invoke <code>Rake -T</code> you will see a good sized list of available tasks.</p>
665
+
666
+ <p>The techinque as discussed thus far is quite usable, and those heavily favoring pure Rake usage
667
+ may wish to venture no further than right here. But there are is one final variation that has
668
+ it's own benefits. Rather then store the project information as Ruby code within one's Rakefile,
669
+ the information can be placed in a separate <i>ProjectInfo</i> file (something you are already
670
+ familiar with if you read about Project Generation). To utilize this file, instead of using the
671
+ <code>new</code> or <code>autonew</code> methods you instead use the <code>load</code> and
672
+ <code>autoload</code> methods. The upshot is that your typical Rakefile may have little more
673
+ than these two-lines:</p>
674
+
675
+ <pre>
676
+ require 'ratchets/project'
677
+ Project.autoload
678
+ </pre>
679
+
680
+
681
+ <script type="text/javascript"> chapter('The "Sake" Technique'); </script>
682
+
683
+ <p>Sake follows a non-centralized model of design. As such, Sake is essentially a collection of
684
+ tools that make it easy to create your own sand-alone task scripts. Here's a basic example
685
+ session of how such tasks are utilized.</p>
686
+
687
+ <pre>
688
+ $ cd sake/src
689
+
690
+ $ ls
691
+ bin data doc ProjectInfo setup.rb
692
+ _darcs demo lib script work
693
+
694
+ $ lt script/
695
+ [/home/monkey/code/ruby/sake/src]
696
+ script/package # Generate distributable packages
697
+ script/version # Generate VERSION file
698
+ script/release # Release packages to hosting service
699
+ script/changelog # Generate ChangeLog file
700
+ script/rdoc # Generate API documentaiton
701
+
702
+ $ script/version -n
703
+ 0.0.1 (2006-08-12)
704
+ </pre>
705
+
706
+ <p>Notice the use of <code>lt</code>. That's an included utility that lists executable
707
+ script in a given directory. It does this by grabbing the first comment line
708
+ (that starts with #) it finds.</p>
709
+
710
+ <br/>
711
+
712
+ <p>Ruby task scripts are plan ruby scripts. The only thing special about them are:</p>
713
+
714
+ <ol><li>The bang header tells the system to run the script as a "rubytask"</li>
715
+ <li>The first comment line describes the task (mainly for use by <code>lt</code>).
716
+ <li>The name of the main method, if used, must be the same as the scripts (minus extension).
717
+ </ol>
718
+
719
+ <p>Here's your obligatory <code>hello</code> example.</p>
720
+
721
+ <pre>
722
+ #! /usr/bin/env rubytask
723
+
724
+ # Hello World
725
+ #
726
+ # This is my first sake script!
727
+
728
+ puts "Hello, World!"
729
+ </pre>
730
+
731
+ <p>How this example simply prints "Hello, World!" to stdout immediately. That may be fine one-off cases,
732
+ but because it does not relegate the execution to a method however, it is not as easily reusable. A better
733
+ way to write this example is:</p>
734
+
735
+ <pre>
736
+ #! /usr/bin/env rubytask
737
+
738
+ # Hello World
739
+ #
740
+ # This is my first sake script!
741
+
742
+ def hello
743
+ puts "Hello, World!"
744
+ end
745
+ </pre>
746
+
747
+ <p>Keep in mind, for this to work, the file itself must be named 'hello' or 'hello.rb'
748
+ to match the main method's name.</p>
749
+
750
+ <p>Ratcehts provides a convenient mechanism by which to call other stand-alone tasks
751
+ simply by calling them as another method.</p>
752
+
753
+ <pre>
754
+ #!/usr/bin/env rubytask
755
+
756
+ # General preperation
757
+ #
758
+ # This script preforms a number of tasks to prepare for release.
759
+
760
+ testrun
761
+ changelog
762
+ version
763
+ </pre>
764
+
765
+ <p>This will call three external scripts in order: test, changelog and version.
766
+ Sometimes there is method is already defined with the same name as an external task. In those
767
+ cases you can manually invoke the extrneal method via the <code>#rubytask</code> method.
768
+ For instance the above can be also written:</p>
769
+
770
+ <pre>
771
+ #!/usr/bin/env rubytask
772
+
773
+ # General preperation
774
+ #
775
+ # This script preforms a number of tasks to prepare for release.
776
+
777
+ system_task 'testrun'
778
+ system_task 'changelog'
779
+ system_task 'version'
780
+ </pre>
781
+
782
+ <p>The two forms are completely equivalent. The former is simply calling #system_task behined the scenes.</p>
783
+
784
+ <p>The <code>rubytask</code> method restricts the same task from being run twice in the same execution session,
785
+ so there's not need to worry about cascading task calls. On the other hand if you wish to reuse a task more
786
+ than once, here's how to write a script to do so.</p>
787
+
788
+ <pre>
789
+ #!/usr/bin/env rubytask
790
+
791
+ require_local 'hello'
792
+
793
+ # Say hello three times
794
+
795
+ hello
796
+ hello
797
+ hello
798
+ </pre>
799
+
800
+ <p>The "Sake" technique of creating tasks for a project takes a little more time to setup.
801
+ But it has many distinct advantages. Among them:</p>
802
+
803
+ <ul>
804
+ <li>Tasks are clearly enumerable and can be viewed like any other file-system folder.</li>
805
+ <li>Individual tasks can be quickly edited without having to sort through other task definitions.</li>
806
+ <li>Permissions on tasks can be restricted individually.</li>
807
+ <li>Shell-based tools can coexist along side rubytask tools.</li>
808
+ </ul>
809
+
810
+
811
+ <script type="text/javascript"> chapter('Lookup and Do'); </script>
812
+
813
+ <p>What if I want to run a task script, but I'm currently way down in the
814
+ project's directory tree. I dont want to <code>cd</code> all the way up or type
815
+ <code>../</code> a bunch of times.</h2>
816
+
817
+ <p>Sake provides a utility called <code>ludo</code> which stands for
818
+ <i>lookup and do</i>. Just prepend that command to your invocation and it
819
+ will find the executable and execute it.</p>
820
+
821
+ <pre>
822
+ % ludo script/info
823
+ </pre>
824
+
825
+ <p>By the way, the <code>ludo</code> command can be used anywhere you like, it is
826
+ not dependent on Sake to work. Albeit you should exercise some caution when doing
827
+ so since <code>ludo</code> actively searches up the directory tree for a script
828
+ to execute.</p>
829
+
830
+
831
+ <br/>
832
+
833
+ <p>By the way, if you'd like to really make <i>sake</i> here's the process:</h2>
834
+
835
+ <div style="margin: 20px; margin-bottom: 50px;">
836
+ <img src="img/process.gif"/>
837
+ </div>
838
+
839
+ <p>Good luck with that. <code>;)</code></p>
840
+
841
+ </div>
842
+
843
+
844
+ <!-- Build Tools -->
845
+
846
+ <div id="tool" class="section">
847
+
848
+ <img src="img/redratchet.jpg" align="right" style="margin-top: -30px; padding: 10px;"/>
849
+
850
+ <div class="part">Part III</div>
851
+
852
+ <div id="title1" style="color: #888844;">Tool Utilization</div>
853
+
854
+
855
+ <script type="text/javascript"> chapter('Tools and the Project Class'); </script>
856
+
857
+ <p>At it's core it is a set of integrated tools designed to simplify the life
858
+ of Ruby application developers and project managers. The built-in tools cover
859
+ the full range of common project needs, from setting up a standard project structure
860
+ to packaging and making announcements. Because of commonality between the tools,
861
+ Reap utilizes a central YAML configuration file(s) to harvest project information.
862
+ This significantly simplifies usage.</p>
863
+
864
+
865
+ <p>Custom tasks can also be easily created to suit specific project requirements.
866
+ In this respect Reap is much like Rake.
867
+
868
+ <p>Reap differentiates itself from the other build tools in a number of ways.
869
+ It supports a variety of techinues for utilizing tools and defining tasks.
870
+ Reap can be used as a Rake-clone. In fact Reap is a nearly 100% compatible
871
+ replacement for Rake[1]. On the other hand, if you can't pull yourself
872
+ away from Rake, Reap's tasks can also be used via Rake much like any other set of
873
+ addon Rake tasks.</p>
874
+
875
+ <p>Reap tasks can also be defined as standard executables, the ability to use YAML
876
+ to easily setup built-in tasks, the use of a centralized data resource for project
877
+ information and it's extensive library of built-in tasks. The built-in tasks are
878
+ extensive enough that Sake can also be thought of as a complete project managment
879
+ assitant application.</p>
880
+
881
+
882
+ <script type="text/javascript"> chapter('Revision Tools'); </script>
883
+
884
+ <p>Revision tools are tied to a particular revision control system like SVN or Darcs. The one exception is
885
+ the backup tool which simply makes a raw compress backup of your source repository. Because of the
886
+ tie into the particluar revision system you should make sure the <code>scm:</code> entry is set in your
887
+ ProjectInfo file, otherwise these tools will not be be available. Vaild settings are <code>cvs</code>,
888
+ <code>svn</code>, <code>git</code> and <code>darcs</darcs>.</p>
889
+
890
+ <p><span class="red">IMPORTANT!</span> Only Darcs is fully supported at this time. The others will be supported
891
+ in a future release.</p>
892
+
893
+ <h2>Backup</h2>
894
+
895
+ <p>Backup tool provides a facility to quuickly backup a project. The location of the backup will be under the given
896
+ output folder, then under the name of the project and a subdirectory of the day’s date.
897
+ For example, Ratchets itself was backed up to today at: <code>/var/backup/ratchets/ratchets_2006_10_21.tar.gz</code></p>
898
+
899
+ <pre class="list">
900
+ name Name of project/backup
901
+ output The backup directory (eg. '/var/backup')
902
+ folder The directory to backup. [.]
903
+ </pre>
904
+
905
+ <h2>History</h2>
906
+
907
+ <p>The history tool produces a ChangeLog. The ChangeLog can be had in a number of styles.
908
+ Presently <code>gnu</code> and <code>compact</code> are support. Both <code>xml</code> and
909
+ <code>yaml</code> formats will be available in an upcoming release.</p>
910
+
911
+ <pre class="list">
912
+ output File to save the log. [doc/ChangeLog]
913
+ style ChangeLog format. [gnu]
914
+ </pre>
915
+
916
+ <h2>Stamp</h2>
917
+
918
+ <p>The stamp tool produces a VERSION stamp. This is one-line string that gives
919
+ version, release status and release date in a concise and readable, but machine parsable
920
+ format.
921
+
922
+ <pre class="list">
923
+ version Version of release.
924
+ status Status of release (eg. beta, RC1).
925
+ released Date of release.
926
+ file File to save the version stamp.
927
+ </pre>
928
+
929
+
930
+ <script type="text/javascript"> chapter('Progress Tools'); </script>
931
+
932
+ <h2>Notes</h2>
933
+
934
+ <p>The notes tool can lookup and list TODO, FIXME and other types of labeled comments from source code.</p>
935
+
936
+ <pre class="list">
937
+ include File pattern selecting files to analyze.
938
+ Default pattern is 'lib/**/*'.
939
+ label Types of notes to find [TODO, FIXME].
940
+ </pre>
941
+
942
+ <h2>Stats</h2>
943
+
944
+ <p>The stats tools provides file and LOC analysis of your code.</p>
945
+
946
+ <pre class="list">
947
+ include The files to include in analysis.
948
+ Default pattern is 'lib/**/*'.
949
+ exclude The files to exclude from analysis.
950
+ </pre>
951
+
952
+ <h2>Test</h2>
953
+
954
+ <p>Run unit-tests (each in a separate process).</p>
955
+
956
+ <p>It will run unit tests. Each test file is run in a separate interpretor to prevent script clash.</p>
957
+
958
+ <p>The Test class runs each test in it’s own proccess, making for a more pure test facility.
959
+ This prevents potential conflicts between scripts.</p>
960
+
961
+ <pre class="list">
962
+ tests Test files (eg. test/tc_**/*.rb)
963
+
964
+ Defaults to typcial selection.
965
+ libs List of lookup directories to include in
966
+ load path. './lib' is always included.
967
+ live Flag to quickly deactive use of local libs.
968
+ Test against installed files instead.
969
+ reqs List of any files to pre-require.
970
+ </pre>
971
+
972
+ <p>NOTE This works well enough but it is a tad delicate. It actually marshals test results across
973
+ stdout->stdin shell pipe. One consequence of this is that you can’t send debug info to stdout in
974
+ your tests #(including p and puts).</p>
975
+
976
+
977
+ <script type="text/javascript"> chapter('Manifest Tools'); </script>
978
+
979
+ <h2>Manifest</h2>
980
+
981
+ <p>Manifest class produces a simple file manifest for a project, listing the path
982
+ of each file and it’s MD5 checksum.
983
+ Create a manifest file for the package. By default is a very simple filename manifest.
984
+ The check type can be supplied and a checksum will be given with each filename.
985
+ In the future this will be exanded to build a varity of manifest formats.</p>
986
+
987
+ <pre class="list">
988
+ include Files to include.
989
+ exclude Files to exclude from the included.
990
+ file Save the manifest to this file (otherwise stdout).
991
+ digest Include optional digest type:
992
+ md5, sha128 (sha1), sha256, sha512
993
+ </pre>
994
+
995
+ <h2>Sign</h2>
996
+
997
+ <p>Sign class will generate signitures for a library’s files. It also can generate
998
+ a public key for the project if it does not have one. You must supply a private key.</p>
999
+
1000
+ <pre class="list">
1001
+ name Project name.
1002
+ keyfile Pathname top .pem file of private key.
1003
+ include Glob of files to include.
1004
+ exclude Glob of files to exclude.
1005
+ output Dir to store signiture files [data/{name}/sig].
1006
+ </pre>
1007
+
1008
+
1009
+ <script type="text/javascript"> chapter('Documentation Tools'); </script>
1010
+
1011
+ <h2>Rdoc</h2>
1012
+
1013
+ <p>RDoc tool is a user-friendly interface for generating RDocs via the rdoc shell command.
1014
+ This tool generates API documentation from source comments.</p>
1015
+
1016
+ <pre class="list">
1017
+ title Project title to use in documentation.
1018
+ output Directory to store documentation [doc]
1019
+ source Project location to document [.]
1020
+ main File to use as main page [README]
1021
+ template Which RDoc template to use [html]
1022
+ include Files to include in RDocs
1023
+ exclude Files to exclude from those
1024
+ options Pass-thru extra options to RDoc command
1025
+ </pre>
1026
+
1027
+ <h2>Publish</h2>
1028
+
1029
+ <p>The publish tools provides a simple way to upload documents or even an entire
1030
+ website to a host.</p>
1031
+
1032
+ <pre class="list">
1033
+ include Files to include.
1034
+ </pre>
1035
+
1036
+
1037
+ <script type="text/javascript"> chapter('Release Tools'); </script>
1038
+
1039
+ <h2>Announce</h2>
1040
+
1041
+ <p>The announce tool handles release announcements. It generates a nicely
1042
+ formated message and then emails to the specified address(es).</p>
1043
+
1044
+ <pre class="list">
1045
+ title Project title [title].
1046
+ version Project version [version].
1047
+ summary Brief one-line description [summary].
1048
+ description Long description of project [description].
1049
+ homepage Project homepage web address [homepage].
1050
+ links Array of http links to related sites.
1051
+ file File that contains announcement message.
1052
+ memo Embedded announcement message.
1053
+ slogan Motto for you project.
1054
+ email Send email otherwise just display announcement.
1055
+ </pre>
1056
+
1057
+ <p>If email is set to true, then these also apply:</p>
1058
+
1059
+ <pre class="list">
1060
+ subject Subject of email message.
1061
+ from Message FROM address [email].
1062
+ to Email address to send announcemnt.
1063
+ server Email server to route message.
1064
+ port Email server's port.
1065
+ domain Email server's domain name.
1066
+ account Email account name.
1067
+ login Login type: plain, cram_md5 or login.
1068
+ secure Uses TLS security, true or false?
1069
+ </pre>
1070
+
1071
+ <p>(Square brackets indicate defaults taken from Project information. if used via Project class.)</p>
1072
+
1073
+
1074
+ <h2>Package</h2>
1075
+
1076
+ <p>Create distribution packages.
1077
+
1078
+ <p>This tool can create standard .zip, .tgz, or .tbz packages, plus .gem, .deb and other distributions.</p>
1079
+
1080
+ <p>Builds distribution packages. The package task supports tar.gz, tar.bz2, zip source packages
1081
+ and gem, pacman and debian ditribution packages.</p>
1082
+
1083
+ <pre class="list">
1084
+ Inherited settings:
1085
+
1086
+ name Package name.
1087
+ version Package version.
1088
+ architecture Can be any, i368, i686, ppc, etc.
1089
+ executables Executable files in this distribution.
1090
+
1091
+ Tool specific settings:
1092
+
1093
+ output Directory in which to store distributions.
1094
+ include Files to include in distribution.
1095
+ exclude Files to exclude from those.
1096
+ formats List of distribution formats desired. Eg.
1097
+ tgz, tar.gz, tbz, tar.bz2, zip
1098
+ gem, deb, rpm, pac, etc.
1099
+ tier Version tier the package (for use with Library).
1100
+ rules Specify where files should go in package (see below).
1101
+
1102
+ Seetings that can be of use depending on the package format.
1103
+
1104
+ category Software category.
1105
+ dependencies List of packages this depends.
1106
+ recommends List of packages that can be used with this package.
1107
+ replaces List of packages this one replaces.
1108
+
1109
+ RubyGems specific settings:
1110
+
1111
+ autorequire
1112
+ platform
1113
+ require_paths
1114
+ </pre>
1115
+
1116
+ <p>If you need to vary settings according to the format, all you need to do is create
1117
+ separate package tasks.</p>
1118
+
1119
+ <p>There is one parameter that deserves additional attention. This is the setting called ‘rules’.
1120
+ The rules setting allows you to define how files are copied into the distribution package, so instead
1121
+ of a one to one copy of the included files, you can actually have a file placed in a different
1122
+ location within the distribution. This can be very handy if you wish to develop your project with one
1123
+ layout, but need to distribute it with another.</p>
1124
+
1125
+ <p>See the Stage module for details on using rules.</p>
1126
+
1127
+
1128
+ <h2>Release</h2>
1129
+
1130
+ <p>Upload release packages to hosting service.
1131
+ This task releases files to a host such as RubyForge.</p>
1132
+
1133
+ <pre class="list">
1134
+ folder Distribution directory
1135
+ exclude Distribution types to exclude
1136
+ package Package name
1137
+ date Date of release (defaults to Time.now)
1138
+ processor Processor/Architecture (Any, i386, PPC, etc.)
1139
+ release Release name (default is version number)
1140
+ is_public Public release?
1141
+
1142
+ changes Changes given in string form.
1143
+ notes Release notes given in string form.
1144
+ -or-
1145
+ changelog Change log file
1146
+ notelog Release notes file
1147
+ </pre>
1148
+
1149
+ <p>The release option can be a template by using %s in the string.
1150
+ The version number of your project will be sub’d in for the %s.
1151
+ This saves you from having to update the release name before every release.</p>
1152
+
1153
+
1154
+ <script type="text/javascript"> chapter('Deployment Tools'); </script>
1155
+
1156
+ <h2>Setup</h2>
1157
+
1158
+ <p>This tool builds and installs a project using setup.rb or install.rb.
1159
+ If neither exist setup.rb will be created for the purpose.</p>
1160
+
1161
+ <pre class="list">
1162
+ options Command line options to add to shell command.
1163
+ </pre>
1164
+
1165
+
1166
+ <script type="text/javascript"> chapter('Creating Custom Tools'); </script>
1167
+
1168
+ <p>Adding code to a rakefile or a sake-style script is fine for one-off tasks. But what if you
1169
+ need a more versitle and reusable tool --one you can add to your projectinfo file like Ratchets
1170
+ built-in tools? In that case you need to build a <i>custom tool</i>.</p>
1171
+
1172
+ <p>If you have custom tools you'd like to use for all your projects you can place them
1173
+ either in you home directory under ~/.share/ratchets/tools/, or you could make them
1174
+ universally available to all users in the shared data directory, on Debian,
1175
+ /usr/share/ratchets/tools/. If, on the other hand, the tool is specific to a project,
1176
+ place it in a project tools/ folder.</p>
1177
+
1178
+ <div class="special"><b>IMPORTANT!</b> While this is how you write a custom tool, the loading
1179
+ of custom tools is still on our TODO list. Sake-style scripts will have to suffice until
1180
+ we get this fixed.</div>
1181
+
1182
+ <p>Here's a "simple" example of a custom tool:</p>
1183
+
1184
+ <pre>
1185
+ # Add tool to a tool module (or add to an existing tool module).
1186
+
1187
+ module MyToolModule
1188
+
1189
+ module_function # very important!
1190
+
1191
+ def simple( keys=nil, &amp;yld )
1192
+ keys = (keys||yld).to_openobject
1193
+
1194
+ message = keys.message
1195
+ signed = keys.signed || '-annonymous'
1196
+
1197
+ puts message + "\n\n" + signed
1198
+ end
1199
+
1200
+ end
1201
+
1202
+ # To use the new tool via project, add a tool interface.
1203
+
1204
+ class Project
1205
+
1206
+ tool :simple, 'my custom tool'
1207
+
1208
+ def simple( keys )
1209
+ keys = keys.to_h
1210
+ keys *= {
1211
+ :message => info.message
1212
+ }
1213
+ keys *= (info[:simple] || {})
1214
+ MyToolModule.simple(keys)
1215
+ end
1216
+
1217
+ end
1218
+ </pre>
1219
+
1220
+ <p>The corresponding settings in the ProjectInfo file can then be:</p>
1221
+
1222
+ <pre>
1223
+ message: Hi, how are you?
1224
+
1225
+ tasks:
1226
+
1227
+ simple: !!simple
1228
+ signed: Your friend, Tom.
1229
+ </pre>
1230
+
1231
+ <p>And to use it type:</p>
1232
+
1233
+ <pre>
1234
+ $ project simple
1235
+ </pre>
1236
+
1237
+ <p>Notice the reference to 'info'. This is an OpenStruct-like interface to the project information.</p>
1238
+
1239
+ <p>It's a good idea to take some time and learn all the standard properties of a project's information file
1240
+ which you can draw on for your own tools. Looking at the RDoc API documentation will elucidate most of them.
1241
+ And, of course you can also invent your own if needed.</p>
1242
+
1243
+ <p>The rest of building a tool is a matter or writing the code to have it do what you want. If you
1244
+ develop any nice tools, be sure to pass them along!
1245
+ </p>
1246
+
1247
+
1248
+ <script type="text/javascript"> chapter('Reaping the Rewards'); </script>
1249
+
1250
+ <p>As you can see there are many tools...</p>
1251
+
1252
+ </div>
1253
+
1254
+
1255
+ <!-- Test Services -->
1256
+
1257
+ <div id="test" class="section">
1258
+
1259
+ <img src="img/test.jpg" align="right" style="margin-top: -25px; padding: 10px;"/>
1260
+
1261
+ <div class="part">Part IV</div>
1262
+
1263
+ <div id="title1">Test Services</div>
1264
+
1265
+ <br/><br/>
1266
+
1267
+ <div style="color: white; width: 40%; font: bold 1.5em monospace; background: red; text-align: center;">
1268
+ WARNING!!! TEST SERVICES ARE NOT READY FOR GENERAL USE!
1269
+ </div>
1270
+
1271
+
1272
+ <script type="text/javascript"> chapter('Summary of Test Services'); </script>
1273
+
1274
+ <p>Ratchet's provides a number of different tools to help you
1275
+ test your applicaitons. Running units test was briefly covered
1276
+ in Tool Utilization, but Ratchets' test services are far more
1277
+ extensive. These include a full testing framework similar to
1278
+ Test Unit and RSpec, mock object classes to facilitate test
1279
+ creation, and a versitle breakpoint tool, as well as a variety
1280
+ of test run styles and modes.
1281
+ </p>
1282
+
1283
+
1284
+ <script type="text/javascript"> chapter('Unit Test Framework'); </script>
1285
+
1286
+ <p>Ratchet's test framework is actually very simple in design. It is centered around a simple
1287
+ functor (ie. a function decorator) that routes all calls though an assertion hook. The functor
1288
+ is accessed the the <code>should</code> method, or it negating counterpart <code>should_not</code>.
1289
+ Via this special functor, we can use all of Ruby's typical commands to test assertions wihtout
1290
+ learning any special purpose DSL.</p>
1291
+
1292
+ <p>Consider this simple example.</p>
1293
+
1294
+ <pre>
1295
+ a = 1
1296
+ a == 1
1297
+ a.should == 1
1298
+ </pre>
1299
+
1300
+ <p>The difference between the 2nd and 3rd lines...</p>
1301
+
1302
+ <p>Ratchets' Test Framework also support Behavior Driven Devlopment. BDD is primarily a
1303
+ differnece in one's frame of mind rather the a substatially differnt meand of testing.
1304
+ But two method facilitate that minset: context and ???.</p>
1305
+
1306
+ <pre>
1307
+ context "some context" do
1308
+ ??? "some ???" do
1309
+ a.should == 1
1310
+ end
1311
+ end
1312
+ </pre>
1313
+
1314
+ <p></p>
1315
+
1316
+
1317
+ <script type="text/javascript"> chapter('Making a Mockery'); </script>
1318
+
1319
+ <p>Ratchets has a few mocking classes to make test writing easier. Mock objects
1320
+ are object that pretend to be other object. There is a generic mock object
1321
+ with versitle setup commands for creating complex mock interactions quickly and
1322
+ easily. There are also IO, File and Dir mock objects to avoid testing against
1323
+ fixtures. In the works is also an AOP-based wrapping mechinism that (with
1324
+ any luck) will make mocking pre-existing classes a snap.</p>
1325
+
1326
+
1327
+ <script type="text/javascript"> chapter('Breakpoints and Tracepoints'); </script>
1328
+
1329
+ <p>Ratchets provides a couple of breakpoint tools. These can be
1330
+ run externally or invoked by your code. Ratchets breakpoint system
1331
+ is quite versitle, based on the work Florian Gross' and Mentalurgy
1332
+ it can drop you into an irb seesion, or it can drop you into your
1333
+ favorite editor at the point of failure.</p>
1334
+
1335
+
1336
+ <script type="text/javascript"> chapter('Additional Testing Services'); </script>
1337
+
1338
+ <p>Ratchets has a few additional testing tools that may be of use.</p>
1339
+
1340
+ <p>The MethodProbe is an interesting tool that allows one to drop
1341
+ <i>decoy</i> arguments into a method and extract parameter interface
1342
+ requirements. Unfortunately MethodProbe is an imperfect device
1343
+ because Ruby does not expose all of it's features as overridable
1344
+ methods, in particular conditionals like <code>if</code> are not
1345
+ methods. So not all parameter interfaces can be determined.
1346
+ But with selective usage MehtodProbe can provide useful information.</p>
1347
+
1348
+
1349
+ <script type="text/javascript"> chapter('Excerpt Runner'); </script>
1350
+
1351
+ <p>You may learn about Reap's ability to extract unit tests from source code wrapped in
1352
+ <code>=begin test...=end</code> comment blocks.</p>
1353
+
1354
+ <pre>
1355
+ =begin test
1356
+
1357
+ require 'test/unit'
1358
+
1359
+ class TestThis &lt; Test::Unit::TestCase
1360
+ assert_equal( 2, 1+1 )
1361
+ end
1362
+
1363
+ =end
1364
+ </pre>
1365
+
1366
+ <p>This can be amazing convenient, especailly for testing functional support scripts. But it's not a
1367
+ convenient to have to extract your tests every time you need to run <i>one</i>. To solve this problem,
1368
+ Reap also includes a command called <code>rubytest</code>. To us it simply navigate to the file in
1369
+ question (eg. the one with the commented test, of course) and type:</p>
1370
+
1371
+ <pre>
1372
+ % exrb myscript.rb
1373
+ </pre>
1374
+
1375
+ <p>And you'll see your standard test assertion feedback.</p>
1376
+
1377
+ </div>
1378
+
1379
+
1380
+ <!-- Appendix -->
1381
+
1382
+ <div id="appendix" class="section">
1383
+
1384
+ <img src="img/appendix.png" align="right" style="margin-top: -25px; padding: 10px;"/>
1385
+
1386
+ <div class="part">Appendix</div>
1387
+
1388
+
1389
+ <script type="text/javascript"> chapter('License'); </script>
1390
+
1391
+ <p>
1392
+ Ratcehts<br/>
1393
+ Copyright &copy; 2006 Thomas Sawyer</br>
1394
+ </p>
1395
+
1396
+ <p>Ruby/GPL License</p>
1397
+
1398
+ <p>This program is free software; you can redistribute it and/or modify
1399
+ it under the terms of the Ruby License or GNU General Public License
1400
+ as published by the Free Software Foundation; either version 2 of the
1401
+ License, or (at your option) any later version.</p>
1402
+
1403
+ <p>This program is distributed in the hope that it will be useful,
1404
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1405
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1406
+ GNU General Public License for more details.</p>
1407
+
1408
+ <p>You should have received a copy of the GNU General Public License
1409
+ along with this program; if not, write to the Free Software
1410
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</p>
1411
+
1412
+ </div>
1413
+
1414
+ </div>
1415
+ </body>
1416
+ </html>