<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: macosx code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 08 Aug 2008 11:16:46 GMT</pubDate>
    <description>DZone Snippets: macosx code</description>
    <item>
      <title>Modified Growl support for Ruby autotest</title>
      <link>http://snippets.dzone.com/posts/show/4514</link>
      <description># This code is a different approach to using Growl notifications (Mac OS X)&lt;br /&gt;# with autotest for Ruby.&lt;br /&gt;# The code can be added to ~/.autotest&lt;br /&gt;# Be sure to comment out "require 'autotest/growl'" if you have that line&lt;br /&gt;# in your .autotest file.&lt;br /&gt;# Based on ZenTest-3.6.1/lib/autotest/growl.rb&lt;br /&gt;# Requires the 2 rails png graphics found at:&lt;br /&gt;# http://blog.internautdesign.com/2006/11/12/autotest-growl-goodness&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;module Autotest::Growl&lt;br /&gt;  # save the name of the working directory (e.g., the app name)&lt;br /&gt;  # to be used as a key to identify this particular run of autotest&lt;br /&gt;  # so the same growl notification will be reused for updates,&lt;br /&gt;  # instead of a new growl window for every posting.&lt;br /&gt;  @@current_directory_name = Dir.pwd.match(/([^\/]+)\z/).to_s&lt;br /&gt;  def self.growl title, msg, pri=0&lt;br /&gt;    title += " in #{@@current_directory_name}"&lt;br /&gt;    msg += " at #{Time.now}"&lt;br /&gt;    # ### change the path to the directory for the png graphics:&lt;br /&gt;    system "growlnotify -n autotest #{pri &gt; 0 ? '-s ' : ''}--image /Users/grant/Pictures/rails_#{pri &gt; 0 ? 'fail' : 'ok'}.png -p #{pri} -d '#{Dir.pwd}' -m #{msg.inspect} #{title}"&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  Autotest.add_hook :run do  |at|&lt;br /&gt;    growl "autotest running", "Started"&lt;br /&gt;  end&lt;br /&gt;  Autotest.add_hook :red do |at|&lt;br /&gt;    growl "Tests Failed", "#{at.files_to_test.size} tests failed", 2&lt;br /&gt;  end&lt;br /&gt;  Autotest.add_hook :green do |at|&lt;br /&gt;    growl "Tests Passed", "Tests passed", -2 if at.tainted&lt;br /&gt;  end&lt;br /&gt;  Autotest.add_hook :all_good do |at|&lt;br /&gt;    growl "Tests Passed", "All tests passed", -2 if at.tainted&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 09 Sep 2007 13:22:55 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4514</guid>
      <author>grantneufeld (Grant Neufeld)</author>
    </item>
  </channel>
</rss>
