Are the following equivalent?
namespace :resque do
task setup: :environ开发者_Go百科ment do
end
end
task "resque:setup" => :environment do
end
In short: yes. When running rake resque:setup
both of these tasks will be invoked.
Rake will merge these tasks. You can test this by doing the following:
p Rake.application.tasks
Which in this case would return something like
[<Rake::Task resque:setup => [environment]>]
Which is simply an Array holding a single Rake::Task
object. You can also check the scope or list of namespaces for a task by doing:
p Rake.application.tasks.first.scope
#=> ["resque"]
If you want to learn a little more on how the internals of Rake work, check out Rake::Task and Rake::TaskManager
精彩评论