Skip to content

Instantly share code, notes, and snippets.

@shishi
Created December 1, 2011 19:36
Show Gist options
  • Select an option

  • Save shishi/1419241 to your computer and use it in GitHub Desktop.

Select an option

Save shishi/1419241 to your computer and use it in GitHub Desktop.
watch *.p[lm] and *.t then notify test results
watch('(.*).(p[ml])') { |m| code_changed(m[0]) }
watch('(.*).t') { |m| code_changed(m[0]) }
def code_changed(file)
run "prove -cv"
end
def run(cmd)
result = `#{cmd}`
growl result rescue nil
end
def growl(message)
puts(message)
message = message.split("\n").last(2);
osn = Config::CONFIG["target_os"].downcase
growlnotify = `which growlnotify`.chomp if osn.include?("darwin")
growlnotify = `which notify-send`.chomp if osn.include?("linux")
title = message.find { |e| /Result:\sFAIL/ =~ e } ? "FAILURES" : "PASS"
info = message[0]
options = "-n Watchr '#{title}' -m '#{info}'" if osn.include?("darwin")
options = "'#{title}' '#{info}'" if osn.include?("linux")
system %(#{growlnotify} #{options} &)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment