Allow cleaning namespaces.
Rake::Task class has a clear() method for removing actions and prerequisites from task. Would it be possible to provide method like this for Rake::NameSpace to remove all tasks?
Also, there is no (at least I couldn't find any) method for searching for namespace like [](task_name) in Rake::Task. There is [](name) method in there, but it searches for task in namespace.
These two features could enable one to write:
Rake::NameSpace.get('namespace_name').clear
Where get is a bad excuse for a method name that returns namespace by name.
I would follow Rake::Task's API, so instead of Rake::NameSpace::get, Rake::NameSpace::[] to look up a namespace:
Rake::NameSpace['namespace_name'].clear
… so I'm for it. Also, there's only one method in Rake that has get in it, which is why I prefer [].
I wrote get because NameSpace already have [] method that finds tasks in namespace. Changing it's functionality could break API for some people.
That one is on a Rake::Namespace instance, the one I propose would be on the Rake::Namespace class. For example:
namespace :n do
task :t do
puts 'work'
end
end
my_namespace = Rake::Namespace['n'] # namespace "n"
my_task = my_namespace['t'] # task "n:t"
This would match Rake::Task['some_task'] (implemented here inside class << self)
Great. Looks perfect!
hey is this already in progress? I just ran into the need for this functionality myself and would be glad to implement it quickly and send a PR if nobody else is working on it