Skip to content

Instantly share code, notes, and snippets.

@proofek
Created March 9, 2011 10:45
Show Gist options
  • Save proofek/862016 to your computer and use it in GitHub Desktop.
Save proofek/862016 to your computer and use it in GitHub Desktop.
watrchr and PHPUnit integration
watch('./(.*).php') { |m| code_changed(m[0]) }
def code_changed(file)
run "phpunit"
end
def run(cmd)
result = `cd Test && #{cmd}`
growl result rescue nil
end
def growl(message)
puts(message)
message = message.split("\n").last(3);
growlnotify = `which growlnotify`.chomp
title = message.find { |e| /FAILURES/ =~ e } ? "FAILURES" : "PASS"
if title == "FAILURES"
image = "~/.watchr_images/failed.png"
info = /\x1b\[37;41m\x1b\[2K(.*)/.match(message[1])[1]
else
image = "~/.watchr_images/passed.png"
info = /\x1b\[30;42m\x1b\[2K(.*)/.match(message[1])[1]
end
options = "-w -n Watchr --image '#{File.expand_path(image)}' --html '#{title}' -m '#{info}'"
system %(#{growlnotify} #{options} &)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment