From: "Dennis B." Date: 2012-11-23T03:26:36+09:00 Subject: Re: Rake task with variable arguments I have submitted the following Pull Request to add this functionality: https://github.com/jimweirich/rake/pull/150. In analyzing the source, currently there is no place that stores the argument values not associated with a 'named' argument, so they cannot be retrieved after parsing. The patch keeps all the passed-in values and makes them available via the #to_a method, or just the extra values via the #extras method (ie, not the values that get associated with named arguments. I have also devised a horrendous hack to get around this current limitation: # Prepare the dummy args - supports up to 100 values vargs = ((0..99).map {|i| ("arg%02d" % i).to_sym}) def vargs.join(*args) # This gets used to document the args in rake -T: be descriptive, ie: ",,...," end def vargs.map(&block) # This need to return self in order to have the above join work # This is only called in the set_arg_names block internally to convert # to symbols which it already is; make sure you don't need to use it # yourself; if so, use collect instead self end task :task_name, vargs do |t, args| # Pull all the used args out... values = args.names.select {|n| !args[n].nil?}.collect {|n| args[n]} # Pop out the special values target = values.shift sources = values # Rest of task end -- Posted via http://www.ruby-forum.com/.