This project is archived and is in readonly mode.
[Patch] Add beep sound when rake task fails because of pending migrations
-
Lenary
Something clever about rake is that when you do something that in any other rails item (say a method) would be redefining it, instead rake appends this action onto the rake task. this is how you could accomplish this.
Here shows what i mean by what i said in that first sentence:
task :foo do puts "bar" end task :foo do puts "baz" endwhen you run it, this happens:
⚡ rake foo (in ~/Git/rails-three/tester) bar bazI think that this is probably bloat for core rails, but i have done a little hacking and here's a snippet for your Rakefile (didn't work in a lib/tasks/*.rake file during my testing sadly)
task :plink_on_abort do def abort(string=nil) $stderr.print "\a" super end end if Rake::Task.task_defined?("db:abort_if_pending_migrations") Rake::Task["db:abort_if_pending_migrations"].prerequisites << "plink_on_abort" end-1
-
Lenary
My last comment was a little unclear. Usually the first method works, but not in this case when your addition is in the middle of lots of logic. Hence Why i showed you that snippet. If you wanted to have an even more simple solution, for it to plink on every abort, just redefine abort as i have, but at the top level in the Rakefile.
-
Dennis Theisen
Thanks for your help!
I realized it's really not a good idea to patch something like this into rails core. You can mark this ticket as invalid.I actually found a neat way of solving this problem (getting notified when rake tasks are finished) with the rakegrowl gem:
-
Rizwan Reza
- State changed from new to invalid
