4

I have a rake task that creates diagrams:

task :diagram do
  `rake erd filetype=dot disconnected=true`
end

The execution of this task is quite slow and I guess it is because in the nested rake-invoke statement the whole rails environment is loaded again.

I wanted to use Rake::Task['...'].invoke instead. But the erd task has some non-rake arguements (filetype=dot etc.), which don't seem to work with the invoke method.

Is there a way to pass those arguments to rake so that I can use the proper rake invoke syntax.

Besi
  • 22,579
  • 24
  • 131
  • 223
  • http://stackoverflow.com/a/5050412/784318 gave me some pointers towards environment varables – Besi Jun 30 '14 at 13:58

1 Answers1

4

Try setting the ENV variables in your code:

task :diagram do
  ENV['filetype']='dot'
  ENV['disconnected'='true'

  Rake::Task['erd'].invoke
end
Uri Agassi
  • 36,848
  • 14
  • 76
  • 93