Skip to main content
Updated to use the shorthand .each(&:invoke)
Source Link
Joshua Pinter
  • 47.9k
  • 23
  • 261
  • 258

I suggest you to use this if you have lots of tasks in the namespace.

task :my_tasks do Rake.application.in_namespace(:my_tasks){|namespace| namespace.tasks.each{|t| t.(&:invoke})} end 

And then you can run all tasks in the namespace by:

rake my_tasks 

With this, you don't need to worry to change your :all task when you add new tasks into that namespace.

I suggest you to use this if you have lots of tasks in the namespace.

task :my_tasks do Rake.application.in_namespace(:my_tasks){|namespace| namespace.tasks.each{|t| t.invoke}} end 

And then you can run all tasks in the namespace by:

rake my_tasks 

With this, you don't need to worry to change your :all task when you add new tasks into that namespace.

I suggest you to use this if you have lots of tasks in the namespace.

task :my_tasks do Rake.application.in_namespace(:my_tasks){|namespace| namespace.tasks.each(&:invoke)} end 

And then you can run all tasks in the namespace by:

rake my_tasks 

With this, you don't need to worry to change your :all task when you add new tasks into that namespace.

Replace `x` with `namespace`, which is the object being passed into the block.
Source Link
Joshua Pinter
  • 47.9k
  • 23
  • 261
  • 258

I suggest you to use this if you have lots of tasks in the namespace.

task :my_tasks do Rake.application.in_namespace(:my_tasks){|x||namespace| xnamespace.tasks.each{|t| t.invoke}} end 

And then you can run all tasks in the namespace by:

rake my_tasks 

With this, you don't need to worry to change your :all task when you add new tasks into that namespace.

I suggest you to use this if you have lots of tasks in the namespace.

task :my_tasks do Rake.application.in_namespace(:my_tasks){|x| x.tasks.each{|t| t.invoke}} end 

And then you can run all tasks in the namespace by:

rake my_tasks 

With this, you don't need to worry to change your :all task when you add new tasks into that namespace.

I suggest you to use this if you have lots of tasks in the namespace.

task :my_tasks do Rake.application.in_namespace(:my_tasks){|namespace| namespace.tasks.each{|t| t.invoke}} end 

And then you can run all tasks in the namespace by:

rake my_tasks 

With this, you don't need to worry to change your :all task when you add new tasks into that namespace.

Source Link
Rocky
  • 5.8k
  • 8
  • 36
  • 38

I suggest you to use this if you have lots of tasks in the namespace.

task :my_tasks do Rake.application.in_namespace(:my_tasks){|x| x.tasks.each{|t| t.invoke}} end 

And then you can run all tasks in the namespace by:

rake my_tasks 

With this, you don't need to worry to change your :all task when you add new tasks into that namespace.