<?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>Erik A. Hanson &#187; Howto</title>
	<atom:link href="http://www.eahanson.com/category/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.eahanson.com</link>
	<description>My weblog</description>
	<lastBuildDate>Thu, 06 Jan 2011 02:27:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Testing File Uploads To A Rack Server</title>
		<link>http://www.eahanson.com/2009/03/28/testing-file-uploads-to-a-rack-server/</link>
		<comments>http://www.eahanson.com/2009/03/28/testing-file-uploads-to-a-rack-server/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 19:28:46 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.eahanson.com/?p=78</guid>
		<description><![CDATA[I wrote a web app on top of Rack that includes the ability to accept file uploads. It took some time to figure out how to successfully test the file upload using Rack::Test. The trick was to encode the file exactly correctly, and then post it with the correct headers. I wrote a simple post_file [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote a web app on top of <a href="http://rack.rubyforge.org/">Rack</a> that includes the ability to accept file uploads. It took some time to figure out how to successfully test the file upload using <a href="http://www.brynary.com/2009/3/5/rack-test-released-a-simple-testing-api-for-rack-based-frameworks-and-apps">Rack::Test</a>. </p>
<p>The trick was to encode the file exactly correctly, and then post it with the correct headers. I wrote a simple <code>post_file</code> method to do this.</p>
<pre>
  def post_file(url, param_name, file_path, content_type)
    file_name = File.basename(file_path)
    boundary = "AaB03x"
    data = "--#{boundary}\r\n" +
           "Content-Disposition: form-data; name=\"#{param_name}\"; filename=\"#{file_name}\"\r\n" +
           "Content-Type: #{content_type}\r\n" +
           "\r\n" +
           "#{File.read(file_path)}\r\n" +
           "--#{boundary}--\r\n" +
           "\r\n"
    post(url, {}, {
      "CONTENT_TYPE" => "multipart/form-data, boundary=\"#{boundary}\"",
      "CONTENT_LENGTH" => data.length, :input => data })
  end
</pre>
<p>I call it from my test like this:</p>
<pre>
...
post_file("/my_app/upload", "uploaded_image", "../test-images/originals/loki.jpg", "image/jpeg")
...
</pre>
<p>and my app reads it like this:</p>
<pre>
...
request = Rack::Request.new(env)
...
uploaded_image = request.params["uploaded_image"][:tempfile]
...
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.eahanson.com/2009/03/28/testing-file-uploads-to-a-rack-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPress 2.7 Theme Development on Mac OS X 10.5 (Leopard)</title>
		<link>http://www.eahanson.com/2008/12/17/wordpress-27-theme-development-on-mac-os-x-105-leopard/</link>
		<comments>http://www.eahanson.com/2008/12/17/wordpress-27-theme-development-on-mac-os-x-105-leopard/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 07:03:29 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Howto]]></category>

		<guid isPermaLink="false">http://www.eahanson.com/?p=41</guid>
		<description><![CDATA[I wanted to create/edit a WordPress theme on my local computer, so I had to install WordPress. It wasn&#8217;t quite as straightforward as I would have hoped. Here are some instructions: MySQL I had already downloaded and installed MySQL, so I didn&#8217;t have to do anything. If I remember, installing MySQL was straightforward. Apache Apache [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to create/edit a WordPress theme on my local computer, so I had to install WordPress. It wasn&#8217;t quite as straightforward as I would have hoped. Here are some instructions:</p>
<h3>MySQL</h3>
<p>I had already <a href="http://dev.mysql.com/downloads/">downloaded</a> and installed MySQL, so I didn&#8217;t have to do anything. If I remember, installing MySQL was straightforward.</p>
<h3>Apache</h3>
<p>Apache comes pre-installed on Mac OS X, but I had to turn it on in System Preferences &gt; Sharing &gt; Web Sharing.</p>
<h3>PHP</h3>
<p>PHP 5 comes pre-installed on Mac OS X, but I had to enable it in Apache by editing the conf file: </p>
<pre>
sudo vi /etc/apache2/httpd.conf
</pre>
<p>and uncommenting the line:</p>
<pre>
LoadModule php5_module
</pre>
<h3>WordPress</h3>
<p>I <a href="http://wordpress.org/download/">downloaded</a> WordPress and extracted it into:</p>
<pre>
~/Sites/wordpress
</pre>
<p>I followed the <a href="http://codex.wordpress.org/Installing_WordPress">installation instructions</a>, but <b>I had to use &#8220;Localhost&#8221; instead of &#8220;localhost&#8221; as my database host name</b>.</p>
<p>I created a symlink from the directory where I was editing my theme to the WordPress themes directory: </p>
<pre>
ln -s ~/Development/my-theme ~/Sites/wordpress/wp-content/themes/my-theme
</pre>
<p>Apache wasn&#8217;t set up to follow symlinks in my user directory, so I had to edit my personal conf file:</p>
<pre>
sudo vi /private/etc/apache2/users/ehanson.conf
</pre>
<p>and set the options line to:</p>
<pre>
Options Indexes MultiViews FollowSymLinks
</pre>
<p>Then I logged into the WordPress admin console at <code>http://localhost/~ehanson/wordpress/wp-admin</code>, set the theme to my new theme, and everything worked.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.eahanson.com/2008/12/17/wordpress-27-theme-development-on-mac-os-x-105-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Ruby Script To Generate a JsUnit Suite</title>
		<link>http://www.eahanson.com/2007/05/26/a-ruby-script-to-generate-a-jsunit-suite/</link>
		<comments>http://www.eahanson.com/2007/05/26/a-ruby-script-to-generate-a-jsunit-suite/#comments</comments>
		<pubDate>Sat, 26 May 2007 20:38:29 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JsUnit]]></category>

		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=16</guid>
		<description><![CDATA[I've got a bunch of JsUnit tests for a project I'm working on and I wanted an easy way to create a JsUnit suite that can run all the tests but also run any individual test page. Also, I wanted to be able to view any test page so I could debug the tests with Firebug. I also didn't want to run a web server all the time, so I wanted a script that would create a static HTML file.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve got a bunch of JsUnit tests for a project I&#8217;m working on and I wanted an easy way to create a JsUnit suite that can run all the tests but also run any individual test page.</p>
<p>Also, I wanted to be able to view any test page so I could debug the tests with Firebug (as explained <a href="http://www.eahanson.com/weblog/?p=11">here</a>).</p>
<p>I also didn&#8217;t want to run a web server all the time, so I wanted a script that would create a static HTML file.</p>
<p>Here&#8217;s what I came up with. It&#8217;s not configurable, so you&#8217;ll have to modify it for your own needs.</p>
<p align="center"><strong><a href="/code/JsUnitSuiteBuilder.rb">JsUnitSuiteBuilder.rb</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.eahanson.com/2007/05/26/a-ruby-script-to-generate-a-jsunit-suite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging a JsUnit Test With Firebug</title>
		<link>http://www.eahanson.com/2006/11/16/debugging-a-jsunit-test-with-firebug/</link>
		<comments>http://www.eahanson.com/2006/11/16/debugging-a-jsunit-test-with-firebug/#comments</comments>
		<pubDate>Thu, 16 Nov 2006 07:36:53 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JsUnit]]></category>

		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=11</guid>
		<description><![CDATA[Sometimes I find that I want to debug a JsUnit test because I'm not quite sure what's going on in the browser. FireBug has a nice debugger, but I couldn't get it to work with the JsUnit test runner. I could set breakpoints in JsUnit itself, but any breakpoints in my test would be ignored. And then it hit me: ditch the test runner.]]></description>
			<content:encoded><![CDATA[<p>Sometimes I find that I want to debug a <a href="http://www.jsunit.net/">JsUnit</a> test because I&#8217;m not quite sure what&#8217;s going on in the browser.</p>
<p><a href="http://getfirebug.com/">FireBug</a> has a nice debugger, but I couldn&#8217;t get it to work with the JsUnit test runner. I could set breakpoints in JsUnit itself, but any breakpoints in my test would be ignored.</p>
<p>And then it hit me: ditch the test runner. I opened my test page directly in Firefox, opened FireBug, clicked the Debugger tab, and chose my test from the &#8220;Scripts&#8221; menu. Here&#8217;s a simplified version:</p>
<pre>
function testUpdate() {
  var listPanel = new ListPanel();
  listPanel.update(["one", "two", "three"]);

  var children = $("content").childNodes;
  assertEquals("one", children[0]);
  assertEquals("two", children[1]);
  assertEquals("three", children[2]);
}</pre>
<p>I put a breakpoint at the first <tt>assertEquals</tt> and switched to the Console tab and typed <tt>testUpdate()</tt>. I saw the ListPanel getting drawn in the browser (something you don&#8217;t see in the JsUnit test runner) and in the Debugger tab I could inspect all my variables.</p>
<p>But even better, I could go back to the Console tab and start evaluating Javascript.</p>
<pre>
&gt;&gt;&gt; children.length
3</pre>
<p>Good.</p>
<pre>
&gt;&gt;&gt; children[0]
div</pre>
<p>Bad.</p>
<pre>
&gt;&gt;&gt; children[0].firstChild
[Text] "one"</pre>
<p>Better.</p>
<pre>
&gt;&gt;&gt; children[0].firstChild.nodeValue
"one"</pre>
<p>Perfect.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.eahanson.com/2006/11/16/debugging-a-jsunit-test-with-firebug/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A Bold Prompt in Bash</title>
		<link>http://www.eahanson.com/2006/02/12/a-bold-prompt-in-bash/</link>
		<comments>http://www.eahanson.com/2006/02/12/a-bold-prompt-in-bash/#comments</comments>
		<pubDate>Mon, 13 Feb 2006 04:20:29 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Howto]]></category>

		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=8</guid>
		<description><![CDATA[I wanted my Bash prompt to be bold and red so I could find my one line of input amongst the million lines of output in my terminal. I'm no Unix nerd, so I don't really know offhand where to look for this info. After a bunch of Googling, I found something that works for me.]]></description>
			<content:encoded><![CDATA[<p>I wanted my Bash prompt to be bold and red so I could find my one line of input amongst the million lines of output in my terminal. I&#8217;m no Unix nerd, so I don&#8217;t really know offhand where to look for this info. After a bunch of Googling, I found something that works for me. The shell variable for the prompt is naturally called <tt>PS1</tt>. The original value was:</p>
<pre>PS1='\h:\w \u\$ '</pre>
<p>The code for starting a font and color change is <tt>\e[</tt>. The code for bold red is <tt>1;31</tt>. The code for closing the starting code for a font and color tag is <tt>m</tt>. The closing code for a font and color change is <tt>\e[m</tt>. Bash thinks that these color commands will increase the length of the prompt, which will cause odd line wrapping behavior. The solution is to wrap all the color codes in brackets (<tt>\[</tt> and <tt>\]</tt>).</p>
<p>
So, the entire prompt looks like this:</p>
<pre>PS1='\[\e[1;31m\]\h:\w \u\$\[\e[m\] '</pre>
<p>Eeech. Add that to your <tt>.bashrc</tt> file and you&#8217;re all set. If you don&#8217;t want the red, the prompt would be:</p>
<pre>PS1='\[\e[1m\]\h:\w \u\$\[\e[m\] '</pre>
<p>
More colors are listed at the bottom of <a href="http://networking.ringofsaturn.com/Unix/Bash-prompts.php">this page</a>.</p>
<p>
<b>Update:</b> Somewhere along the way, all the backslashes got replaced by double backslashes. I&#8217;ve fixed that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.eahanson.com/2006/02/12/a-bold-prompt-in-bash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Join Tables with Attributes in Rails</title>
		<link>http://www.eahanson.com/2006/02/12/join-tables-with-attributes-in-rails/</link>
		<comments>http://www.eahanson.com/2006/02/12/join-tables-with-attributes-in-rails/#comments</comments>
		<pubDate>Mon, 13 Feb 2006 04:19:39 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=7</guid>
		<description><![CDATA[I had a little trouble today with join tables that contain attributes.]]></description>
			<content:encoded><![CDATA[<p>I had a little trouble today with join tables that contain attributes. </p>
<p><h4>Creating the join table</h4>
<p>Starting with tables <tt>foos</tt> and <tt>bars</tt>, I created a join table <tt>bars_foos</tt>. (Rails expects the join table&#8217;s name to be a concatenation of the two table names <i>in alphabetical order</i>). </p>
<p><h4>Reading attributes</h4>
<p>I added an attribute <tt>baz</tt> to <tt>bars_foos</tt>. I had originally tried to access it with:</p>
<pre class="wrong">myFoo.baz</pre>
<p>but that didn&#8217;t work. It turns out that I needed to force Rails to do the join before accessing the attribute, which makes sense when you think about it (but it took me a while before my little brain thought about it correctly):</p>
<pre class="right">myFoo.bars.baz</pre>
<p><h4>Adding attributes</h4>
<p>Use the well-documented <tt>push_with_attributes</tt> method:</p>
<pre>myFoo.bars.push_with_attributes(bar, :baz => &quot;fez&quot;)</pre>
<p><h4>Updating attributes</h4>
<p>Apparently you can&#8217;t. Luckily, in my app the attribute is immutable. Other people have suggested deleting and re-inserting the row which I imagine shouldn&#8217;t be a problem for most applications. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.eahanson.com/2006/02/12/join-tables-with-attributes-in-rails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Setting XSL Parameters from Javascript in AJAXSLT</title>
		<link>http://www.eahanson.com/2005/10/23/setting-xsl-parameters-from-javascript-in-ajaxslt/</link>
		<comments>http://www.eahanson.com/2005/10/23/setting-xsl-parameters-from-javascript-in-ajaxslt/#comments</comments>
		<pubDate>Sun, 23 Oct 2005 23:34:22 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[XSL]]></category>

		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=6</guid>
		<description><![CDATA[Recently, I was trying to pass some info from my Javascript into my XSL stylesheet. Here's how I finally did it.]]></description>
			<content:encoded><![CDATA[<p>Google&#8217;s <a href="http://goog-ajaxslt.sourceforge.net/">AJAXSLT</a> library is very nice, but it is lacking in documentation and sometimes hard to figure out.</p>
<p>
Recently, I was trying to pass some info from my Javascript into my XSL stylesheet. Here&#8217;s how I finally did it:</p>
<p>
<i>(Quick note: in real life, I don&#8217;t name variables &quot;myThis&quot; and &quot;myThat&quot;; I&#8217;m just doing it here to make it clear what is my code and what is part of XSL, AJAXSLT, Javascript, etc.)</i></p>
<p><h4>The XSL</h4>
<pre>
&lt;xsl:stylesheet version=&quot;1.0&quot;
    xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt;
  &lt;xsl:param name=&quot;myParam&quot; select=&quot;&apos;myDefault&apos;&quot;/&gt;
  &lt;xsl:template match=&quot;/&quot;&gt;
    myParam: &lt;xsl:value-of select=&quot;$myParam&quot;/&gt;
  &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
</pre>
<p><h4>The Javascript</h4>
<pre>
var myContext = new ExprContext(myXml);
myContext.setVariable(&quot;myParam&quot;,
    <b>new StringValue(&quot;the value for myParam&quot;)</b>);
xsltProcessContext(myContext, myXsl, myRootElement);
</pre>
<h4>The Trick</h4>
<p>So the big trick, which I figured out after reading lots of the AJAXSLT code, was to set the parameter to a <tt>StringValue</tt>, rather than a regular Javascript String. <tt>StringValue</tt> is part of AJAXSLT. <b>Update:</b> Will, in the comments below, mentions that there are four total types: <tt>StringValue</tt>, <tt>NumberValue</tt>, <tt>BooleanValue</tt> and <tt>NodeSetValue</tt>.</p>
<h4>Troubleshooting</h4>
<p>Don&#8217;t forget to declare your parameter with <code>&lt;xsl:param.../&gt;</code> before using it with <code>&lt;xsl:value-of select=&quot;$...&quot;/&gt;</code>, otherwise Ajaxslt will blow up in the middle of rendering.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.eahanson.com/2005/10/23/setting-xsl-parameters-from-javascript-in-ajaxslt/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>How To Use Google&#8217;s Ajaxslt Library</title>
		<link>http://www.eahanson.com/2005/09/30/how-to-use-googles-ajaxslt-library/</link>
		<comments>http://www.eahanson.com/2005/09/30/how-to-use-googles-ajaxslt-library/#comments</comments>
		<pubDate>Fri, 30 Sep 2005 15:53:48 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[XSL]]></category>

		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=4</guid>
		<description><![CDATA[Google has written an open-source library called Ajaxslt that implements XPath and XSLT in Javascript. It took a bit of playing to get it to work.]]></description>
			<content:encoded><![CDATA[<p><a href="http://search.yahoo.com/search?p=google&#038;sm=Yahoo%21+Search&#038;fr=FP-tab-web-t&#038;toggle=1&#038;cop=&#038;ei=UTF-8">Google</a> has written an open-source library called <a href="http://goog-ajaxslt.sourceforge.net/">Ajaxslt</a> that implements <a href="http://www.w3.org/TR/1999/REC-xpath-19991116">XPath</a> and <a href="http://www.w3.org/TR/1999/REC-xslt-19991116">XSLT</a> in Javascript.</p>
<p>It took a bit of playing to get it to work. Here&#8217;s some sample code. (I forgot to write it up when I did it, so I might have left something out.)</p>
<h3>Setup</h3>
<p>First, include the scripts. <b>Note:</b> make sure to have a closing <tt>&lt;/script&gt;</tt> tag rather than doing <tt>&lt;script ... /&gt;</tt> because that silently fails on some browsers (yay!).</p>
<pre>
&lt;!-- AJAXSLT --&gt;
&lt;script src=&quot;/ajaxslt/misc.js&quot;
    type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;/ajaxslt/dom.js&quot;
    type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;/ajaxslt/xpath.js&quot;
    type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;/ajaxslt/xslt.js&quot;
    type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;/ajaxslt/xpathdebug.js&quot;
    type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
</pre>
<h3>Using Ajaxslt for XSL Transformation</h3>
<p>For XSL transformation, you&#8217;ll need three things: some XML, some XSL, and a node (or DocumentFragment presumably) to place the result in. One way to get the XML and XSL is to load them through an XmlHttpRequest. Ajaxslt also provides a couple of handy functions to convert between text and XML:</p>
<pre>
var myText = &quot;...&quot;;
var myXml = xmlParse(myText);
var myTextAgain = xmlText(myXml);
</pre>
<p>Once you&#8217;ve got the XML and XSL, you&#8217;re ready to do the transformation:</p>
<pre>
var myNode = document.getElementById(&quot;myId&quot;);
xsltProcessContext(new ExprContext(myXml), myXsl, myNode);
</pre>
<p>Your node should now contain the result of the transformation.</p>
<h3>Using Ajaxslt for XPath</h3>
<p>You can also use Ajaxslt for XPath evaluation, which is really handy when writing tests on your rendered document:</p>
<pre>
var expr = xpathParse(myXpathString);
var result = expr.evaluate(new ExprContext(myXmlDocument));
var resultAsString = result.stringValue();
</pre>
<h3>Troublshooting</h3>
<p><b>The order of the JavaScript include statements matters:</b> if Ajaxslt is giving strange errors, make sure the scripts are included in the exact same order as  in the Setup section of this page.</p>
<p><b>Make sure you know what you&#8217;re passing to Ajaxslt:</b> if you&#8217;re sending <tt>request.responseXML</tt> to a method, don&#8217;t look at <tt>request.responseText</tt> to see what you&#8217;re passing; use <tt>xmlText(request.responseXML)</tt>.</p>
<p><b>The root element isn&#8217;t selectable:</b> if your XML is <tt>&lt;foo id=&quot;myId&quot;&gt;...&lt;/foo&gt;</tt>, then  you don&#8217;t select foo&#8217;s id with <tt>/foo/@id</tt> but rather with just <tt>@id</tt>.</p>
<p><b>Case matters in xpath:</b> If you&#8217;re evaluating an xpath expression on an HTML DOM, note that the node names are most likely uppercase. So do <tt>/HTML/BODY</tt> instead of <tt>/html/body</tt></p>
]]></content:encoded>
			<wfw:commentRss>http://www.eahanson.com/2005/09/30/how-to-use-googles-ajaxslt-library/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>Writing a Ruby Test Suite that RDT and Test::Unit Can Understand</title>
		<link>http://www.eahanson.com/2005/09/20/writing-a-ruby-test-suite-that-rdt-and-testunit-can-understand/</link>
		<comments>http://www.eahanson.com/2005/09/20/writing-a-ruby-test-suite-that-rdt-and-testunit-can-understand/#comments</comments>
		<pubDate>Tue, 20 Sep 2005 17:33:10 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=3</guid>
		<description><![CDATA[I'm working on a Ruby project using Eclipse and RDT. RDT provides a couple useful features, including support for running unit tests with Test::Unit. Unfortunately, it's pretty primitive at the moment. One big problem is that it can't run all your tests. So we wrote a test suite class that runs all tests and can be run from Test::Unit:.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on a <a href="http://www.ruby-lang.org">Ruby</a> project using <a href="http://www.eclipse.org">Eclipse</a> and <a href="http://rubyeclipse.sourceforge.net/">RDT</a>. RDT provides a couple useful features, including support for running unit tests with Test::Unit. Unfortunately, it&#8217;s pretty primitive at the moment.</p>
<p>One big problem is that it can&#8217;t run all your tests. So we wrote a test suite class that runs all tests and can be run from Test::Unit:</p>
<pre>
require 'test/unit'

Dir.chdir(&quot;test&quot;)
@@test_files = Dir.glob(&quot;**/*_test.rb&quot;)
@@test_files.each {|x| require x} 

class TestSuite
  def self.suite
    suite = Test::Unit::TestSuite.new

    @@test_files.each do |filename|
      File.open(filename) do |file|
        file.each_line do |line|
          if match = (/class\s+(\w+Test)/).match(line)
           suite &lt;&lt; eval(match[1] + &quot;.suite&quot;)
          end
        end
      end
    end

    return suite

  end
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.eahanson.com/2005/09/20/writing-a-ruby-test-suite-that-rdt-and-testunit-can-understand/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing Ruby on Rails on Mac OS X 10.4 (Tiger)</title>
		<link>http://www.eahanson.com/2005/09/07/instaling-ruby-on-rails-on-mac-os-x-104-tiger/</link>
		<comments>http://www.eahanson.com/2005/09/07/instaling-ruby-on-rails-on-mac-os-x-104-tiger/#comments</comments>
		<pubDate>Wed, 07 Sep 2005 16:55:29 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=2</guid>
		<description><![CDATA[I had a hell of a time getting Ruby on Rails to work on Mac OS X 10.4 (Tiger). Here's what ended up working for me.]]></description>
			<content:encoded><![CDATA[<p>I had a hell of a time getting <a href="http://www.rubyonrails.org/">Ruby on Rails</a> to work on <a href="http://www.apple.com/macosx/">Mac OS X 10.4 (Tiger)</a>.</p>
<p>Here&#8217;s what ended up working for me. It&#8217;s based on the <a href="http://jamie.blogthing.com/2005/05/12/installing-rails-on-a-fresh-tiger/">instructions on Jamie&#8217;s Blogomatic</a>.</p>
<p>1. Install the XCode tools from the Tiger DVD.</p>
<p>2. Download and run the Ruby on Rails installer from: <a href="http://users.tpg.com.au/aarnold/Ruby%20on%20Rails.zip">http://users.tpg.com.au/aarnold/Ruby%20on%20Rails.zip</a>.</p>
<p>3. Download and run the MySQL installer (I used version 4.1.11): <a href="http://dev.mysql.com/downloads/index.html">http://dev.mysql.com/downloads/index.html</a>.</p>
<p>4. Start mysql:  <tt>bash$ <b>sudo /usr/local/mysql/bin/mysqld_safe</b></tt></p>
<p>5. Put mysql into the background: <tt><b>ctrl-z</b></tt> and then <tt>bash$ <b>bg</b></tt></p>
<p>6. Update gems: <tt>bash$ <b>sudo gem update</b></tt></p>
<p>7. Install the mysql gem <b>from the remote source</b>: <tt>bash$ <b>sudo gem install -r mysql -- --with-mysql-dir=/usr/local/mysql</b></tt></p>
<p>8. Compile and install the MySQL API module from here: <a href="http://www.tmtm.org/en/mysql/ruby/">http://www.tmtm.org/en/mysql/ruby/</a>.</p>
<p>9. All done! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.eahanson.com/2005/09/07/instaling-ruby-on-rails-on-mac-os-x-104-tiger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

