|
|
# vi: ft=ruby
module Autotest::Growl
def self.growl title, msg, img="", pri='normal', sticky=""
image = img != '' ? "-i #{img}" : ""
system "notify-send #{image} '#{title}' '#{msg.inspect}'"
end
def self.whisper(whut, wpm=20, pitch=0)
system "espeak -p#{pitch} -s#{wpm} '#{whut}'"
end
def self.get_results( input )
output = input.detect{ |result| result.include? "example"}
remove_color_codes( output )
end
def self.remove_color_codes( string )
string.match( /m(.+)\e/)[1]
end
Autotest.add_hook :ran_command do |at|
image_root = "~/.autotest_images"
tallies = get_results(at.results)
examples, failures, pending = tallies.split(", ")
# I've taken to making the pitch and speed of the announcements random
# began really because I thought it would be a nice way to try a bunch
# of combinations in order to find something I liked best, but I rather
# like the randomness now.
pitch = rand(99)
wpm = rand(250)
puts "wpm: #{wpm} pitch #{pitch} tallies: #{tallies}"
if failures.to_i > 0
growl "FAIL", "#{failures.to_i} failed", "#{image_root}/fail.png", 2 #, "-s"
whisper "#{failures.to_i} fayal", 10 # failures are always low pitched and monotonous
else
growl "Pass", "#{examples.to_i}", "#{image_root}/pass.png"
whisper "#{examples.to_i} passing", wpm, pitch
end
if pending.to_i > 0
growl "PENDING", "#{pending.to_i} are still pending", "#{image_root}/pending.png"
whisper "#{pending.to_i} are still pending", wpm, pitch
end
growl "Summary", tallies
end
end
|