If your tasks are inside of a namespace you already know which one is being called. It would not be hard to pass the name of the task to private function outside the namespace that will do some addition work for you. Here is a simple example of what I’m talking about.
namespace :grocery do
task :egg do
shop_list(“egg”)
puts " 1 egg "
end
task :milk do
shop_list("milk")
puts " 1 glass milk "
end
end
private
def shop_list(item)
puts “You are looking for #{item}”
end
Let me know if this is not what you are looking for.
Hi brian,
Thanks for the reply. Here's my requirement more specifically:
We have more than 200 tasks split across 10 different .rake files, and
we "load" them all from the Rakefile. However since these are too many
loading them all takes time (about 10 secs) and so it hurts if we have
to run rake repeatedly. So I am looking for a way to load only the
required .rake file based on the namespace:taskname supplied on the
rake command line.