Calling Rake Task's with in Rake

43 sec read

If you want to call a Rake task within or from other rake files, then the pretty straight-forward, just use it like
Rake::Task[“:“].invoke.
Not sure how it may work and if you prefer a working Ruby on Rails demo?, then you can download the source code from GITHUB’s
https://github.com/spritlesoftware/rake-from-rake.
It was built using Rails4, Ruby 2
Here is a sample code snippet if you prefer.
[source language=”ruby”]
namespace :myproject do
namespace :taskgroup_one do
desc “MyProject | Task Group one | task one description”
task task_one: :environment do
puts “I am task one from – Tasks group one”
end
desc “MyProject | Task Group one | task two description”
task task_two: :environment do
puts “I am task two from – Tasks group one”
end
desc “MyProject | Task Group one | Call tasks from this group”
task call_tasks_from_group_one: :environment do
Rake::Task[“myproject:taskgroup_one:task_one”].invoke
Rake::Task[“myproject:taskgroup_one:task_two”].invoke
end
desc “MyProject | Task Group one | Call tasks from group two”
task call_tasks_from_group_two: :environment do
Rake::Task[“myproject:taskgroup_two:task_one”].invoke
Rake::Task[“myproject:taskgroup_two:task_two”].invoke
end
end
end
[/source]

Related posts:

My Testing Experience with Healthcare Project

Hi Folks, I am working on a healthcare related web application. I would like to share few interesting things that I came across while...
Ashwin Sundarabaskar
5 min read

Fix for Net::OpenTimeout: execution expired When on AWS with…

If you happen to see the error “Net::OpenTimeout: execution expired” and if it originating from /home/ubuntu/.rvm/rubies/ruby-x.x.x/lib/ruby/x.x.x/net/smtp.rb and if you are running your server on...
Praveen Kumar
15 sec read

Leave a Reply

Your email address will not be published. Required fields are marked *