# Is it a better way to build?

**URL:** <https://www.ruby-forum.com/t/is-it-a-better-way-to-build/64665>\
**Category:** Ruby\
**Created:** [August 15, 2006, 2:13pm UTC](https://www.ruby-forum.com/t/is-it-a-better-way-to-build/64665 "2006-08-15T14:13:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 15, 2006, 2:13pm UTC](https://www.ruby-forum.com/t/is-it-a-better-way-to-build/64665/1 "2006-08-15T14:13:40Z")

</div>

Yesterday, as I beat myself with my old  
what-to-name-it-where-to-put-it stick 😉 I touched on idea loosely  
derived on the script/ dir “Railism”. So I tried it out just to see if  
it could work and indeed it does. The idea is this. Instead of a  
single monolithic script like Rakefile to manage your project tasks,  
you can have a script file for each task in a subdir (like script/).  
Task dependencies are simply handled by internal methods if they are  
“hidden” tasks or by requiring another tasks, and handling them a  
cache mechinism.

So for example a project might look like:

fooproject/  
lib/  
test/  
script/  
rdoc  
package  
release  
test

An example script (as presently implemented) looks like this. Note,  
for the expiremental system I called the module “Scriptonic” (as  
opposed to “Reap”). Here’s script/rdoc:

#!/usr/bin/env ruby

def rdoc  
Scriptonic.rdoc do |r|  
r.template = ‘jamis’  
r.options = [’–all’, ‘–inline-source’]  
r.include = [‘lib/\*\*/_’, '[A-Z]_’ ]  
r.output = ‘rdoc’  
end  
end

load ‘scriptonic.rb’

By calling script/rdoc on the command line:

$ script/rdoc

It will find the ProjectInfo and change to the project root dir and  
then call the method of the same name, e.g. rdoc, which as we see runs  
the Scriptonic.rdoc builtin task.

(Note, on a system that doesn’t support #!/usr/bin/env ruby, you have  
to use “ruby script/rdoc”)

To have a prerequisite task lets say we wanted to run our test task  
before rdocing. To do that we can use the #prereq method which returns  
a Once functor (a memoize/cache system):

require ‘test’

def rdoc  
prereq.test  
Scriptonic.rdoc do |r|  
r.template = ‘jamis’  
r.options = [’–all’, ‘–inline-source’]  
r.include = [‘lib/\*\*/_’, '[A-Z]_’ ]  
r.output = ‘doc/api’  
end  
end

There is also a help system “script/rdoc --help” and task can take  
arguments “script/rdoc more” (doesn’t yet support custom flag options  
though).

Okay, now that I explained it, the question is: Is this a better way  
to build than Rake (and it’s clone, Reap)?

Thanks,  
T.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 15, 2006, 2:13pm UTC](https://www.ruby-forum.com/t/is-it-a-better-way-to-build/64665/2 "2006-08-15T14:13:58Z")

</div>

TRANS [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> Okay, now that I explained it, the question is: Is this a better way  
> to build than Rake (and it’s clone, Reap)?

I don’t think so. Rakefiles work fine, create less files flying  
around and are widely supported.

While your “lots of small scripts”-approach has a certain elegance, I  
don’t think it has major advantages.
