[Rake-devel] Tasks with arguments and dependencies - doc patch

Jim Weirich jim.weirich at gmail.com
Fri Oct 10 22:38:49 EDT 2008


On Oct 10, 2008, at 6:00 PM, Witold Rugowski wrote:

> Hi!
> I was recently using tasks with arguments and have noticed issue with
> docs. First, there is missing :needs key in example. Second - I'm  
> using
> rake 0.8.3 and enclosing arguments names into array in task definition
> results with error when task is run (only when there is dependency on
> this task).
>
> In doc there is example:
>
> task :name, [:first_name, :last_name] => [:pre_name] do |t, args|
>     args.with_defaults(:first_name => "John", :last_name => "Dough")
>     puts "First name is #{args.first_name}"
>     puts "Last  name is #{args.last_name}"
>   end
>
> It is missng :needs key,

Actually no, it is correct as it stands.  The 0.8.3 version of rake  
does not need the :needs key (it will accept it, but the [:args] =>  
[:prereqs] syntax is preferred.  See below for an example.

Double check to make sure you are running version 0.8.3.  Perhaps you  
have two versions installed and are not running the one you expect.

Thanks for the feedback.

-- 
-- Jim Weirich
-- jim.weirich at gmail.com

$ cat Rakefile
task :pre_name do
   puts "In pre_name"
end

task :name, [:first_name, :last_name] => [:pre_name] do |t, args|
   args.with_defaults(:first_name => "John", :last_name => "Dough")
   puts "First name is #{args.first_name}"
   puts "Last  name is #{args.last_name}"
end
$ rake --version
rake, version 0.8.3
$ rake name
(in /Users/jim/pgm/rake/witold)
In pre_name
First name is John
Last  name is Dough
$ rake name[Jim,Weirich]
(in /Users/jim/pgm/rake/witold)
In pre_name
First name is Jim
Last  name is Weirich
$ 


More information about the Rake-devel mailing list