From: Eric Hodel Date: 2006-06-01T06:07:02+09:00 Subject: Re: Tasks with Parameters: Can it be done? On May 31, 2006, at 1:03 PM, transfire@gmail.com wrote: > I've been working on a task library, on the surface similiar to Rake, > but generalized for use on a per module level --hence usable anywhere > in one's code. The basic principle of the library is that a TASK IS A > METHOD WITH DEPENDENCIES. > > But there's a problem with using a notion like that of Rake's. Since > the dependencies are designated by a list of task names there is no > way > to pass parameters to those dependencies and hence tasks can't have > parameters at all. Eg. [...] > So does any one have any idea how it might be done, or perhaps an > alternative way ot supplying parameters to tasks? Rake does it this way: $ ri Rake::TestTask ---------------------------------------- Class: Rake::TestTask < TaskLib Create a task that runs a set of tests. Example: Rake::TestTask.new do |t| t.libs << "test" t.test_files = FileList['test/test*.rb'] t.verbose = true end If rake is invoked with a "TEST=filename" command line option, then the list of test files will be overridden to include only the filename specified on the command line. This provides an easy way to run just one test. If rake is invoked with a "TESTOPTS=options" command line option, then the given options are passed to the test process after a '--'. This allows Test::Unit options to be passed to the test suite. Examples: rake test # run tests normally rake test TEST=just_one_file.rb # run just one test file. rake test TESTOPTS="-v" # run in verbose mode rake test TESTOPTS="--runner=fox" # use the fox test runner See also tsort.rb. -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com