<?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; windows</title>
	<atom:link href="http://monket.net/blog/tag/windows/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>New version of Autotest Growl (with Window support)</title>
		<link>http://monket.net/blog/2009/07/new-version-of-autotest-growl-with-window-support/</link>
		<comments>http://monket.net/blog/2009/07/new-version-of-autotest-growl-with-window-support/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 09:16:35 +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[windows]]></category>

		<guid isPermaLink="false">http://monket.net/blog/?p=187</guid>
		<description><![CDATA[In a previous post I detailed changes I made to add Growl for Windows support to Autotest Growl. These changes have now been integrated back into the autotest-growl gem. Along with some major improvements to the analysis of test results, and the details in the notifications. Thanks to Svoop, the creator of autotest-growl. This gem [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous post I detailed changes I made to <a href="http://monket.net/blog/2009/07/autotest-growl-for-windows/">add Growl for Windows support to Autotest Growl</a>.</p>

<p>These changes have now been integrated back into the <code>autotest-growl</code> gem. Along with some major improvements to the analysis of test results, and the details in the notifications. Thanks to <a href="http://github.com/svoop">Svoop</a>, the creator of <code>autotest-growl</code>.</p>

<p>This gem isn&#8217;t yet available on <a href="http://rubyforge.org/">Rubyforge</a>, but you can grab a copy from my fork on GitHub until it is:</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> karl-autotest-growl <span style="color: #660033;">--source</span> http:<span style="color: #000000; font-weight: bold;">//</span>gems.github.com</pre></div></div>


<p>This should be a drop in replacement for the previous version of <code>karl-autotest-growl</code>, the only thing you should notice more detail from the growl notifications!</p>

<p>I&#8217;ll post again once the official gem is available on <a href="http://rubyforge.org/">Rubyforge</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://monket.net/blog/2009/07/new-version-of-autotest-growl-with-window-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby Growl Notifications in Windows</title>
		<link>http://monket.net/blog/2009/07/ruby-growl-notifications-in-windows/</link>
		<comments>http://monket.net/blog/2009/07/ruby-growl-notifications-in-windows/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 14:24:57 +0000</pubDate>
		<dc:creator>Karl O&#39;Keeffe</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[growl]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://monket.net/blog/?p=167</guid>
		<description><![CDATA[I previously posted an update that enables Growl notifications for Autotest in Windows. Which is nice, but what about other Ruby programs, they might want to send Growl notifications too. To this end Vision Media have produced a Ruby Growl gem which makes it easy for any Ruby program to send Growl notifications. But the [...]]]></description>
			<content:encoded><![CDATA[<p>I previously posted an update that enables <a href="http://monket.net/blog/2009/07/autotest-growl-for-windows/">Growl notifications for Autotest in Windows<a/>.</p>

<p>Which is nice, but what about other Ruby programs, they might want to send Growl notifications too. To this end Vision Media have produced a <a href="http://github.com/visionmedia/growl/tree/master">Ruby Growl gem</a> which makes it easy for any Ruby program to send Growl notifications.</p>

<p>But the visionmedia-growl gem only works on OSX.</p>

<h2>Now With Added Windows Support</h2>

<p>So I had a go at adding Windows support. The short version is that it works, but the code is seriously ugly and not well tested (you have been warned!).</p>

<p>Check out <a href="http://github.com/karl/growl/tree/master">my visionmedia-growl fork</a>. Or just install the gem:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> karl-growl <span style="color: #660033;">--source</span> http:<span style="color: #000000; font-weight: bold;">//</span>gems.github.com</pre></div></div>


<h2>Packaging <code>growlnotify</code></h2>

<p>First up I decided to package both the OSX and Windows versions of <code>growlnotify</code> with the gem.</p>

<p>This is a departure from the existing gem, which requires that you have installed <code>growlnotify</code> yourself. I wanted to be able to include this gem in new projects without having to bother users to download extra dependencies.</p>

<h2>Choose the Right <code>growlnotify</code></h2>

<p>I decide which growlnotify to use by checking which platform we are running on:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>51
52
53
54
55
56
57
58
59
60
61
62
63
64
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">is_windows</span>?
    processor, platform, <span style="color:#006600; font-weight:bold;">*</span>rest = RUBY_PLATFORM.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;-&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    platform == <span style="color:#996600;">'mswin32'</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;">##</span>
  <span style="color:#008000; font-style:italic;"># Execute +args+ against the binary.</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#CC0066; font-weight:bold;">exec</span> <span style="color:#006600; font-weight:bold;">*</span>args
    bin = PACKAGED_BIN
    bin <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#996600;">'.com'</span> <span style="color:#9966CC; font-weight:bold;">if</span> is_windows?
&nbsp;
    <span style="color:#CC00FF; font-weight:bold;">Kernel</span>.<span style="color:#CC0066; font-weight:bold;">system</span> bin, <span style="color:#006600; font-weight:bold;">*</span>args
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>


<h2>Different Switches on Different Operating Systems</h2>

<p>The biggest headache with adding Windows support was adding the ability to generate Windows style command line arguments.</p>

<p>Example OSX command line:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">growlnotify <span style="color: #660033;">--message</span> llamas <span style="color: #660033;">--title</span> Llama<span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">--image</span> images<span style="color: #000000; font-weight: bold;">/</span>llama.png</pre></div></div>


<p>Example Windows command line:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">growlnotify.com llamas <span style="color: #000000; font-weight: bold;">/</span>t:Llama<span style="color: #000000; font-weight: bold;">!</span> <span style="color: #000000; font-weight: bold;">/</span>i:images<span style="color: #000000; font-weight: bold;">/</span>llama.png</pre></div></div>


<p>Note that in the Windows command line, switches are specified with <code>/<i>x</i>:</code> prefix, and no space. The names of the switches don&#8217;t correspont exactly with the OSX ones.</p>

<p>Also, with the Windows version of <code>growlnotify</code> you don&#8217;t give an switch for the message body, just include it as the first argument.</p>

<h2>Adding Support for Windows Style Switches</h2>

<p>The first part of adding this support was to map the OSX switches to their Windows counterparts (where they existed).</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">    switch <span style="color:#ff3333; font-weight:bold;">:title</span>,      <span style="color:#ff3333; font-weight:bold;">:t</span>
    switch <span style="color:#ff3333; font-weight:bold;">:sticky</span>,     <span style="color:#ff3333; font-weight:bold;">:s</span>
    switch <span style="color:#ff3333; font-weight:bold;">:priority</span>,   <span style="color:#ff3333; font-weight:bold;">:p</span>
    switch <span style="color:#ff3333; font-weight:bold;">:host</span>,       <span style="color:#ff3333; font-weight:bold;">:host</span>
    switch <span style="color:#ff3333; font-weight:bold;">:password</span>,   <span style="color:#ff3333; font-weight:bold;">:pass</span>
    switch <span style="color:#ff3333; font-weight:bold;">:port</span>,       <span style="color:#ff3333; font-weight:bold;">:port</span>
&nbsp;
    switch <span style="color:#ff3333; font-weight:bold;">:name</span>,       <span style="color:#ff3333; font-weight:bold;">:a</span>
    switch <span style="color:#ff3333; font-weight:bold;">:message</span>,    <span style="color:#ff3333; font-weight:bold;">:EMPTY</span>
    switch <span style="color:#ff3333; font-weight:bold;">:image</span>,      <span style="color:#ff3333; font-weight:bold;">:i</span>
    switch <span style="color:#ff3333; font-weight:bold;">:identifier</span>, <span style="color:#ff3333; font-weight:bold;">:id</span>
&nbsp;
    switch <span style="color:#ff3333; font-weight:bold;">:iconpath</span>,   <span style="color:#0000FF; font-weight:bold;">nil</span>
    switch <span style="color:#ff3333; font-weight:bold;">:appIcon</span>,    <span style="color:#0000FF; font-weight:bold;">nil</span>
    switch <span style="color:#ff3333; font-weight:bold;">:icon</span>,       <span style="color:#0000FF; font-weight:bold;">nil</span>
&nbsp;
    switch <span style="color:#ff3333; font-weight:bold;">:udp</span>,        <span style="color:#0000FF; font-weight:bold;">nil</span>
    switch <span style="color:#ff3333; font-weight:bold;">:auth</span>,       <span style="color:#ff3333; font-weight:bold;">:hash</span>
    switch <span style="color:#ff3333; font-weight:bold;">:crypt</span>,      <span style="color:#0000FF; font-weight:bold;">nil</span></pre></td></tr></table></div>


<p>As you can see, not all OSX switches are available in the Windows version of <code>growlnotify</code>. I dealt with this at the moment, by just stripping out any switches that won&#8217;t work in Windows.</p>

<p>Finally I altered (hacked?) the Growl <code>run</code> method, to produce parameter strings for either OSX or Windows.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">    <span style="color:#9966CC; font-weight:bold;">def</span> run
      <span style="color:#CC0066; font-weight:bold;">raise</span> Error, <span style="color:#996600;">'message required'</span> <span style="color:#9966CC; font-weight:bold;">unless</span> message
      <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9966CC; font-weight:bold;">class</span>.<span style="color:#9900CC;">switches</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>name, win_name<span style="color:#006600; font-weight:bold;">|</span>
        <span style="color:#9966CC; font-weight:bold;">if</span> send<span style="color:#006600; font-weight:bold;">&#40;</span>:<span style="color:#996600;">&quot;#{name}?&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
          value = send<span style="color:#006600; font-weight:bold;">&#40;</span>name<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">to_s</span> <span style="color:#9966CC; font-weight:bold;">if</span> send<span style="color:#006600; font-weight:bold;">&#40;</span>name<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> !<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">TrueClass</span> === send<span style="color:#006600; font-weight:bold;">&#40;</span>name<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
          <span style="color:#9966CC; font-weight:bold;">if</span> is_windows?
            <span style="color:#9966CC; font-weight:bold;">next</span> <span style="color:#9966CC; font-weight:bold;">if</span> win_name.<span style="color:#0000FF; font-weight:bold;">nil</span>?
&nbsp;
            switch = <span style="color:#006600; font-weight:bold;">&#40;</span>win_name == <span style="color:#ff3333; font-weight:bold;">:EMPTY</span><span style="color:#006600; font-weight:bold;">&#41;</span> ? <span style="color:#996600;">&quot;&quot;</span> : <span style="color:#996600;">&quot;/#{win_name}:&quot;</span>
            args <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> switch <span style="color:#006600; font-weight:bold;">+</span> value
          <span style="color:#9966CC; font-weight:bold;">else</span>
            args <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;--#{name}&quot;</span>
            args <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> value
          <span style="color:#9966CC; font-weight:bold;">end</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
      Growl.<span style="color:#CC0066; font-weight:bold;">exec</span> <span style="color:#006600; font-weight:bold;">*</span>args
    <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>


<p>The main points of interest here are the The windows switches don&#8217;t have any space between the switch name and the value. So instead they are concatenated together into a single string.</p>

<p>Finally we deal with the special case where using the Windows version of <code>growlnotify</code> we need to add the message parameter without a switch, so we use the special token <code>:EMPTY</code> to deal with this.</p>

<h2>The Result</h2>

<p>The results of this is a <a href="http://github.com/karl/growl/tree/master">Ruby gem that supports Growl notifications in Windows</a>. The gem can be installed with the following commands:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> karl-growl <span style="color: #660033;">--source</span> http:<span style="color: #000000; font-weight: bold;">//</span>gems.github.com</pre></div></div>


<p>And used in your Ruby program as follows:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Growl.<span style="color:#9900CC;">notify</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">message</span> = <span style="color:#996600;">'Hello World'</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">image</span> = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span> <span style="color:#996600;">'path'</span>, <span style="color:#996600;">'to'</span>, <span style="color:#996600;">'image.png'</span>
  <span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>


<p>For more usage examples see the <a href="http://github.com/karl/growl/tree/master">karl-growl site</a>.</p>

<h2>Known Issues</h2>

<p>There are a few known issues. The biggest of which no support for normalised icons.</p>

<p>To support OSX and Windows always give a path to an image, e.g.</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#ff3333; font-weight:bold;">:image</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'path/to/image.png'</span></pre></div></div>


<p>There are a number of switches that only work in OSX, and are ignored in Windows. Unsupported switches are:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#ff3333; font-weight:bold;">:iconpath</span>
  <span style="color:#ff3333; font-weight:bold;">:appIcon</span>
  <span style="color:#ff3333; font-weight:bold;">:icon</span>
  <span style="color:#ff3333; font-weight:bold;">:udp</span>
  <span style="color:#ff3333; font-weight:bold;">:crypt</span></pre></div></div>


<p>The gem has only received the most cursory of testing, so there may be a whole host of other issues, be warned!</p>

<h2>The Future</h2>

<p>I&#8217;m treating the current version of this gem, as a design spike, a proof of concept that shows we can have cross Operating System support. The code is a real mess, and has no unit tests, but I&#8217;m releasing it here to follow the <a href="http://anarchycreek.com/2009/07/11/better-now-beats-best-later/">&#8216;better now beats best later&#8217;</a> rule.</p>

<p>I hope to refactor the code into something more production worthy when I get a chance.</p>
]]></content:encoded>
			<wfw:commentRss>http://monket.net/blog/2009/07/ruby-growl-notifications-in-windows/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Autotest Growl for Windows</title>
		<link>http://monket.net/blog/2009/07/autotest-growl-for-windows/</link>
		<comments>http://monket.net/blog/2009/07/autotest-growl-for-windows/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 10:32:48 +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[windows]]></category>

		<guid isPermaLink="false">http://monket.net/blog/?p=110</guid>
		<description><![CDATA[In a previous blog post I detailed how to get Autotest Growl notifications on Windows using Snarl. But, there now exists an official Growl client for Windows. So how about we update autotest-growl to support Windows (on top of it&#8217;s existing support for OSX). If you don&#8217;t want to know all the gory details, you [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous blog post I detailed <a href="http://monket.net/blog/2009/06/autotest-growl-notifications-on-windows-using-snarl/">how to get Autotest Growl notifications on Windows using Snarl</a>. But, there now exists an <a href="http://www.growlforwindows.com/gfw/">official Growl client for Windows</a>.</p>

<p>So how about we update <code>autotest-growl</code> to support Windows (on top of it&#8217;s existing support for OSX).</p>

<p>If you don&#8217;t want to know all the gory details, you can just install my fork of the <code>autotest-growl</code> gem, that includes native Growl Windows support:</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> karl-autotest-growl <span style="color: #660033;">--source</span> http:<span style="color: #000000; font-weight: bold;">//</span>gems.github.com</pre></div></div>


<p>Obviously, you&#8217;ll need to have <a href="http://www.growlforwindows.com/gfw/">Growl for Windows</a> installed as well!</p>

<h2>Updating Autotest Growl to support Windows</h2>

<p>First up <a href="http://www.growlforwindows.com/gfw/">download and install Growl for Windows</a> (if you haven&#8217;t already).</p>

<p>Updating Autotest Growl turns out to be pretty simple. We need to download <a href="http://www.growlforwindows.com/gfw/help/growlnotify.aspx">growlnotify for Windows</a>, and add it to the <code>growl/</code> directory.</p>

<p>Then we can update the <code>autotest-growl</code> code to decide which <code>growlnotify</code> to use depending on the Operating System.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">is_windows</span>?
    processor, platform, <span style="color:#006600; font-weight:bold;">*</span>rest = RUBY_PLATFORM.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;-&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    platform == <span style="color:#996600;">'mswin32'</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;">##</span>
  <span style="color:#008000; font-style:italic;"># Display a message through Growl.</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>
    growl = <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;">'growl'</span>, <span style="color:#996600;">'growlnotify'</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>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;
    <span style="color:#9966CC; font-weight:bold;">if</span> is_windows?
      growl <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#996600;">'.com'</span>
      cmd = <span style="color:#996600;">&quot;#{growl} #{message.inspect} /a:<span style="color:#000099;">\&quot;</span>autotest<span style="color:#000099;">\&quot;</span> /r:<span style="color:#000099;">\&quot;</span>Autotest<span style="color:#000099;">\&quot;</span> /n:<span style="color:#000099;">\&quot;</span>Autotest<span style="color:#000099;">\&quot;</span> /i:<span style="color:#000099;">\&quot;</span>#{image}<span style="color:#000099;">\&quot;</span> /p:#{priority} /t:<span style="color:#000099;">\&quot;</span>#{title}<span style="color:#000099;">\&quot;</span>&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">else</span> 
      <span style="color:#9966CC; font-weight:bold;">if</span> @@remote_notification
        cmd = <span style="color:#996600;">&quot;#{growl} -H localhost -n autotest --image '#{image}' -p #{priority} -m #{message.inspect} '#{title}' #{stick}&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">else</span>
        cmd = <span style="color:#996600;">&quot;#{growl} -n autotest --image '#{image}' -p #{priority} -m #{message.inspect} '#{title}' #{stick}&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#CC0066; font-weight:bold;">system</span> cmd
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>


<p>You&#8217;ll notice that the command line flags are slightly different for the Windows version of <code>growlnotify</code>, the using the <code>/x:</code> format, rather than the OSX <code>-x </code> format.</p>

<p>The Windows version also adds the flat <code>/r:"Autotest"</code> to ensure the Autotest application is registered the first time it is run.</p>

<p>There is no need to deal with the <code>@@remote_notification</code> settings, as Growl for Windows does not have the same problem with <a href="https://bugs.launchpad.net/growl/+bug/267767">intermittent notification loss</a> that OSX does.</p>

<h2>Installing updated Autotest Growl gem</h2>

<p>I have rolled all these changes into my fork of <code>autotest-growl</code>. To switch over to this fork, open a Windows command prompt and enter:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem uninstall autotest-growl
gem <span style="color: #c20cb9; font-weight: bold;">install</span> karl-autotest-growl <span style="color: #660033;">--source</span> http:<span style="color: #000000; font-weight: bold;">//</span>gems.github.com</pre></div></div>


<p>And then watch the notifications roll in!</p>
]]></content:encoded>
			<wfw:commentRss>http://monket.net/blog/2009/07/autotest-growl-for-windows/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<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>
