tags:

views:

18

answers:

1

According to http://rake.rubyforge.org/files/doc/rakefile_rdoc.html, you can create a task that accepts parameters and also has prerequisites:

task :name, [:first_name, :last_name] => [:pre_name] do |t, args|

But what if :pre_name is a task that also accepts parameters? What is the syntax for passing parameters to :pre_name when it is used as a prerequisite?

A: 

I don't have a direct answer, but I do have an alternative solution that might work for you. None of my rake tasks use parameters. (I think I tried to use parameters and had trouble getting them to work.) Instead, I rely on the ENV array. So, for example, I would write that example task as:

task :name =>:pre_name do
  do_something_with_name(ENV['first_name'], ENV['last_name'])
end

which would be invoked as:

rake name first_name=John last_name=Smith

The ENV array data would be available to the pre_name task as well.

--Paul

Paul Lynch