Created
December 1, 2011 19:36
-
-
Save shishi/1419241 to your computer and use it in GitHub Desktop.
watch *.p[lm] and *.t then notify test results
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
| 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