Trans
8/10/2006 3:02:00 PM
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.