तरह ग्रेप आदेश का उपयोग कर सकते हैं, Rake.application.tasks साथ आप सभी कार्य मिलता है।
लेकिन नाम स्थान के अंदर, आप नाम स्थान (कार्य mytest: कार्यसूची) का ही कार्य का चयन कर सकते
और आप एक नाम स्थान (कार्य tasklist_mytest) को कार्य पर रोक लगा दें।
require 'rake'
namespace :mytest do |ns|
task :foo do |t|
puts "You called task #{t}"
end
task :bar do |t|
puts "You called task #{t}"
end
desc 'Get tasks inside actual namespace'
task :tasklist do
puts 'All tasks of "mytest":'
puts ns.tasks #ns is defined as block-argument
end
end
desc 'Get all tasks'
task :tasklist do
puts 'All tasks:'
puts Rake.application.tasks
end
desc 'Get tasks outside the namespace'
task :tasklist_mytest do
puts 'All tasks of "mytest":'
Rake.application.in_namespace(:mytest){|x|
puts x.tasks
}
end
if $0 == __FILE__
Rake.application['tasklist'].invoke() #all tasks
Rake.application['mytest:tasklist'].invoke() #tasks of mytest
Rake.application['tasklist_mytest'].invoke() #tasks of mytest
end
जहां तक मैंने देखा है, एक गुंजाइश के भीतर चीजों को खोजने के लिए कोई सहायक नहीं है, लेकिन मुझे लगता है कि यह इतना आसान होना चाहिए: Rake.application.tasks.reject {| task | task.scope! = [: your,: scope]} – phoet
मेरे मामले में (रेल), 'Rake.application.tasks' – joshfindit