public
Description: bash, git, vim, irb, rails, sake
Clone URL: git://github.com/mislav/dotfiles.git
dotfiles / autotest
100644 28 lines (23 sloc) 0.842 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module Autotest::Growl
  def self.growl title, msg, pri = 0, img = nil
    # title += " in #{Dir.pwd.split(/\//)[-3..-1].join("/")}"
    # msg += " at #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}"
    
    # TODO: parameterize default image
    img ||= "/Applications/Mail.app/Contents/Resources/Caution.tiff"
    cmd = "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title.inspect}"
    system cmd
  end
 
  Autotest.add_hook :initialize do |at|
    growl "autotest running", "Started"
    false
  end
 
  Autotest.add_hook :red do |at|
    growl "Tests Failed", "#{at.files_to_test.size} tests failed", 2
  end
 
  Autotest.add_hook :green do |at|
    growl "Tests Passed", "Tests passed", -2 if at.tainted
  end
 
  Autotest.add_hook :all_good do |at|
    growl "Tests Passed", "All tests passed", -2 if at.tainted
  end
end