[Rake-devel] task parameters and default values

Luis Lavena luislavena at gmail.com
Sat Nov 15 13:36:55 EST 2008


Hello Eveybody,

I found that having the same parameter name for two task, when calling
one it automatically overwrite the others value.

task :bar, [:version] do |t, args|
  version = args.version || 'unstable'
  puts "Bar version #{version}"
end

task :foo, [:version] => [:bar] do |t, args|
  version = args.version || 'stable'
  puts "Foo version #{version}"
end


Calling 'foo' without parameters:

Luis at KEORE (D:\Users\Luis\Desktop)
$ rake foo
(in D:/Users/Luis/Desktop)
Bar version unstable
Foo version stable

But calling 'foo' with '1.8', overwrites also bar task

Luis at KEORE (D:\Users\Luis\Desktop)
$ rake foo[1.8]
(in D:/Users/Luis/Desktop)
Bar version 1.8
Foo version 1.8

I've tried the code above and also usage of with_defaults to setup the
arguments options, both with same results.

Should this be considered a bug? At first sight the TaskArguments
should be per-task and not global available to all the tasks.

-- 
Luis Lavena
AREA 17
-
Human beings, who are almost unique in having the ability to learn from
the experience of others, are also remarkable for their apparent
disinclination to do so.
Douglas Adams


More information about the Rake-devel mailing list