- .watchr:
def run(cmd)
`#{cmd}`
end
def run_spec_file(spec)
system('clear')
puts "Running #{spec}"
result = run("bundle exec rspec #{spec}")
puts result
growl result.split("\n").last rescue nil
end
:
def growl(message)
growlnotify = `which growlnotify`.chomp
unless growlnotify.empty?
title = "Test Results"
image = message.match(/\s0\s(errors|failures)/) ? "~/.watchr_images/ruby_green.png" : "~/.watchr_images/ruby_red.png"
options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{strip_ansi(message)}' '#{title}'"
run("#{growlnotify} #{options} &")
end
end
, ~/.watchr_images/ dev growlnotify binary .
: , , spec.opts, , , --color.
And the strip_ansigrowl method is used to mark up color codes so that it appears in the growl notification.
def strip_ansi(m)
m.gsub(/\e\[[^m]*m/, '')
end
source
share