Added rake task to execute every rake task for every foodcoop.

This commit is contained in:
benni 2012-08-27 08:24:25 +02:00
parent ec2e761e7f
commit ea547c84f0
2 changed files with 20 additions and 0 deletions

View file

@ -24,6 +24,14 @@ class FoodsoftConfig
config[key] config[key]
end 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 private
def set_config(foodcoop) def set_config(foodcoop)

12
lib/tasks/multicoops.rake Normal file
View 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