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, but even with it rake name returns:
>rake name
(in E:/NB/devel/NetBeans)
rake aborted!
undefined method `to_sym' for [:first_name, :last_name]:Array
E:/NB/devel/NetBeans/rakefile:1
(See full trace by running task with --trace)
Changing task definition into
task :name, :first_name, :last_name, :needs => :pre_name do |t, args|
fixes problem.
I'm attaching patch to doc to make it clear and example rakefile which
render this error.
Best regards,
--
Witold Rugowski
Ruby on Rails freelancer
http://nhw.pl/wp/ (EN blog) http://nhw.pl/pl (PL blog)
task :name, [:first_name, :last_name], :needs => [:other] 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
task :other do
enddiff --git a/doc/rakefile.rdoc b/doc/rakefile.rdoc
index dc116e3..6ad40fa 100644
--- a/doc/rakefile.rdoc
+++ b/doc/rakefile.rdoc
@@ -226,9 +226,10 @@ where we specify default values for the first and last
names:
Tasks that use parameters have a slightly different format for
prerequisites. Use the <tt>:needs</tt> keyword to specify the
-prerequisites for tasks with arguments. For example:
+prerequisites for tasks with arguments. Don't use array for defining
+parameter names. For example:
- task :name, [:first_name, :last_name] => [:pre_name] do |t, args|
+ task :name, :first_name, :last_name, :needs => [: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}"
_______________________________________________
Rake-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rake-devel