Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow cleaning namespaces. #58

Open
mtuchowski opened this issue Jul 29, 2015 · 6 comments · May be fixed by #371
Open

Allow cleaning namespaces. #58

mtuchowski opened this issue Jul 29, 2015 · 6 comments · May be fixed by #371

Comments

@mtuchowski
Copy link

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.

@drbrain
Copy link
Member

drbrain commented Jul 29, 2015

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

@drbrain
Copy link
Member

drbrain commented Jul 29, 2015

… so I'm for it. Also, there's only one method in Rake that has get in it, which is why I prefer [].

@mtuchowski
Copy link
Author

I wrote get because NameSpace already have [] method that finds tasks in namespace. Changing it's functionality could break API for some people.

@drbrain
Copy link
Member

drbrain commented Jul 30, 2015

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)

@mtuchowski
Copy link
Author

Great. Looks perfect!

@frankpinto
Copy link

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

@fatkodima fatkodima linked a pull request Dec 21, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants