Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
# ~.autotest require 'autotest/growl' module Autotest::Growl FAIL_IMAGE = "/Users/carlosbrando/.autotest_images/fail.png" PENDING_IMAGE = "/Users/carlosbrando/.autotest_images/pending.png" SUCCESS_IMAGE = "/Users/carlosbrando/.autotest_images/pass.png" Autotest.add_hook :ran_command do |at| result = at.results.last if result # examples = result =~ /(\d+) examples/ ? $1.to_i : 0 failures = result =~ /(\d+) failure/ ? $1.to_i : 0 pendings = result =~ /(\d+) pending/ ? $1.to_i : 0 if failures > 0 growl "Tests Failed", "#{failures} test#{ 's' if failures > 1 } failed", FAIL_IMAGE elsif pendings > 0 growl "Tests Pending", "#{pendings} test#{ pendings == 1 ? ' is pending' : 's are pending'}", PENDING_IMAGE else growl "Tests Passed", "All tests passed", SUCCESS_IMAGE end code = (failures > 0) ? 31 : (pendings > 0) ? 33 : 32 puts "\e[#{code}m#{'=' * 80}\e[0m\n\n" end end class << self def growl(title, msg, img = SUCCESS_IMAGE, pri = 0) title = "Autotest Running" if title == "autotest running" msg += " at #{Time.now.strftime("%I:%M %p")}" if msg == "Started" system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title}" end end end
This paste will be private.
From the Design Piracy series on my blog: