-
-
Save maxcal/3808114 to your computer and use it in GitHub Desktop.
watchr.rb
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
$exec = "phpunit" | |
watch('./(.*).php') { |m| changed(m[0]) } | |
def changed(file) | |
run "phpunit" | |
end | |
def run(cmd) | |
result = `#{cmd}` | |
puts result | |
# Use terminal-notify | |
#notify result | |
growl result | |
end | |
def notify(result) | |
ok = /^(OK.*)$/.match(result) | |
fail = /(FAILURES!$\n.*$)/.match(result) | |
msg = ok ? ok : fail | |
cmd = "terminal-notifier" | |
cmd = cmd + " -message '#{msg}'" | |
cmd = cmd + " -title " + "PHPUnit" | |
system cmd | |
end | |
def growl(message) | |
ok = /^(OK.*)$/.match(message) | |
fail = /(FAILURES!$\n.*$)/.match(message) | |
message = ok ? ok : fail | |
image = "~/#{ok ? 'passed' : 'failed' }.png" | |
options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}'" | |
full = %(#{'growlnotify'} #{options} &) | |
system full | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment