[Rake-devel] Invoke tasks more than once

murphy murphy at rubychan.de
Sat Feb 17 16:34:58 EST 2007


I wrote:
> ... As you can see, I had
> to tweak Task#invoke to allow them to be called repeatedly.
I just noticed that this is handy for other things, like:

  namespace :db do
    desc 'Delete all tables, and migrate DB to latest version.'
    task :reload do
      ENV['VERSION'] = '0'
      Rake::Task['db:migrate'].invoke
      ENV.delete 'VERSION'
      Rake::Task['db:migrate'].invoke false
    end
  end

...which is not possible with the current invoke method.

So, independent from the Observer Mode patch, it would be nice to have
this in Rake 0.8 :)

Actually, it might be preferable to change the semantics of #invoke to
skip the only-once check by default, and check only if the option "true"
is given. If rake is started from the shell, it would act as usual, but
if you use it manually (like in the above example), you would get the
expected result (two invocations), without a parameter.
Alternatively, an invoke_once method might be even better.

[murphy]


More information about the Rake-devel mailing list