Created
February 23, 2011 11:28
-
-
Save metalelf0/840314 to your computer and use it in GitHub Desktop.
Autotest notifier
This file contains hidden or 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::Notify | |
def self.notify title, msg, img, pri='low', time=3000 | |
`notify-send -i #{img} -u #{pri} -t #{time} '#{msg}'` | |
end | |
Autotest.add_hook :initialize do |at| | |
%w{.svn .hg .git vendor}.each {|exception| at.add_exception(exception)} | |
end | |
Autotest.add_hook :ran_command do |autotest| | |
results = [autotest.results].flatten.join("\n") | |
output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/) | |
folder = "~/Pictures/rails/" | |
if output =~ /[1-9]\d*\sfailures?/ | |
notify "FAIL:", "#{output}", folder+"rails_fail.png", 'critical', 10000 | |
elsif output =~ /[1-9]\d*\spending?/ | |
notify "PENDING:", "#{output}", folder+"rails_pending.png", 'normal', 10000 | |
else | |
notify "PASS:", "#{output}", folder+"rails_ok.png" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment