Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
# ~.autotest module Autotest::Growl FAIL = -1 PENDING = 0 SUCCESS = 1 FAIL_IMAGE = "/Users/carlosbrando/.autotest_images/fail.png" SUCCESS_IMAGE = "/Users/carlosbrando/.autotest_images/pass.png" Autotest.add_hook :ran_command do |at| result = at.results.last if result # Unit::Test tests = result =~ /(\d+) test/ ? $1.to_i : 0 assertions = result =~ /(\d+) assertion/ ? $1.to_i : 0 errors = result =~ /(\d+) error/ ? $1.to_i : 0 # RSpec examples = result =~ /(\d+) example/ ? $1.to_i : 0 pendings = result =~ /(\d+) pending/ ? $1.to_i : 0 # Shared failures = result =~ /(\d+) failure/ ? $1.to_i : 0 code = 32 msg = if result =~ /test/ code = 31 if failures > 0 || errors > 0 "#{pluralize('test', tests)}, #{pluralize('assertion', assertions)}, #{pluralize('failure', failures)}, #{pluralize('error', errors)}" else code = (failures > 0) ? 31 : (pendings > 0) ? 33 : 32 "#{pluralize('example', examples)}, #{pluralize('failure', failures)}, #{pendings} pending" end if failures > 0 || errors > 0 growl "FAIL", msg, FAIL_IMAGE, 2 else growl "Pass", msg, SUCCESS_IMAGE end puts "\e[#{code}m#{'=' * 80}\e[0m\n\n" end end class << self def growl(title, msg, img = SUCCESS_IMAGE, pri = 0) system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title}" end def pluralize(text, number) "#{number} #{text}#{'s' if number != 1}" end end end
This paste will be private.
From the Design Piracy series on my blog: