<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog &#187; snarl</title>
	<atom:link href="http://monket.net/blog/tag/snarl/feed/" rel="self" type="application/rss+xml" />
	<link>http://monket.net/blog</link>
	<description></description>
	<lastBuildDate>Mon, 12 Apr 2010 13:11:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Autotest Growl notifications on Windows (using Snarl)</title>
		<link>http://monket.net/blog/2009/06/autotest-growl-notifications-on-windows-using-snarl/</link>
		<comments>http://monket.net/blog/2009/06/autotest-growl-notifications-on-windows-using-snarl/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 11:31:18 +0000</pubDate>
		<dc:creator>Karl O&#39;Keeffe</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[autotest]]></category>
		<category><![CDATA[growl]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[snarl]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://monket.net/blog/?p=50</guid>
		<description><![CDATA[Growl and Autotest work brilliantly together. Autotest runs all your tests in the background every time a file changes, giving you extremely fast feedback on your test driven development. And Growl notifications save you from needing to flip back to the Terminal to see the result of each test run, you get an unobtrusive popup [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://monket.net/blog/2009/06/simple-example-of-autotest-cucumber-and-growl/">Growl and Autotest work brilliantly together</a>. Autotest runs all your tests in the background every time a file changes, giving you extremely fast feedback on your test driven development. And Growl notifications save you from needing to flip back to the Terminal to see the result of each test run, you get an unobtrusive popup in the corner of your screen showing the success or failure of the tests.</p>

<p>But what about those users working on the Windows platform?</p>

<p><a href="http://www.fullphat.net/index.php">Snarl</a> is a windows counterpart to Growl. Providing much of the same functionality.</p>

<p>And there is a Snarl Ruby gem allowing us to create Snarl notifications from Ruby.</p>

<p>So lets convert our Growl calls to Snarl calls, and get Autotest notifications under Windows.</p>

<h2>Installing Autotest, Snarl, and the Growl to Snarl converter</h2>

<p>If you haven&#8217;t already <a href="http://www.ruby-lang.org/en/downloads/">download and install Ruby</a>.</p>

<p>First up we need to <a href="http://www.fullphat.net/index.php">download and install Snarl</a>.</p>

<p>Then we need to install Autotest and the autotest-growl gem (that we are later going to override). Open a command prompt, and type the following (Autotest is part of the ZenTest gem):</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> ZenTest
gem <span style="color: #c20cb9; font-weight: bold;">install</span> ruby-snarl
gem <span style="color: #c20cb9; font-weight: bold;">install</span> autotest-growl</pre></div></div>


<p>Then save the code below to <code>lib/autotest/growl-to-snarl.rb</code> within your project. This code converts any Growl calls to equivalent Snarl calls.</p>

<h4>growl-to-snarl.rb</h4>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'snarl'</span>
<span style="color:#9966CC; font-weight:bold;">module</span> <span style="color:#6666ff; font-weight:bold;">Autotest::Growl</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Display a message through Snarl.</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">growl</span> title, message, icon, priority=<span style="color:#006666;">0</span>, stick=<span style="color:#996600;">&quot;&quot;</span>
    image = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'HOME'</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#996600;">'.autotest-growl'</span>, <span style="color:#996600;">&quot;#{icon}.png&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    image = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>GEM_PATH, <span style="color:#996600;">'img'</span>, <span style="color:#996600;">&quot;#{icon}.png&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">exists</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>image<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
	Snarl.<span style="color:#9900CC;">show_message</span><span style="color:#006600; font-weight:bold;">&#40;</span>title, message.<span style="color:#9900CC;">inspect</span>, image<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<p>Next we need to update our <code>.autotest</code> configuration file to include the autotest-growl gem, and the Growl to Snarl converter. Add the following to your <code>.autotest</code> file in the project root directory.</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'autotest-growl'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'snarl'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'lib/autotest/growl-to-snarl'</span></pre></div></div>


<h2>Running Autotest with Snarl support</h2>

<p>First up ensure Snarl is running (check for the icon in the system tray).</p>

<p>Autotest will fail to run on Windows if a <code>HOME</code> environment variable doesn&#8217;t exist, so we need to create one before we run (I&#8217;ve also noticed that the Ruby <code>gem</code> command will fail to run if the <code>HOME</code> evironment variable <em>does</em> exist, which is frustrating!).</p>

<p>Open a command prompt, navigate to the project root directory. Then enter the following to set the <code>HOME</code> environment variable and run Autotest.</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">HOME</span>=<span style="color: #ff0000;">&quot;C:\Documents and Settings\username&quot;</span>
autotest</pre></div></div>


<p>The results of your test runs should now display as Snarl notifications.</p>
]]></content:encoded>
			<wfw:commentRss>http://monket.net/blog/2009/06/autotest-growl-notifications-on-windows-using-snarl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
