Skip to content

Instantly share code, notes, and snippets.

@benwoody
Created October 4, 2012 14:06
Show Gist options
  • Save benwoody/3833728 to your computer and use it in GitHub Desktop.
Save benwoody/3833728 to your computer and use it in GitHub Desktop.
.autotest for notify-send
require 'autotest'
module Autotest::Notify
def self.notify title, msg, img, pri='low', time=3000
`notify-send #{title} -i #{img} -u #{pri} -t #{time} '#{msg}'`
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 = "~/Dropbox/Photos/autotest/"
if output =~ /[1-9]\d*\sfailures?/
notify "FAIL:", "#{output}", folder+"failed.png", 'critical', 10000
elsif output =~ /[1-9]\d*\spending?/
notify "PENDING:", "#{output}", folder+"pending.png", 'normal', 10000
else
notify "PASS:", "#{output}", folder+"passed.png"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment