سؤال

I've read a lot but i'm confused.

I'm trying to order the execution of my Rake tasks but haven't any luck yet. The Task looks like this:

task :populate do

  # 1st in Order
  Rake::Task['import0'].invoke
  Rake::Task['import00'].invoke

  # 2nd in Order
  Rake::Task['import000'].invoke
  Rake::Task['import0000'].invoke

  # 3rd in Order
  Rake::Task['import000000'].invoke

  # 4th in Order
  Rake::Task['import1'].invoke
  Rake::Task['import2'].invoke
  Rake::Task['import3'].invoke

  # 5th in Order
  Rake::Task['importA'].invoke
  Rake::Task['importB'].invoke
  Rake::Task['importC'].invoke

end

How can i order the execution of invokes being called. Do i have to call it from the Initial Tasks itself?

هل كانت مفيدة؟

المحلول

Yes, you can set the order when they are called.

With a maximum of 3 in each set, I would do it this way:

TASKS = [ :import0, :import00, :import000, :import0000, :import000000,
          :import1, :import2,  :import3,
          :importA, :importB,  :importC ]

TASKS.each do |t|
  Rake::Task[t.to_s].invoke
end
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top