Added rake task to execute every rake task for every foodcoop.
This commit is contained in:
parent
ec2e761e7f
commit
ea547c84f0
2 changed files with 20 additions and 0 deletions
|
@ -24,6 +24,14 @@ class FoodsoftConfig
|
|||
config[key]
|
||||
end
|
||||
|
||||
# Loop through each foodcoop and executes the given block after setup config and database
|
||||
def each_coop
|
||||
APP_CONFIG.keys.reject { |coop| coop =~ /^(default|development|test|production)$/ }.each do |coop|
|
||||
select_foodcoop coop
|
||||
yield coop
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_config(foodcoop)
|
||||
|
|
12
lib/tasks/multicoops.rake
Normal file
12
lib/tasks/multicoops.rake
Normal file
|
@ -0,0 +1,12 @@
|
|||
namespace :multicoops do
|
||||
|
||||
desc 'Runs a specific rake task for each registered foodcoop, use rake multicoops:run db:migrate'
|
||||
task :run => :environment do
|
||||
task_to_run = ARGV[1]
|
||||
FoodsoftConfig.each_coop do |coop|
|
||||
puts "Run '#{task_to_run}' for #{coop}"
|
||||
Rake::Task[task_to_run].invoke
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in a new issue