initial work on notifier

This commit is contained in:
John Bintz 2011-05-26 10:31:56 -04:00
parent 46c04a8e79
commit b373b3ced7
1 changed files with 24 additions and 1 deletions

View File

@ -1,8 +1,31 @@
require 'guard/notifier'
module Guard module Guard
class JasmineHeadlessWebkitRunner class JasmineHeadlessWebkitRunner
class << self class << self
def run(paths = []) def run(paths = [])
system %{jasmine-headless-webkit -c #{paths.join(" ")}} passes = fails = 0
capturing = 0
Open3.popen3(%{jasmine-headless-webkit -c #{paths.join(" ")}}) do |stdin, stdout, stderr|
stdin.close
stderr.close
while !stdout.eof?
$stdout.print (char = stdout.getc)
$stdout.flush
case char.chr
when "\n"
capturing += 1
when '.'
passes += 1 if capturing == 1
when "F"
fails += 1 if capturing == 1
end
end
end
Notifier.notify("#{passes + fails} examples, #{fails} failures", :title => 'Jasmine results', :image => (fails == 0) ? :success : :failes)
$?.exitstatus $?.exitstatus
end end
end end