This project is archived and is in readonly mode.

#3384 ✓invalid
Dennis Theisen

[Patch] Add beep sound when rake task fails because of pending migrations

Reported by Dennis Theisen | October 16th, 2009 @ 06:45 PM

Background:

When running e.g. tests that take a few minutes, most users (or is it only me?) use rake db:migrate and then do something else. In a bigger project it is quite common that fetching the latest changes from git added a new migration file.

Because the console is in the background often times the user doesn't know that the migrations haven't been applied yet and time is wasted. A default error/warn sound could help notify the user that there's a problem.

The attached patch is tiny and basically just adds the beep character to the error message.

Comments and changes to this ticket

  • Dennis Theisen
  • Lenary

    Lenary April 18th, 2010 @ 12:29 AM

    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"
    end
    

    when you run it, this happens:

    ⚡ rake foo
    (in ~/Git/rails-three/tester)
    bar
    baz
    

    I 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

    Lenary April 18th, 2010 @ 12:35 AM

    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

    Dennis Theisen April 18th, 2010 @ 01:52 AM

    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:

    http://github.com/porras/rakegrowl

  • Rizwan Reza

    Rizwan Reza May 15th, 2010 @ 03:07 PM

    • State changed from “new” to “invalid”
  • Ryan Bigg

    Ryan Bigg October 9th, 2010 @ 09:48 PM

    • Tag cleared.

    Automatic cleanup of spam.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages