Getting namespaces from rake

C

Chris Kilmer

I am trying to automate the process of running all of the rake tasks
within a specific directory. Currently, we have a file that looks like
this:

namespace :myapp do

namespace :bootstrap do

desc "Bootstrap users"
task :users do
end

desc "Bootstrap categories"
task :categories do
end

desc "Bootstrap all"
task :all do
tasks = %w[users categories]
tasks.each do |task|
Rake::Task["myapp:bootstrap:#{task}"].invoke
end
end

end

end

I would like a way to have the :all task look at the myapp:bootstrap
namespace and provide a list of tasks automatically. We want to avoid
someone adding a bootstrap task and forgetting to add it to the array in
the all task (i.e. %w[...)].

I have read through the rake docs and look at the source, but I'm just
not getting it.

I've looked the following:

tasks = Rake::NameSpace(task_manager, "myapp:bootstrap)

Of course, this doesn't work because I can't figure out how to get and
use a TaskManager object.

I'm sure there is a way to get the task list other than grepping rake -T
myapp:bootstrap. Can anyone provide some insight? All help
appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top