Created
January 16, 2014 02:17
-
-
Save jonforums/8448721 to your computer and use it in GitHub Desktop.
rake cmd line task name alchemy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Safe little monkey patch to Rake...until it isn't ;) | |
module Rake | |
class Application | |
def top_level_tasks=(tasks) | |
@top_level_tasks = tasks | |
end | |
end | |
end | |
puts 'Original top level tasks: %s' % Rake.application.top_level_tasks.inspect | |
Rake.application.top_level_tasks = Rake.application.top_level_tasks.map do |v| | |
if v =~ /(ruby)(\d{2})/ | |
"#{$1}[#{$2}]" | |
else | |
v | |
end | |
end | |
puts 'Monkey patched top level tasks: %s' % Rake.application.top_level_tasks.inspect | |
desc 'build specifed ruby version' | |
task :ruby, [:version] do |t, args| | |
puts "---> building ruby version #{args.version}" | |
end | |
task :default do | |
puts '---> doing something secret by default' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C:\>rake ruby18 | |
Original top level tasks: ["ruby18"] | |
Monkey patched top level tasks: ["ruby[18]"] | |
---> building ruby version 18 | |
C:\>rake ruby19 | |
Original top level tasks: ["ruby19"] | |
Monkey patched top level tasks: ["ruby[19]"] | |
---> building ruby version 19 | |
C:\>rake ruby20 | |
Original top level tasks: ["ruby20"] | |
Monkey patched top level tasks: ["ruby[20]"] | |
---> building ruby version 20 | |
C:\>rake ruby21 | |
Original top level tasks: ["ruby21"] | |
Monkey patched top level tasks: ["ruby[21]"] | |
---> building ruby version 21 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment