bee 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
@@ -0,0 +1,4 @@
1
+ Bee is a simple build tool. It is inspired from Make (for intensive
2
+ usage of command line to build projects) and Ant (for its build file).
3
+ The result is aimed to keep benefits of both and get rid of their
4
+ defaults (if any :o). Enjoy!
data/bin/bee ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+ require 'bee'
5
+
6
+ Bee.start_command_line
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+ require 'beedoc'
5
+
6
+ Bee::Doc.start_command_line
@@ -0,0 +1,444 @@
1
+ <!--
2
+ Copyright 2006 Michel Casabianca <casa@sweetohm.net>
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ -->
16
+
17
+ <p>Bee is a build tool parsing YAML build files. These files can embed
18
+ shell and/or Ruby scripts. It is as fast as Make and its build files are
19
+ far more readable than Ant ones (without the bloated XML syntax ;o).</p>
20
+
21
+ <h2>Installation</h2>
22
+
23
+ <p>Bee is a Ruby script, thus an interpreter must be installed on your
24
+ machine. You can get one for free at
25
+ <a href="http://www.ruby-lang.org">http://www.ruby-lang.org</a>.</p>
26
+
27
+ <p>If <a href="http://docs.rubygems.org/">RubyGems</a> is installed on
28
+ your machine, type <code>gem install bee</code> (you might need to have
29
+ administrator privileges to do so).</p>
30
+
31
+ <p>If you are reluctant to install RubyGems (which is not a good idea),
32
+ you can still install bee the old fashion way: unzip installation
33
+ archive somewhere and put its <i>bin</i> directory in your PATH.</p>
34
+
35
+ <p>You can test your installation typing <code>bee -h</code>.</p>
36
+
37
+ <h2>Usage</h2>
38
+
39
+ <p>Type <code>bee</code> in directory of your build file (which name
40
+ defaults to <i>build.yml</i>). To get help about usage, type
41
+ <code>bee -h</code>:</p>
42
+
43
+ <pre class="code"><code>$ bee -h
44
+ Usage: bee [options] [targets]
45
+ -h Print help about usage and exit.
46
+ -b Print help about build and exit.
47
+ -t Write template build file on disk.
48
+ -v Enable verbose mode.
49
+ -s style Define style for output (see documentation).
50
+ -f file Build file to run (defaults to "build.yml").
51
+ targets Targets to run (default target if omitted).</code></pre>
52
+
53
+ <p>You can get help about loaded build file (using <code>-f</code>
54
+ option if necessary) typing <code>bee -b</code>:</p>
55
+
56
+ <pre class="code"><code>$ bee -b
57
+ - Build: "bee"
58
+ Description:
59
+ This build file needs zip command line tool to generate distribution
60
+ archive.
61
+ - Properties:
62
+ - api: "/Users/casa/Desktop/bee/build/api"
63
+ - archive: "bee-beta-1.zip"
64
+ - base: "/Users/casa/Desktop/bee"
65
+ - build: "/Users/casa/Desktop/bee/build"
66
+ - dist: "/Users/casa/Desktop/bee/build/bee"
67
+ - doc: "/Users/casa/Desktop/bee/build/doc"
68
+ - files: "README bin"
69
+ - name: "bee"
70
+ - src: "/Users/casa/Desktop/bee/bin/*"
71
+ - syntax_report: "/Users/casa/Desktop/bee/build/syntax.txt"
72
+ - test: "/Users/casa/Desktop/bee/test"
73
+ - test_report: "/Users/casa/Desktop/bee/build/tests.txt"
74
+ - version: "beta-1"
75
+ - Targets:
76
+ - all: Generate all
77
+ - api: Generate API documentation
78
+ - clean: Clean generated files
79
+ - dist: Generate distribution archive
80
+ - doc: Generate documentation
81
+ - syntax: Check syntax of ruby files
82
+ - syntax-report: Check syntax of ruby files and generate report
83
+ - test: Run unit tests
84
+ - test-report: Run unit tests and gerenate report
85
+ - Default: all</code></pre>
86
+
87
+ <p>This will print help about:</p>
88
+
89
+ <ul>
90
+ <li>Build file.</li>
91
+ <li>Defined properties.</li>
92
+ <li>Build targets.</li>
93
+ <li>Default target.</li>
94
+ </ul>
95
+
96
+ <p>The <code>-t</code> option writes a template build file. This is
97
+ convenient to quickly write a new build file editing this example.
98
+ You can use option <code>-t file</code> to write template to another
99
+ location than <i>build.yml</i> in current directory. Note that bee
100
+ will refuse to overwrite an existing build file with a template.</p>
101
+
102
+ <p>The <code>-v</code> option enables verbose mode (printing loaded
103
+ build file, executed scripts and build time). Option <code>-s style</code>
104
+ defines a style for output (see above section <i>Defining styles</i>
105
+ for more information). The <code>-f file</code> enables you to load
106
+ an alternate build file. Without this option, bee will look for
107
+ a file named <i>build.yml</i> in current directory.</p>
108
+
109
+ <h2>Configuration</h2>
110
+
111
+ <p>bee doesn't load configuration file st startup, but you can set
112
+ command line options in environment variable <code>BEEOPT</code> that
113
+ is appended on command line at startup. For instance, setting:</p>
114
+
115
+ <pre class="code">BEEOPT="-v"<code></code></pre>
116
+
117
+ <p>Would always run bee in verbose mode.</p>
118
+
119
+ <h2>Project files</h2>
120
+
121
+ <p>Here is a sample project file (simplified version to generate bee
122
+ distribution archive):</p>
123
+
124
+ <pre class="code"><code># Build info
125
+ - build: bee
126
+ default: all
127
+ description: |
128
+ This build file needs zip command line tool to generate distribution
129
+ archive.
130
+
131
+ # Build properties
132
+ - properties:
133
+ - name: bee
134
+ - version: "beta-1"
135
+ - test: "test"
136
+ - build: "#{base}/build"
137
+ - dist: "#{build}/#{name}"
138
+ - files: "README bin"
139
+ - archive: "#{name}-#{version}.zip"
140
+
141
+ # Build targets
142
+ - target: test
143
+ description: Run unit tests
144
+ script:
145
+ - "testrb #{test}"
146
+
147
+ - target: dist
148
+ description: Generate distribution archive
149
+ depends: test
150
+ script: |
151
+ if [ ! -d #{build} ]
152
+ then
153
+ mkdir #{build}
154
+ fi
155
+ if [ ! -d #{dist} ]
156
+ then
157
+ mkdir #{dist}
158
+ fi
159
+ cp -r #{files} #{dist}
160
+ rm -rf `find #{dist} -name "CVS"`
161
+ rm -rf `find #{dist} -name ".??*"`
162
+ cd #{build}
163
+ zip -r #{archive} #{name}
164
+
165
+ - target: clean
166
+ description: Clean generated files
167
+ script: |
168
+ rm -rf #{build}
169
+ rm -f `find #{base} -name "*~"`
170
+ rm -f `find #{base} -name ".DS_Store"`
171
+
172
+ - target: all
173
+ description: Generate all
174
+ depends: [clean, dist]</code></pre>
175
+
176
+ <p>This is a <a href="http://www.yaml.org/">YAML</a> file. In such
177
+ files, list elements are lines starting with a dash (<i>-</i>
178
+ character) and hash entries are lines made of a key / value pair
179
+ separated with a colon (<i>:</i> character). Thus, you might already
180
+ have noticed that this file is a list of hash which can be:</p>
181
+
182
+ <h3>Project information</h3>
183
+
184
+ <p>This is a piece of information that is not mandatory but used
185
+ while displaying build help. This looks like:</p>
186
+
187
+ <pre class="code"><code>- build: bee
188
+ default: all
189
+ description: |
190
+ This build file needs zip command line tool to generate distribution
191
+ archive.</code></pre>
192
+
193
+ <p>This hash may have following keys:</p>
194
+
195
+ <ul>
196
+ <li><b>build</b>: for the build name (mandatory).</li>
197
+ <li><b>default</b>: to indicate default target to run (optional). If no
198
+ default target is set, bee will set default as first target declared in
199
+ the build file.</li>
200
+ <li><b>description</b>: build description (optional). This is the place
201
+ to list dependencies for the build (such as <code>zip</code> in this
202
+ example).</li>
203
+ <li><b>context</b>: this is a list of scripts to load at startup in
204
+ the build context. These scripts can define variables and functons
205
+ used in embedded scripts. See section <i>Build Context</i> above for
206
+ more information.</li>
207
+ </ul>
208
+
209
+ <h3>Build properties</h3>
210
+
211
+ <p>These are properties used by build file scripts or other properties.
212
+ They can be seen as build file variable declarations:</p>
213
+
214
+ <pre class="code"><code>- properties:
215
+ - name: bee
216
+ - version: "beta-1"
217
+ - test: "test"
218
+ - build: "#{base}/build"
219
+ - dist: "#{build}/#{name}"
220
+ - files: "README bin"
221
+ - archive: "#{name}-#{version}.zip"</code></pre>
222
+
223
+ <p>This entry has a single key <i>properties</i> that contains a list
224
+ of property definitions. Each definition is a Hash with a single key
225
+ which is the property name associated to its value. Properties can
226
+ reference each other using a Ruby syntax <code>#{property}</code>.</p>
227
+
228
+ <h3>Targets</h3>
229
+
230
+ <p>A target can be seen as build file functions. A target is defined
231
+ to implement a given goal. For instance, in sample hereafter, target
232
+ named <i>dist</i> generates distribution archive:</p>
233
+
234
+ <pre class="code">- target: dist
235
+ description: Generate distribution archive
236
+ depends: test
237
+ script: |
238
+ if [ ! -d #{build} ]
239
+ then
240
+ mkdir #{build}
241
+ fi
242
+ if [ ! -d #{dist} ]
243
+ then
244
+ mkdir #{dist}
245
+ fi
246
+ cp -r #{files} #{dist}
247
+ rm -rf `find #{dist} -name "CVS"`
248
+ rm -rf `find #{dist} -name ".??*"`
249
+ cd #{build}
250
+ zip -r #{archive} #{name}<code></code></pre>
251
+
252
+ <p>A target entry might have following keys:</p>
253
+
254
+ <ul>
255
+ <li><b>target</b>: the target name (mandatory).</li>
256
+ <li><b>description</b>: description printed in build help (optional).</li>
257
+ <li><b>depends</b>: a list of target's dependencies (optional). This
258
+ might be a list or a single string. Dependencies are executed before a
259
+ given target.</li>
260
+ <li><b>script</b>: script to run to achive this target (optinal). This is
261
+ a single script or a list of scripts to run. Each script might be a
262
+ shell script or a Ruby script (when prefixed with <code>- rb:</code>).</li>
263
+ </ul>
264
+
265
+ <p>bee writes executed scripts in verbose mode. For instance, running
266
+ sample script would print on console:</p>
267
+
268
+ <pre class="code"><code>$ bee
269
+ ----------------------------------------------------------------------- clean --
270
+ ------------------------------------------------------------------------ test --
271
+ Loaded suite test
272
+ Started
273
+ ..
274
+ Finished in 0.003776 seconds.
275
+
276
+ 2 tests, 2 assertions, 0 failures, 0 errors
277
+ ------------------------------------------------------------------------ dist --
278
+ adding: bee/ (stored 0%)
279
+ adding: bee/bin/ (stored 0%)
280
+ adding: bee/bin/bee (deflated 73%)
281
+ adding: bee/bin/beedoc (deflated 69%)
282
+ adding: bee/README (deflated 30%)
283
+ ------------------------------------------------------------------------- all --
284
+ OK</code></pre>
285
+
286
+ <p>While running in verbose mode, it would output:</p>
287
+
288
+ <pre class="code">$ bee -v
289
+ Starting build 'build.yml'...
290
+ ----------------------------------------------------------------------- clean --
291
+ - rm -rf #{build}
292
+ . rm -f `find #{base} -name "*~"`
293
+ . rm -f `find #{base} -name ".DS_Store"`
294
+ ------------------------------------------------------------------------ test --
295
+ - testrb #{test}
296
+ Loaded suite test
297
+ Started
298
+ ..
299
+ Finished in 0.003944 seconds.
300
+
301
+ 2 tests, 2 assertions, 0 failures, 0 errors
302
+ ------------------------------------------------------------------------ dist --
303
+ - if [ ! -d #{build} ]
304
+ . then
305
+ . mkdir #{build}
306
+ . fi
307
+ . if [ ! -d #{dist} ]
308
+ . then
309
+ . mkdir #{dist}
310
+ . fi
311
+ . cp -r #{files} #{dist}
312
+ . rm -rf `find #{dist} -name "CVS"`
313
+ . rm -rf `find #{dist} -name ".??*"`
314
+ . cd #{build}
315
+ . zip -r #{archive} #{name}
316
+ adding: bee/ (stored 0%)
317
+ adding: bee/bin/ (stored 0%)
318
+ adding: bee/bin/bee (deflated 73%)
319
+ adding: bee/bin/beedoc (deflated 69%)
320
+ adding: bee/README (deflated 30%)
321
+ ------------------------------------------------------------------------- all --
322
+ Built in 0.567582 s
323
+ OK<code></code></pre>
324
+
325
+ <p>First line of a script starts with a dash (<i>-</i> character) while
326
+ following ones start with a dot (<i>.</i> character). In verbose mode,
327
+ bee also prints loaded build file and build time.</p>
328
+
329
+ <h2>Build Context</h2>
330
+
331
+ <p>Setting <code>context</code> key in build info entry load a given
332
+ Ruby script in the build context. This context is the place where
333
+ embedded Ruby scripts run (this is similar to the workspace where you
334
+ run code you type in IRB). This is a simple way to load a library you
335
+ will call in your Ruby scripts. Let's say you would like to call function
336
+ <code>say_hello</code> defined in script named <i>hello.rb</i>:</p>
337
+
338
+ <pre class="code"><code>def say_hello(who)
339
+ puts "Hello #{who}!"
340
+ end</code></pre>
341
+
342
+ <p>You would load it in context with following build file: </p>
343
+
344
+ <pre class="code"><code>- build: hello
345
+ context: hello.rb
346
+
347
+ - properties:
348
+ - world: "World"
349
+
350
+ - target: hello
351
+ script:
352
+ - rb: "say_hello(world)"</code></pre>
353
+
354
+ <p>The contex path is relative to the build file. Furthermore, you can
355
+ load more than one file in your context, using a list:</p>
356
+
357
+ <pre class="code"><code>- build: hello
358
+ context: [foo.rb, bar.rb]</code></pre>
359
+
360
+ <h2>Defining Style</h2>
361
+
362
+ <p>You can define a style using the <code>-s syle</code> option. This
363
+ is a way to colorize output on console using ANSI colors for Unix
364
+ terminals. For instance, on a Unix box, running bee with option
365
+ <code>-s lc:,tf:yellow,ts:underscore,ss:bright,sf:green,es:bright,ef:red,kf:blue</code>
366
+ would output:</p>
367
+
368
+ <center><img src="style.png"></center>
369
+
370
+ <p>Styles are defined as coma separated key/value pairs. Keys are the
371
+ following:</p>
372
+
373
+ <table>
374
+ <tr>
375
+ <th>Key</th>
376
+ <th>Description</th>
377
+ </tr>
378
+ <tr>
379
+ <td><b>lc</b></td>
380
+ <td>Character for target title (defaults to dash <i>-</i>). To set space,
381
+ set to an empty value, such as: <code>...,lc:,...</code> as there should
382
+ not be spaces in style option (this would break command line parsing).</td>
383
+ </tr>
384
+ <tr>
385
+ <td><b>ll</b></td>
386
+ <td>Line length. If not set, will try to determine it calling IOCTL
387
+ function. If this call fails, will set line length to <i>80</i>
388
+ characters.</td>
389
+ </tr>
390
+ <tr>
391
+ <td><b>ts</b></td>
392
+ <td>Target style.</td>
393
+ </tr>
394
+ <tr>
395
+ <td><b>tf</b></td>
396
+ <td>Target foreground.</td>
397
+ </tr>
398
+ <tr>
399
+ <td><b>tb</b></td>
400
+ <td>Target background.</td>
401
+ </tr>
402
+ <tr>
403
+ <td><b>ks</b></td>
404
+ <td>Task style.</td>
405
+ </tr>
406
+ <tr>
407
+ <td><b>kf</b></td>
408
+ <td>Task foreground.</td>
409
+ </tr>
410
+ <tr>
411
+ <td><b>kb</b></td>
412
+ <td>Task background.</td>
413
+ </tr>
414
+ <tr>
415
+ <td><b>ss</b></td>
416
+ <td>Success style.</td>
417
+ </tr>
418
+ <tr>
419
+ <td><b>sf</b></td>
420
+ <td>Success foreground.</td>
421
+ </tr>
422
+ <tr>
423
+ <td><b>sb</b></td>
424
+ <td>Success background.</td>
425
+ </tr>
426
+ <tr>
427
+ <td><b>es</b></td>
428
+ <td>Error style.</td>
429
+ </tr>
430
+ <tr>
431
+ <td><b>ef</b></td>
432
+ <td>Error foreground.</td>
433
+ </tr>
434
+ <tr>
435
+ <td><b>eb</b></td>
436
+ <td>Error background.</td>
437
+ </tr>
438
+ </table>
439
+
440
+ <p>If a given key is not set, it will keep its default value. The bee
441
+ options environment variable <code>BEEOPT</code> is the best place
442
+ to set you style settings.</p>
443
+
444
+ <p>Enjoy!</p>