Last active
August 29, 2015 14:01
-
-
Save asierba/1b56ab1e21322e2fe147 to your computer and use it in GitHub Desktop.
How to use :symbols when defining task dependencies
This file contains 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
# defined the '+' method of Symbol so we can do things like :build+:update_version in the task dependencies and get 'build:update_vesion' | |
# Instead of using strings which are hard to refactor | |
class Symbol | |
def method_missing(m, *args, &block) | |
if (m == :+) | |
return "#{self.to_s}:#{args[0]}" | |
else | |
super | |
end | |
end | |
end |
This file contains 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
namespace :namespace1 do | |
desc "task1" | |
task :task1 do | |
puts "task1 in namespace1" | |
end | |
desc "task2" | |
task :task2 do | |
puts "task2 in namespace1" | |
end | |
end | |
namespace :namespace2 do | |
desc "task1" | |
task :task1 do | |
puts "task1 in namespace2" | |
end | |
end | |
desc 'Run all task' | |
task :run_all => [:namespace1+:task1, :namespace1+:task2, :namespace2+:task1] |
This file contains 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
namespace :namespace1 do | |
desc "task1" | |
task :task1 do | |
puts "task1 in namespace1" | |
end | |
desc "task2" | |
task :task2 do | |
puts "task2 in namespace1" | |
end | |
end | |
namespace :namespace2 do | |
desc "task1" | |
task :task1 do | |
puts "task1 in namespace2" | |
end | |
end | |
desc 'Run all task' | |
task :run_all => ['namespace1:task1', 'namespace1:task2', 'namespace2:task1'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment