Created
December 10, 2008 04:38
-
-
Save champierre/34233 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Autotest::Growl | |
def self.growl title, msg, img="~/.autotest_icons/rails_ok.png", pri=0, sticky="" | |
msg += " at #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}" | |
system "growlnotify -n autotest -H localhost --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{sticky}" | |
end | |
Autotest.add_hook :ran_command do |at| | |
output = at.results.last.slice(/(\d+)\s+tests,\s*(\d+)\s+assertions,\s*(\d+)\s+failures,\s*(\d+)\s+errors/) | |
if output | |
if $~[3].to_i > 0 || $~[4].to_i > 0 | |
growl "Tests Failed", "#{output}", "~/.autotest_icons/rails_fail.png", 2, "-s" | |
else | |
growl "Tests Passed", "#{output}", "~/.autotest_icons/rails_ok.png", -2 | |
end | |
else | |
growl "Tests Failed", "errors", "~/.autotest_icons/rails_fail.png", 2, "-s" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment