-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support variable-length arguments for Tasks #150
Conversation
This seems like a reasonable request and implementation. I'll probably hold off merging it until this current round of bug fixes are done on the 10.0.x series. |
Definitely in favor of this feature. Thank you for creating this PR. |
👍 great work! |
Was just looking for this feature. Great to see it will be implemented soon(ish) 👍 Too bad I can't seem to use forks of Rake, seems the repository is missing some basic Rubygems file to make it work out of the box |
I've merged this change into master. |
"Too bad I can't seem to use forks of Rake, seems the repository is missing some basic Rubygems file to make it work out of the box" -- JeanMertz Could you expand on this comment? What's missing? |
How can we pass argument values that contain commas? For example, I have a task that needs to receive a list of queues to watch (DelayedJob) and it expects a comma-separated string of names. I suppose I could use arg.extras to recreate the original string passed in... Yeah? |
Yes, that should work. Put all your static args in the front (if you have any) then args.extras will contain an array of your queue names. |
Not sure if this is still the case. But with these small (temporary) modifications, I like to:
This works for most repositories, but yours seems to be lacking the required gemspec file to do this. I've had to create one for your rspec-given repository, as seen in JeanMertz/rspec-given@8acc7a6 It's no big problem, I just noticed this a while ago. |
Jean: I purposely don't include a gemspec in the repo because individual commits are between versions. Any version given in a gemspec file will be a lie. If you wish to use the repo as a gem source, I recommend:
For example:
The above ties the gemfile to a particular commit in the repo and constructs a beta release number incorporating the hash reference. |
Oh, and also rake-10.1.0.beta.3 is available for installation. Just include --pre on the gem install command to get it. |
As an alternative implementation to #70, this allows tasks to access parameters beyond the named parameters that are currently supported. This is accomplished by storing the sequential list of values provided as arguments to the task, and making them available to the block via args.extras.
I have encountered the need for iterating over a variable number of values in a task many times, such as this contrived example below:
It remains compatible with the current named argument and prerequisites syntax using the arrow notation, and doesn't create any further auto-generated hash keys.
It also adds a to_a method to provide the full list of values passed in, regardless whether they are associated with a named argument or not.