[Nitro] Is it a better way to build?

TRANS transfire at gmail.com
Thu Aug 10 09:18:23 EDT 2006


Yesterday, as I beat myself with my old
what-to-name-it-where-to-put-it stick ;-) I touched on idea based on
the script/ "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 task, and handled via 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 prereq 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 "improved" clone Reap)?

Thanks,
T.


More information about the Nitro-general mailing list