<?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>Meta Bates &#187; General</title>
	<atom:link href="http://www.metabates.com/category/general/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.metabates.com</link>
	<description>The technical ramblings of Mark Bates.</description>
	<lastBuildDate>Wed, 01 Feb 2012 16:25:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Using Sprockets without Rails</title>
		<link>http://www.metabates.com/2011/08/31/using-sprockets-without-rails/</link>
		<comments>http://www.metabates.com/2011/08/31/using-sprockets-without-rails/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 19:17:23 +0000</pubDate>
		<dc:creator>Mark Bates</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[coffee script]]></category>
		<category><![CDATA[coffeescript]]></category>
		<category><![CDATA[rack]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sprockets]]></category>

		<guid isPermaLink="false">http://www.metabates.com/?p=503</guid>
		<description><![CDATA[I&#8217;ve started working this week on an example application for the next book I&#8217;m about to write and I wanted a simple way for my readers to easily run the app (it&#8217;s going to be a single HTML file with a ton of cool JavaScript going on in it). My first choice for running this [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started working this week on an example application for the next book I&#8217;m about to write and I wanted a simple way for my readers to easily run the app (it&#8217;s going to be a single HTML file with a ton of cool JavaScript going on in it). My first choice for running this app was to use the popular Ruby library, <a href="http://rack.rubyforge.org/" target="_blank">Rack</a>. If you are unfamiliar with Rack, please check it out. It provides a simple interface for writing web applications. By writing a simple Ruby file readers can use their favorite Rack compatible web server to launch the application. Sounds simple, eh? That&#8217;s because it is.</p>
<p>With a simple Rack application written in a few lines of code I was able to start developing my example application. That&#8217;s when I realized I needed a good way to serve up all my <a href="http://jashkenas.github.com/coffee-script/" target="_blank">CoffeeScript</a> and <a href="http://sass-lang.com/" target="_blank">Sass</a> files. I was going to write a watchr script that did this, but I thought that was a bit heavy handed, and not very flexible, so I turned to <a href="https://github.com/sstephenson/sprockets" target="_blank">Sprockets</a>.</p>
<p>Sprockets recently gained a lot of attention because it is bundled in with <a href="http://guides.rubyonrails.org/3_1_release_notes.html" target="_blank">Rails 3.1</a> to serve up an application&#8217;s assets. It&#8217;s a clever little library that will process your files using CoffeeScript, Sass, etc&#8230; and let you bundle them up in to a single asset by using a manifest. That was exactly what I wanted. After I spent the better part of an afternoon doing a bit of research and debugging here is the Rack configuration file I came up with:</p>
<div id="gist-1184400" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="nb">require</span> <span class="s1">&#39;sprockets&#39;</span></div><div class='line' id='LC2'><span class="n">project_root</span> <span class="o">=</span> <span class="no">File</span><span class="o">.</span><span class="n">expand_path</span><span class="p">(</span><span class="no">File</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="bp">__FILE__</span><span class="p">))</span></div><div class='line' id='LC3'><span class="n">assets</span> <span class="o">=</span> <span class="no">Sprockets</span><span class="o">::</span><span class="no">Environment</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="n">project_root</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">env</span><span class="o">|</span></div><div class='line' id='LC4'>&nbsp;&nbsp;<span class="n">env</span><span class="o">.</span><span class="n">logger</span> <span class="o">=</span> <span class="no">Logger</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="no">STDOUT</span><span class="p">)</span></div><div class='line' id='LC5'><span class="k">end</span></div><div class='line' id='LC6'><br/></div><div class='line' id='LC7'><span class="n">assets</span><span class="o">.</span><span class="n">append_path</span><span class="p">(</span><span class="no">File</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">project_root</span><span class="p">,</span> <span class="s1">&#39;app&#39;</span><span class="p">,</span> <span class="s1">&#39;assets&#39;</span><span class="p">))</span></div><div class='line' id='LC8'><span class="n">assets</span><span class="o">.</span><span class="n">append_path</span><span class="p">(</span><span class="no">File</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">project_root</span><span class="p">,</span> <span class="s1">&#39;app&#39;</span><span class="p">,</span> <span class="s1">&#39;assets&#39;</span><span class="p">,</span> <span class="s1">&#39;javascripts&#39;</span><span class="p">))</span></div><div class='line' id='LC9'><span class="n">assets</span><span class="o">.</span><span class="n">append_path</span><span class="p">(</span><span class="no">File</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">project_root</span><span class="p">,</span> <span class="s1">&#39;app&#39;</span><span class="p">,</span> <span class="s1">&#39;assets&#39;</span><span class="p">,</span> <span class="s1">&#39;stylesheets&#39;</span><span class="p">))</span></div><div class='line' id='LC10'><br/></div><div class='line' id='LC11'><span class="n">map</span> <span class="s2">&quot;/assets&quot;</span> <span class="k">do</span></div><div class='line' id='LC12'>&nbsp;&nbsp;<span class="n">run</span> <span class="n">assets</span></div><div class='line' id='LC13'><span class="k">end</span></div><div class='line' id='LC14'><br/></div><div class='line' id='LC15'><span class="n">map</span> <span class="s2">&quot;/&quot;</span> <span class="k">do</span></div><div class='line' id='LC16'>&nbsp;&nbsp;<span class="n">run</span> <span class="nb">lambda</span> <span class="p">{</span> <span class="o">|</span><span class="n">env</span><span class="o">|</span></div><div class='line' id='LC17'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">[</span></div><div class='line' id='LC18'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="mi">200</span><span class="p">,</span> </div><div class='line' id='LC19'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC20'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="s1">&#39;Content-Type&#39;</span>  <span class="o">=&gt;</span> <span class="s1">&#39;text/html&#39;</span><span class="p">,</span> </div><div class='line' id='LC21'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="s1">&#39;Cache-Control&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;public, max-age=86400&#39;</span> </div><div class='line' id='LC22'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">},</span></div><div class='line' id='LC23'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="no">File</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s1">&#39;public/index.html&#39;</span><span class="p">,</span> <span class="no">File</span><span class="o">::</span><span class="no">RDONLY</span><span class="p">)</span></div><div class='line' id='LC24'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">]</span></div><div class='line' id='LC25'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC26'><span class="k">end</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1184400/525bacf6830e9f5ae339b9f2f60814d146d7e529/config.ru" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1184400#file_config.ru" style="float:right;margin-right:10px;color:#666">config.ru</a>
            <a href="https://gist.github.com/1184400">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>That will serve</p>
<pre>/assets/application.css</pre>
<p>via Sprockets. The file itself will live in</p>
<pre>&lt;pwd&gt;/app/assets/stylesheets/application.scss</pre>
<p>The same goes for JavaScript files.</p>
<p>Hopefully this will save someone else a little of time when they&#8217;re trying to do the same thing. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.metabates.com/2011/08/31/using-sprockets-without-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CoffeeScript &#8211; A Rubyist&#8217;s Love Affair</title>
		<link>http://www.metabates.com/2011/08/10/coffeescript-a-rubyists-love-affair/</link>
		<comments>http://www.metabates.com/2011/08/10/coffeescript-a-rubyists-love-affair/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 13:55:20 +0000</pubDate>
		<dc:creator>Mark Bates</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[bostonrb]]></category>
		<category><![CDATA[coffee script]]></category>
		<category><![CDATA[coffeescript]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.metabates.com/?p=499</guid>
		<description><![CDATA[Last night I had the pleasure of presenting to the Boston Ruby User&#8217;s Group on CoffeeScript. My talk was geared to helping Rubyists understand, and hopefully love, CoffeeScript. Along the way I tried to debunk a few myths and preconceptions as to what CoffeeScript is and isn&#8217;t. The reaction was really positive, so hopefully I [...]]]></description>
			<content:encoded><![CDATA[<p>Last night I had the pleasure of presenting to the <a href="http://www.bostonrb.org">Boston Ruby User&#8217;s Group</a> on CoffeeScript. My talk was geared to helping Rubyists understand, and hopefully love, CoffeeScript. Along the way I tried to debunk a few myths and preconceptions as to what CoffeeScript is and isn&#8217;t. The reaction was really positive, so hopefully I did my job. Anyway, here are the slides:</p>
<p><a href="http://www.slideshare.net/markykang/coffeescript-bostonrb-892011">http://www.slideshare.net/markykang/coffeescript-bostonrb-892011</a></p>
<p>&nbsp;</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.metabates.com/2011/08/10/coffeescript-a-rubyists-love-affair/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Let&#8217;s say goodbye to YAML for configuration, shall we?</title>
		<link>http://www.metabates.com/2011/06/28/lets-say-goodbye-to-yaml-for-configuration-shall-we/</link>
		<comments>http://www.metabates.com/2011/06/28/lets-say-goodbye-to-yaml-for-configuration-shall-we/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 17:31:46 +0000</pubDate>
		<dc:creator>Mark Bates</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[configatron]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[yaml]]></category>

		<guid isPermaLink="false">http://www.metabates.com/?p=482</guid>
		<description><![CDATA[I have to ask a question to my fellow Rubyists out there? Why are you still using YAML? I know why you think you like YAML. You think it&#8217;s a great way to write configuration files, but it&#8217;s really not. You know what&#8217;s a great way of writing configuration files for Ruby apps? RUBY! I [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.metabates.com/wp-content/uploads/2011/06/yml.png"><img class="alignleft size-medium wp-image-489" title="yml" src="http://www.metabates.com/wp-content/uploads/2011/06/yml-300x300.png" alt="" width="180" height="180" /></a>I have to ask a question to my fellow Rubyists out there? Why are you still using YAML? I know why you <em>think</em> you like YAML. You think it&#8217;s a great way to write configuration files, but it&#8217;s really not. You know what&#8217;s a great way of writing configuration files for Ruby apps? RUBY!</p>
<p>I know it&#8217;s crazy, isn&#8217;t it? But why not? Why would you not want to use Ruby for configuring your applications instead of YAML?</p>
<p>I&#8217;m the maintainer of a pretty popular configuration tool for Ruby apps, <a href="http://github.com/markbates/configatron">Configatron</a>, so I think I have a little experience in this field. I also write and maintain a lot of libraries that require configuration and I have never thought that YAML is the best way to do this.</p>
<p>Let&#8217;s look at an example of what a library developer has to do to load a YAML file to get configurations:</p>
<div id="gist-1051635" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="l-Scalar-Plain">foo</span><span class="p-Indicator">:</span></div><div class='line' id='LC2'>&nbsp;&nbsp;<span class="l-Scalar-Plain">bar</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1051635/8b2f51859c67c88817a39ec2637be8a4a42b0789/config.yml" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1051635#file_config.yml" style="float:right;margin-right:10px;color:#666">config.yml</a>
            <a href="https://gist.github.com/1051635">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="nb">require</span> <span class="s1">&#39;yaml&#39;</span></div><div class='line' id='LC2'><span class="n">config</span> <span class="o">=</span> <span class="no">YAML</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="no">ERB</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="no">File</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="s1">&#39;/path/to/config.yml&#39;</span><span class="p">))</span><span class="o">.</span><span class="n">result</span><span class="p">)</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1051635/26ccf1d5e93777a585e7dec43204e9d3857e2b4c/gistfile1.rb" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1051635#file_gistfile1.rb" style="float:right;margin-right:10px;color:#666">gistfile1.rb</a>
            <a href="https://gist.github.com/1051635">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>I don&#8217;t know about you, but I think that&#8217;s kind of lame. Most everybody runs their YAML files through ERB so that they can make their YAML files more &#8216;Ruby-ish&#8217;. Why not just use Ruby?? Here&#8217;s the same example in Ruby:</p>
<div id="gist-1051638" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="no">SomeLibrary</span><span class="o">.</span><span class="n">config</span> <span class="o">=</span> <span class="p">{</span><span class="ss">:foo</span> <span class="o">=&gt;</span> <span class="ss">:bar</span><span class="p">}</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1051638/61390f260946f24cd62e871e379b8b7c334aa25d/config.rb" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1051638#file_config.rb" style="float:right;margin-right:10px;color:#666">config.rb</a>
            <a href="https://gist.github.com/1051638">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="nb">require</span> <span class="s1">&#39;/path/to/config.rb&#39;</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1051638/f64d4b978dfcdffdc6d08d4983c264f93d36ce28/gistfile1.rb" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1051638#file_gistfile1.rb" style="float:right;margin-right:10px;color:#666">gistfile1.rb</a>
            <a href="https://gist.github.com/1051638">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>In addition to not having to deal with all the whitespace, tabs, crazy nesting, etc&#8230; that YAML brings we get to use the full power of Ruby for our configurations! Try storing a Proc in YAML. Yeah, that&#8217;s what I thought. You can drive configurations from the database, environment variables, crazy equations, etc&#8230; the world is your oyster. All you need to do now is stop using YAML!</p>
<p>I&#8217;ve decided to drop YAML support in Configatron 2.9 (coming sometime this Summer) and I encourage all other library developers to do the same. It&#8217;s just not needed, or very nice for that matter. Now, if we can only get Rails to drop the database.yml file, I think we&#8217;ll be all set.</p>
<address>Ps. Make sure to check out my app <a href="http://www.fluxtracker.com?ref=yaml">FluxTracker.com</a> for all your issue, project, and error tracking needs. Also check out <a href="http://tweetko.com?ref=yaml">TweetKO.com</a> for backing up and bookmarking your favorite tweets.</address>
]]></content:encoded>
			<wfw:commentRss>http://www.metabates.com/2011/06/28/lets-say-goodbye-to-yaml-for-configuration-shall-we/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Backup and Bookmark your Tweets with TweetKO.com</title>
		<link>http://www.metabates.com/2011/06/19/backup-and-bookmark-your-tweets-with-tweetko-com/</link>
		<comments>http://www.metabates.com/2011/06/19/backup-and-bookmark-your-tweets-with-tweetko-com/#comments</comments>
		<pubDate>Sun, 19 Jun 2011 21:18:19 +0000</pubDate>
		<dc:creator>Mark Bates</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[tweetko]]></category>
		<category><![CDATA[tweets]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.metabates.com/?p=468</guid>
		<description><![CDATA[Twitter is an incredibly rich source of information. I find out about new libraries, applications, plugins, screen casts, etc&#8230; But, there&#8217;s a problem with is overwhelming amount of information&#8230; keeping track of it all. A lot of time I read Twitter when I&#8217;m on my phone. I&#8217;ll see a link to an article or website, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.metabates.com/wp-content/uploads/2011/06/bigbird_sq.png"><img class="alignleft size-medium wp-image-469" title="bigbird_sq" src="http://www.metabates.com/wp-content/uploads/2011/06/bigbird_sq-300x300.png" alt="" width="300" height="300" /></a>Twitter is an incredibly rich source of information. I find out about new libraries, applications, plugins, screen casts, etc&#8230; But, there&#8217;s a problem with is overwhelming amount of information&#8230; keeping track of it all. A lot of time I read Twitter when I&#8217;m on my phone. I&#8217;ll see a link to an article or website, etc&#8230; but I don&#8217;t have time to read it then, what do I do? How do I find that tweet later? Or what about that announcement or news link for a new service or application that I saw six months ago? How do I find that again?</p>
<p>Twitter is great but it&#8217;s ability to help you find specific tweets that are important to you is almost important. That&#8217;s why today I&#8217;m happy to announce <a href="http://tweetko.com">TweetKO.com</a>. TweetKO solves this problem by using the built &#8216;favorite&#8217; functionality that Twitter offers. From <em>ANY </em>Twitter client you can simply mark a tweet as a favorite and TweetKO will pull it in and save it for you so you can find it later.</p>
<p>That&#8217;s it! It really is that simple. TweetKO is <strong>FREE</strong> and easy to use. In addition to pulling in your favorite tweets you can tell TweetKO to also pull in any tweets you wrote or retweeted, effectively backing up your Twitter history. A powerful search makes finding those tweets simple and easy. Plus you can save those search queries for later use.</p>
<p>Well, I hope you check out TweetKO.com and find it as useful as I do. Enjoy!</p>
<h3 style="text-align: center;"><span style="text-decoration: underline;"><a href="http://tweetko.com">http://tweetko.com - Sign up for Free Now!</a></span></h3>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.metabates.com/2011/06/19/backup-and-bookmark-your-tweets-with-tweetko-com/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Collect user feedback through FluxTracker.com</title>
		<link>http://www.metabates.com/2011/06/13/collect-user-feedback-through-fluxtracker-com/</link>
		<comments>http://www.metabates.com/2011/06/13/collect-user-feedback-through-fluxtracker-com/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 16:00:24 +0000</pubDate>
		<dc:creator>Mark Bates</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[feedback]]></category>
		<category><![CDATA[fluxtracker]]></category>
		<category><![CDATA[issue tracking]]></category>
		<category><![CDATA[project management]]></category>

		<guid isPermaLink="false">http://www.metabates.com/?p=464</guid>
		<description><![CDATA[About six weeks ago I announced FluxTracker.com a unified issue, document, and error management service. The response has been amazing. People love that you can now manage all of those things in one place, without any configuration. Well, today I&#8217;m happy to announce that FluxTracker has taken the next step forward to make managing all [...]]]></description>
			<content:encoded><![CDATA[<p>About six weeks ago I announced <a href="http://www.fluxtracker.com?ref=metabates2">FluxTracker.com</a> a unified issue, document, and error management service. The response has been amazing. People love that you can now manage all of those things in one place, without any configuration. Well, today I&#8217;m happy to announce that FluxTracker has taken the next step forward to make managing all aspects of your project easier. Introducing FluxTracker <a href="http://bit.ly/juVpLJ">Feedback</a>.</p>
<p>FluxTracker Feedback allows you to put a little feedback widget on your site that can be used to collect information from your users, such as feature requests, support requests, and general comments. This feedback is automatically added to your FluxTracker project and from there it&#8217;s up to you to decide what you want to do with it. Of course it supports FluxTracker&#8217;s Issue Connect system so you can turn that customer feedback into an actionable issue with just one click?</p>
<p>Now you&#8217;re probably saying to yourself, I bet it&#8217;s really difficult to implement on my site. Well, you&#8217;d be wrong! It&#8217;s as simple as just adding one line to your site:</p>
<p><a href="http://www.fluxtracker.com/pages/api/feedback">http://www.fluxtracker.com/pages/api/feedback</a></p>
<p>The widget can be customized too. CSS, text, and even the questions can be customized (well, depending on the plan you&#8217;re on). Just check out the Feedback tab on the right side of the page to see the Feedback widget in action.</p>
<p>Well, as you can tell I&#8217;m very excited about this. I think it really makes FluxTracker the true center for managing your application, and I think  you&#8217;ll find that too. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.metabates.com/2011/06/13/collect-user-feedback-through-fluxtracker-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stop Complaining. Start Contributing!</title>
		<link>http://www.metabates.com/2011/05/24/stop-complaining-start-contributing/</link>
		<comments>http://www.metabates.com/2011/05/24/stop-complaining-start-contributing/#comments</comments>
		<pubDate>Tue, 24 May 2011 15:56:33 +0000</pubDate>
		<dc:creator>Mark Bates</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[github.com]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://www.metabates.com/?p=454</guid>
		<description><![CDATA[Because I maintain several open source projects on Github I&#8217;m constantly getting emailed questions or issues, or people are always opening up tickets with bugs, issues, complaints, etc&#8230; And I really appreciate the feedback on these projects, I really do. What I would appreciate more is if instead of just opening a ticket, or sending [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" title="stop complaining" src="http://tanamatales.com/wp-content/uploads/2011/05/stop_complaining1.jpg" alt="" width="300" height="225" />Because I maintain several open source projects on <a href="http://github.com/markbates" target="_blank">Github</a> I&#8217;m constantly getting emailed questions or issues, or people are always opening up tickets with bugs, issues, complaints, etc&#8230; And I really appreciate the feedback on these projects, I really do. What I would appreciate more is if instead of just opening a ticket, or sending an email, why not fork the project, fix it, and then contact me?</p>
<p>Now, I know that sounds like a lot of work, but honestly it&#8217;s really not. Github has made contributing to open source projects so trivial that everyone should be doing it. Take for example a recent ticket I got for one of my projects. The gist of ticket was that if there was a space in the project name the library would throw an error. That&#8217;s a great bug! It&#8217;s also an incredibly easy one to fix. If the person who opened the ticket has actually just submitted a pull request with the fix instead the fix would already have been deployed. Granted it would&#8217;ve taken a bit more than the few minutes to open the ticket, but not that much more. [UPDATE: He actually did fork the project and is trying to fix it! Awesome!]</p>
<p>So why should you do this? Why should you take the time to fix your own issues instead of having the library owner/maintainer do it? Well, the reasons are plentiful, but here are a few of my favorites:</p>
<ul>
<li>You can have it now! That&#8217;s right, if you fork the project and fix the bug or add that new feature you can start using today! Even before the project owner has a chance to merge in the pull request. That&#8217;s a total win right there!</li>
<li>Quicker to be released to the general public. Maintainers of open source projects are busy people and, usually, don&#8217;t spend all day working on their open source libraries. If someone submits a good patch or feature then it&#8217;s easier for them to pull it in and get it out as a proper release sooner.</li>
<li>It feels good! It feels really good to contribute back to a project that you use often. After awhile you might even get commit rights to the project and won&#8217;t have to maintain a fork. That feels really good!</li>
<li>Build a name for yourself. That&#8217;s one of the ways you land better jobs or contracts. People start seeing your name floating around commit messages. You get to know the people maintaining the projects, they like your work, then when they&#8217;re looking to fill a position, guess who they think of?</li>
<li>It makes you a better developer. By contributing to different projects you learn different techniques. You get to understand the code of the library you&#8217;re using and learn little tricks that you might not have known about otherwise.</li>
</ul>
<p>Those are just a few of the reasons why giving back to the open source community is great. So the question I&#8217;m going to leave you with now is are you going to be a player or a hater? Someone who just complains all day, or someone who helps to make the world a better place? I&#8217;m hoping you become the latter.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.metabates.com/2011/05/24/stop-complaining-start-contributing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project, Issue, and Error Tracking United!</title>
		<link>http://www.metabates.com/2011/04/25/project-issue-and-error-tracking-united/</link>
		<comments>http://www.metabates.com/2011/04/25/project-issue-and-error-tracking-united/#comments</comments>
		<pubDate>Mon, 25 Apr 2011 12:00:45 +0000</pubDate>
		<dc:creator>Mark Bates</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Press]]></category>
		<category><![CDATA[Releases]]></category>
		<category><![CDATA[basecamp]]></category>
		<category><![CDATA[error tracking]]></category>
		<category><![CDATA[fluxtracker]]></category>
		<category><![CDATA[hoptoad]]></category>
		<category><![CDATA[issue tracking]]></category>
		<category><![CDATA[lighthouse]]></category>
		<category><![CDATA[project management]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.metabates.com/?p=436</guid>
		<description><![CDATA[For the last few years every project or company I&#8217;ve worked for has started the same way, by setting up Basecamp, Lighthouse and Hoptoad (or similar ones anyway). Why? Basecamp  - so we could share documents and todos. Lighthouse &#8211; so we could track our issues and bugs. Hoptoad &#8211; so we could track the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.metabates.com/wp-content/uploads/2011/04/issue_list_big.png"><img class="alignleft size-medium wp-image-437" title="issue_list_big" src="http://www.metabates.com/wp-content/uploads/2011/04/issue_list_big-300x225.png" alt="" width="300" height="225" /></a>For the last few years every project or company I&#8217;ve worked for has started the same way, by setting up Basecamp, Lighthouse and Hoptoad (or similar ones anyway). Why? Basecamp  - so we could share documents and todos. Lighthouse &#8211; so we could track our issues and bugs. Hoptoad &#8211; so we could track the errors our application was generating.</p>
<p>These are all very good applications and have served myself and my clients well, but they&#8217;ve suffered from several very big flaws. The first big flaw was the cost. You can easily drop $100 or more a month across these different services. But that wasn&#8217;t the biggest flaw or problem I&#8217;ve had with these services. The biggest problem was lack of integration.</p>
<p>So what do I mean by lack of integration? Well, when an error comes in I want to easily be able to create a new issue from it. When the issue gets resolved, so should the error. If the error reoccurs it should re-open automatically, and so should the issue. I want to be able to create an issue right from a document or be able to attach issues to a document. I should be able to follow the flow from document to issue to error and back again very easily. Unfortunately, these applications don&#8217;t give you that level of integration. They offer some level, but just not enough.</p>
<p>Well, my friends, welcome to the future. Welcome to <strong><a href="http://www.fluxtracker.com?ref=metabates">FluxTracker.com</a></strong>. FluxTracker combines a great issue tracker, a project management system, and an error tracker all in one application. Now you can full integration without any configuration, oh, and you can do it at a fraction of the cost!</p>
<p>We know it isn&#8217;t easy to switch to a different application, that&#8217;s why we&#8217;ve made it easy for you. You can easily <a href="http://www.fluxtracker.com/pages/lighthouse_importing?ref=metabates">import your Lighthouse</a> account. FluxTracker also allows you to easily use the <a href="http://www.fluxtracker.com/pages/api/hoptoad_notifier?ref=metabates">Hoptoad Notifier</a> plugin for your project by just setting a few configuration parameters.</p>
<p>So know you know, you&#8217;re life can be easier. And you now know how easy it is to get started! So what are you waiting for? Go and <a href="https://www.fluxtracker.com/signup?ref=metabates">sign up</a> for our Free plan and start living the dream.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.metabates.com/2011/04/25/project-issue-and-error-tracking-united/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Because everybody has an opinion&#8230;</title>
		<link>http://www.metabates.com/2011/04/15/because-everybody-has-an-opinion/</link>
		<comments>http://www.metabates.com/2011/04/15/because-everybody-has-an-opinion/#comments</comments>
		<pubDate>Sat, 16 Apr 2011 01:30:20 +0000</pubDate>
		<dc:creator>Mark Bates</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[active record]]></category>
		<category><![CDATA[coffee script]]></category>
		<category><![CDATA[erb]]></category>
		<category><![CDATA[haml]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.metabates.com/?p=430</guid>
		<description><![CDATA[In case you&#8217;ve been living in a cave this week you&#8217;ve probably heard that Ruby on Rails is going to be including both the CoffeeScript and SASS libraries, it will also make jQuery the default JavaScript framework, replacing the Prototype framework. I would like to start by addressing my experiences with CoffeeScript. My opinion of [...]]]></description>
			<content:encoded><![CDATA[<p>In case you&#8217;ve been living in a cave this week you&#8217;ve probably heard that <a href="http://www.rubyinside.com/rails-3-1-adopts-coffeescript-jquery-sass-and-controversy-4669.html">Ruby on Rails</a> is going to be including both the <a href="http://coffeescript.org/">CoffeeScript</a> and <a href="http://sass-lang.com/">SASS</a> libraries, it will also make <a href="http://jquery.com/">jQuery</a> the default JavaScript framework, replacing the <a href="http://www.prototypejs.org/">Prototype</a> framework.</p>
<p>I would like to start by addressing my experiences with CoffeeScript. My opinion of it is of ambivalence. I&#8217;ve used it on a project, I&#8217;ve played with and in the end I&#8217;ve come out with the opinion of &#8220;it&#8217;s ok&#8221;. It didn&#8217;t blow me away, but at the same time I can see why so many people like. It offers some really cool features that I really wish JavaScript had and you can cut down on the amount of code you have to write. On the other hand the apps I tend to write don&#8217;t tend to be that JavaScript heavy that I really needed to reach out for something like CoffeeScript.</p>
<p><img class="alignleft" src="http://blogs.worldbank.org/files/publicsphere/public%20opinion_JGRNLY.jpeg" alt="" width="326" height="246" />So, how do I feel about CoffeeScript being included with Rails? Well, I&#8217;ll get to that. Let&#8217;s go over some of the most common arguments I&#8217;ve heard from people this week about why they&#8217;re anti-CoffeeScript in Rails.</p>
<blockquote><p>&#8220;It&#8217;s an abstraction layer of JavaScript! JavaScript isn&#8217;t that bad, why can&#8217;t you just write JavaScript?&#8221;</p>
<p>&#8220;It&#8217;s going to be a hinderance to newbies. It&#8217;ll be too much of a learning curve!&#8221;</p></blockquote>
<p>Let&#8217;s start with that second point first, shall we? I agree, it does represent a new element that needs to be learned when coming to Rails. But here&#8217;s the pretty nifty thing about how it&#8217;s all implemented in Rails. In order to actually use CoffeeScript in Rails you have to create your files named foo.js.coffee if, however, you just name your file foo.js then, guess what? You will have to write plain old JavaScript! Seems like newbies, and those who don&#8217;t like CoffeeScript, can just keep writing plain old JavaScript without anything stopping them at all.</p>
<p>Now, let&#8217;s talk about the abstraction layer argument. Yes, CoffeeScript is an abstraction on top of JavaScript, but let&#8217;s take a look at a few other parts of the Rails stack and see how they hold up against this argument.</p>
<p>Here&#8217;s a fairly common Rails stack:</p>
<ul>
<li>ActiveRecord</li>
<li>Haml</li>
<li>jQuery</li>
<li>RSpec</li>
</ul>
<p>What do all those things have in common? Well, they&#8217;re all abstraction layers that sit on top of something else, don&#8217;t they? Let&#8217;s look at that list again?</p>
<ul>
<li>ActiveRecord &#8211; SQL (Structured Query Language)</li>
<li>Haml &#8211; HTML</li>
<li>jQuery &#8211; JavaScript, you could just as easily hand roll those AJAX calls in pure JavaScript.</li>
<li>RSpec &#8211; Test/Unit</li>
</ul>
<p>What I&#8217;ve found funny about the particular argument is that I&#8217;ve heard it MOST from those who use things like HAML, which is a DEFINITELY an abstraction layer that sits on top of HTML. See where I&#8217;m going with this one? Good, I don&#8217;t want to belabor the point. <img src='http://www.metabates.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So, finally, where do I stand on this whole thing? Well, I view like it Test/Unit and Prototype. Those are both the current standard (although jQuery will replace Prototype in 3.1) and I don&#8217;t like or use either of them. Instead I configure Rails to use jQuery and RSpec. I don&#8217;t like Haml, but those that do simply replace ERB with Haml and they move on with their day. So my take is this, it&#8217;s there, it&#8217;s included. Use it if you like, or don&#8217;t. Is it really that big a deal? No, it really isn&#8217;t. If Rails dropped ERB and went with Haml as the default, would I bitch and moan, probably a bit, but then I&#8217;d just install the Rails-ERB gem and move on with my day, just like I do with jQuery and RSpec today.</p>
<p>So sit back, relax, use the libraries that you want to use, Rails let&#8217;s you do that. Oh, while you&#8217;re relaxing why not try out CoffeeScript, who knows, you might just enjoy it. Or not.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.metabates.com/2011/04/15/because-everybody-has-an-opinion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing Tools Aren&#8217;t All the Same, Choose Wisely</title>
		<link>http://www.metabates.com/2011/03/04/407-testing-tools-arent-all-the-same-choose-wisely/</link>
		<comments>http://www.metabates.com/2011/03/04/407-testing-tools-arent-all-the-same-choose-wisely/#comments</comments>
		<pubDate>Fri, 04 Mar 2011 15:57:04 +0000</pubDate>
		<dc:creator>Mark Bates</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[steak]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[tests]]></category>

		<guid isPermaLink="false">http://www.metabates.com/?p=407</guid>
		<description><![CDATA[&#8220;Testing is painful.&#8221; &#8220;Testing is hard.&#8221; &#8220;Testing is complicated.&#8221; &#8220;Testing is not fun.&#8221; I hear those sorts of things all the time when I talk to people about testing. I agree that sometimes testing can be all of those things, but if you choose the right tools, the tools that best suite you, testing doesn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><img class="alignright" title="mario" src="http://www.divanikkiz.com/site/images/stories/mlss_mario-hammer.jpg" alt="" width="255" height="282" />&#8220;Testing is painful.&#8221;</p></blockquote>
<blockquote><p>&#8220;Testing is hard.&#8221;</p></blockquote>
<blockquote><p>&#8220;Testing is complicated.&#8221;</p></blockquote>
<blockquote><p>&#8220;Testing is not fun.&#8221;</p></blockquote>
<p>I hear those sorts of things all the time when I talk to people about testing. I agree that sometimes testing can be all of those things, but if you choose the right tools, the tools that best suite you, testing doesn&#8217;t have to be. Let me give you an example of what I&#8217;m talking about, how choosing the right tools can make a huge impact on how you feel about testing.</p>
<p>When working for a client recently I came across the need for end to end integration testing. I needed to test, amongst other things, the flow of a user registering through the application in a few different ways. Because registration behaves differently based on where you come from and where you want to go, I needed a good way to test that entire flow, so simple unit and functional tests just were not going to cut it.</p>
<p>In the Ruby community there is a big push to use a testing framework called, <a href="http://cukes.info/" target="_blank">Cucumber</a>. Cucumber is a behavior driven development (BDD) tool that let&#8217;s you write user stories in plain English. Those stories then get translated into Ruby code that tests those stories against your application. Because of it&#8217;s popularity, and some of it&#8217;s quite amazing features, this was my first stop on the path to integration testing bliss.</p>
<p>Let me give you an example of a Cucumber script:</p>
<div id="gist-854764" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="k">Feature:</span><span class="nf"> Registration</span></div><div class='line' id='LC2'><span class="nf">  In order to use My Great Application</span></div><div class='line' id='LC3'><span class="nf">  As a user</span></div><div class='line' id='LC4'><span class="nf">  I want to be able to register</span></div><div class='line' id='LC5'><span class="nf">  </span></div><div class='line' id='LC6'><span class="nf">  </span><span class="k">Scenario:</span><span class="nf"> &#39;Standard Registration&#39;</span></div><div class='line' id='LC7'><span class="k">    Given </span><span class="nf">I am not currently logged in</span></div><div class='line' id='LC8'><span class="nf">    </span><span class="k">When </span><span class="nf">I am on the signup page</span></div><div class='line' id='LC9'><span class="nf">    </span><span class="k">Then </span><span class="nf">I should see &quot;</span><span class="s">Sign Up</span><span class="nf">&quot;</span></div><div class='line' id='LC10'><span class="nf">    </span><span class="k">And </span><span class="nf">I fill in &quot;</span><span class="s">Name (required)</span><span class="nf">&quot; with &quot;</span><span class="s">Mickey Dolenz</span><span class="nf">&quot;</span></div><div class='line' id='LC11'><span class="nf">    </span><span class="k">And </span><span class="nf">I fill in &quot;</span><span class="s">Email (required)</span><span class="nf">&quot; with &quot;</span><span class="s">mickey@monkees.com</span><span class="nf">&quot;</span></div><div class='line' id='LC12'><span class="nf">    </span><span class="k">And </span><span class="nf">I fill in &quot;</span><span class="s">Password (required)</span><span class="nf">&quot; with &quot;</span><span class="s">password</span><span class="nf">&quot;</span></div><div class='line' id='LC13'><span class="nf">    </span><span class="k">And </span><span class="nf">I fill in &quot;</span><span class="s">Password confirmation</span><span class="nf">&quot; with &quot;</span><span class="s">password</span><span class="nf">&quot;</span></div><div class='line' id='LC14'><span class="nf">    </span><span class="k">And </span><span class="nf">I press &quot;</span><span class="s">Register</span><span class="nf">&quot;</span></div><div class='line' id='LC15'><span class="nf">    </span><span class="k">Then </span><span class="nf">I should see &quot;</span><span class="s">Sign Up - Confirm Your Account</span><span class="nf">&quot;</span></div><div class='line' id='LC16'><span class="nf">    </span><span class="k">Then </span><span class="nf">I should be on the registration thank you page</span></div><div class='line' id='LC17'><span class="nf">    </span><span class="k">Then </span><span class="nf">&quot;</span><span class="s">mickey@monkees.com</span><span class="nf">&quot; should receive an email</span></div><div class='line' id='LC18'><span class="nf">    </span><span class="k">When </span><span class="nf">I open the email</span></div><div class='line' id='LC19'><span class="nf">    </span><span class="k">Then </span><span class="nf">I should see &quot;</span><span class="s">Confirm my account</span><span class="nf">&quot; in the email body</span></div><div class='line' id='LC20'><span class="nf">    </span><span class="k">When </span><span class="nf">I follow &quot;</span><span class="s">Confirm my account</span><span class="nf">&quot; in the email</span></div><div class='line' id='LC21'><span class="nf">    </span><span class="k">Then </span><span class="nf">I should be on the welcome page</span></div><div class='line' id='LC22'><span class="nf">    </span><span class="k">And </span><span class="nf">I should see &quot;</span><span class="s">Welcome to the Great Application</span><span class="nf">&quot;</span></div><div class='line' id='LC23'><span class="nf">    </span></div><div class='line' id='LC24'><span class="nf">  </span><span class="k">Scenario:</span><span class="nf"> &#39;Accepting an invitation&#39;</span></div><div class='line' id='LC25'><span class="k">    Given </span><span class="nf">I am not currently logged in</span></div><div class='line' id='LC26'><span class="nf">    </span><span class="k">And </span><span class="nf">the &quot;</span><span class="s">Boys and Girls Club</span><span class="nf">&quot; invites &quot;</span><span class="s">mickey@monkees.com</span><span class="nf">&quot; to join</span></div><div class='line' id='LC27'><span class="nf">    </span><span class="k">Then </span><span class="nf">&quot;</span><span class="s">mickey@monkees.com</span><span class="nf">&quot; should receive an email</span></div><div class='line' id='LC28'><span class="nf">    </span><span class="k">When </span><span class="nf">I open the email</span></div><div class='line' id='LC29'><span class="nf">    </span><span class="k">Then </span><span class="nf">I should see &quot;</span><span class="s">Accept Invitation</span><span class="nf">&quot; in the email body</span></div><div class='line' id='LC30'><span class="nf">    </span><span class="k">When </span><span class="nf">I follow &quot;</span><span class="s">Accept Invitation</span><span class="nf">&quot; in the email</span></div><div class='line' id='LC31'><span class="nf">    </span><span class="k">Then </span><span class="nf">I should be on the signup page</span></div><div class='line' id='LC32'><span class="nf">    </span><span class="k">Then </span><span class="nf">I should see &quot;</span><span class="s">Sign Up</span><span class="nf">&quot;</span></div><div class='line' id='LC33'><span class="nf">    </span><span class="k">And </span><span class="nf">I fill in &quot;</span><span class="s">Name (required)</span><span class="nf">&quot; with &quot;</span><span class="s">Mickey Dolenz</span><span class="nf">&quot;</span></div><div class='line' id='LC34'><span class="nf">    </span><span class="k">And </span><span class="nf">the &quot;</span><span class="s">Email (required)</span><span class="nf">&quot; field should contain &quot;</span><span class="s">mickey@monkees.com</span><span class="nf">&quot;</span></div><div class='line' id='LC35'><span class="nf">    </span><span class="k">And </span><span class="nf">I fill in &quot;</span><span class="s">Password (required)</span><span class="nf">&quot; with &quot;</span><span class="s">password</span><span class="nf">&quot;</span></div><div class='line' id='LC36'><span class="nf">    </span><span class="k">And </span><span class="nf">I fill in &quot;</span><span class="s">Password confirmation</span><span class="nf">&quot; with &quot;</span><span class="s">password</span><span class="nf">&quot;</span></div><div class='line' id='LC37'><span class="nf">    </span><span class="k">And </span><span class="nf">I press &quot;</span><span class="s">Register</span><span class="nf">&quot;</span></div><div class='line' id='LC38'><span class="nf">    </span><span class="k">Then </span><span class="nf">the account &quot;</span><span class="s">mickey@monkees.com</span><span class="nf">&quot; should be &quot;</span><span class="s">activated</span><span class="nf">&quot;</span></div><div class='line' id='LC39'><span class="nf">    </span><span class="k">Then </span><span class="nf">I should be on the accept/decline invitation page</span></div><div class='line' id='LC40'><span class="nf">    </span><span class="k">And </span><span class="nf">I should see &quot;</span><span class="s">Join the Boys and Girls Club</span><span class="nf">&quot;</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/854764/81be0e41bf076636677685e985192e211aa693e0/registration.feature" style="float:right;">view raw</a>
            <a href="https://gist.github.com/854764#file_registration.feature" style="float:right;margin-right:10px;color:#666">registration.feature</a>
            <a href="https://gist.github.com/854764">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>That script tests the user registration flow through an application in a couple of different ways, first through &#8216;standard&#8217; registration, and then through being invited to join. Now, the beauty of Cucumber is that these scripts are &#8216;human&#8217; readable. Your product manager, or other stake holders, should be able to write these scripts themselves, and you, the developer, should be able to just plug them in and code until those scripts pass.</p>
<p>Unfortunately, while that sounds like a little slice of Heaven, the reality is far from it in practice. First, getting stake holders to actually write these &#8216;stories&#8217;, as their typically called, is a tough chore to begin with. If they do write them, they&#8217;re typically not going to be &#8216;plug and play&#8217;. Why? Well, when Cucumber reads these scripts it goes line by line and tries to find some code that matches the regular expression of that line and then execute it. If it doesn&#8217;t find matching code, then it fails. That means that your stake holders need to write these scripts in a very particular way or developers need to sit down and massage those stories to fit the correct regular expression.</p>
<p>Now, let me just take this opportunity to say that this is not a post about how much I hate Cucumber, in fact I think Cucumber is a pretty amazing piece of software, and does in fact have a lot of great uses. Instead, what I&#8217;m talking about it is how Cucumber turned out not to be the right tool for the job for me on a recent project.</p>
<p>So why wasn&#8217;t Cucumber the right tool for the job? Great question, glad you asked. Cucumber turned out not to be the right tool for a few reasons. The biggest of which was that I was the one who was writing the user stories. The stake holders had no desire to write these stories, which meant I had to write them. The I had to write the &#8216;steps&#8217; that back each line of the script. In all fairness, Cucumber does give you some great steps right out of the box. After some fiddling I finally got the Cucumber scripts up and running and testing my work flow. But I definitely ran into some issues.</p>
<p>Because Cucumber isn&#8217;t pure Ruby I had a hard time doing something as simple as just printing out the request&#8217;s body and headers without having to write a step that did just that, then add that step to my story, etc&#8230; It&#8217;s overall fiddlyness and non-intuitive way of doing things caused me a lot of grief and time. And, most importantly, I wasn&#8217;t really getting the big benefit of Cucumber, stake holder&#8217;s writing the stories. So I was doing all this work and not getting the benefits of Cucumber.</p>
<p>So what did I do? I turned to a library called <a href="https://github.com/cavalle/steak" target="_blank">Steak</a>. Steak allows you to write integration tests using pure Ruby and integrates directly in with <a href="http://relishapp.com/rspec" target="_blank">RSpec</a>, my preferred testing framework. With Steak I was able to write my integration tests in just a few minutes.</p>
<div id="gist-854844" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="nb">require</span> <span class="no">File</span><span class="o">.</span><span class="n">expand_path</span><span class="p">(</span><span class="no">File</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="bp">__FILE__</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;/acceptance_helper&#39;</span><span class="p">)</span></div><div class='line' id='LC2'><br/></div><div class='line' id='LC3'><span class="n">feature</span> <span class="s2">&quot;Registration Steak&quot;</span><span class="p">,</span> <span class="sx">%q{</span></div><div class='line' id='LC4'><span class="sx">  In order to use My Great Application</span></div><div class='line' id='LC5'><span class="sx">  As a user</span></div><div class='line' id='LC6'><span class="sx">  I want to be able to register</span></div><div class='line' id='LC7'><span class="sx">}</span> <span class="k">do</span></div><div class='line' id='LC8'><br/></div><div class='line' id='LC9'>&nbsp;&nbsp;<span class="n">scenario</span> <span class="s2">&quot;register throught the standard registration process&quot;</span> <span class="k">do</span></div><div class='line' id='LC10'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">visit</span> <span class="n">signup_path</span></div><div class='line' id='LC11'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC12'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">expect</span> <span class="p">{</span></div><div class='line' id='LC13'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">fill_in_registration</span><span class="p">(</span><span class="ss">:name</span> <span class="o">=&gt;</span> <span class="s1">&#39;Mickey Dolenz&#39;</span><span class="p">,</span> <span class="ss">:email</span> <span class="o">=&gt;</span> <span class="s1">&#39;mickey@monkees.com&#39;</span><span class="p">)</span></div><div class='line' id='LC14'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span><span class="o">.</span><span class="n">to</span> <span class="n">change</span><span class="p">(</span><span class="n">delivered_emails</span><span class="p">,</span> <span class="ss">:size</span><span class="p">)</span><span class="o">.</span><span class="n">by</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span></div><div class='line' id='LC15'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC16'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">user</span> <span class="o">=</span> <span class="no">User</span><span class="o">.</span><span class="n">find_by_email</span><span class="p">(</span><span class="s1">&#39;mickey@monkees.com&#39;</span><span class="p">)</span></div><div class='line' id='LC17'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">user</span><span class="o">.</span><span class="n">should</span> <span class="n">be_unverified</span></div><div class='line' id='LC18'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC19'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">page</span><span class="o">.</span><span class="n">should</span> <span class="n">have_content</span><span class="p">(</span><span class="s1">&#39;You have signed up successfully. However, we could not sign you in because your account is unconfirmed.&#39;</span><span class="p">)</span></div><div class='line' id='LC20'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">current_path</span><span class="o">.</span><span class="n">should</span> <span class="o">==</span> <span class="n">root_path</span></div><div class='line' id='LC21'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC22'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">visit</span> <span class="n">signin_path</span></div><div class='line' id='LC23'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">fill_in</span> <span class="s1">&#39;user_email&#39;</span><span class="p">,</span> <span class="ss">:with</span> <span class="o">=&gt;</span> <span class="s1">&#39;mickey@monkees.com&#39;</span></div><div class='line' id='LC24'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">fill_in</span> <span class="s1">&#39;user_password&#39;</span><span class="p">,</span> <span class="ss">:with</span> <span class="o">=&gt;</span> <span class="s1">&#39;password&#39;</span></div><div class='line' id='LC25'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">click_button</span> <span class="s1">&#39;Sign In&#39;</span></div><div class='line' id='LC26'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC27'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">page</span><span class="o">.</span><span class="n">should</span> <span class="n">have_content</span><span class="p">(</span><span class="s1">&#39;You have to confirm your account before continuing.&#39;</span><span class="p">)</span></div><div class='line' id='LC28'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">current_path</span><span class="o">.</span><span class="n">should</span> <span class="o">==</span> <span class="n">new_user_session_path</span></div><div class='line' id='LC29'><br/></div><div class='line' id='LC30'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">click_email_link_matching</span><span class="p">(</span><span class="sr">/users\/confirmation/</span><span class="p">,</span> <span class="n">delivered_emails</span><span class="o">.</span><span class="n">first</span><span class="p">)</span></div><div class='line' id='LC31'><br/></div><div class='line' id='LC32'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">current_path</span><span class="o">.</span><span class="n">should</span> <span class="o">==</span> <span class="n">welcome_users_path</span></div><div class='line' id='LC33'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">page</span><span class="o">.</span><span class="n">should</span> <span class="n">have_content</span><span class="p">(</span><span class="s1">&#39;Welcome to the Great Application&#39;</span><span class="p">)</span></div><div class='line' id='LC34'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">user</span><span class="o">.</span><span class="n">reload</span></div><div class='line' id='LC35'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">user</span><span class="o">.</span><span class="n">should</span> <span class="n">be_activated</span></div><div class='line' id='LC36'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC37'>&nbsp;&nbsp;</div><div class='line' id='LC38'>&nbsp;&nbsp;<span class="n">scenario</span> <span class="s2">&quot;register from an invitation&quot;</span> <span class="k">do</span></div><div class='line' id='LC39'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">mark</span> <span class="o">=</span> <span class="n">users</span><span class="p">(</span><span class="ss">:mark</span><span class="p">)</span></div><div class='line' id='LC40'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">organization</span> <span class="o">=</span> <span class="n">mark</span><span class="o">.</span><span class="n">organizations</span><span class="o">.</span><span class="n">first</span></div><div class='line' id='LC41'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">signin</span><span class="p">(</span><span class="n">mark</span><span class="p">)</span></div><div class='line' id='LC42'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC43'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">visit</span> <span class="n">new_organization_invitation_path</span><span class="p">(</span><span class="n">organization</span><span class="p">)</span></div><div class='line' id='LC44'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">expect</span> <span class="p">{</span></div><div class='line' id='LC45'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">expect</span> <span class="p">{</span></div><div class='line' id='LC46'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">fill_in</span> <span class="s1">&#39;organization_invitation_worker_emails&#39;</span><span class="p">,</span> <span class="ss">:with</span> <span class="o">=&gt;</span> <span class="s1">&#39;mickey@monkees.com&#39;</span></div><div class='line' id='LC47'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">click_button</span> <span class="s1">&#39;Send Invites&#39;</span></div><div class='line' id='LC48'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="no">DJ</span><span class="o">.</span><span class="n">first</span><span class="o">.</span><span class="n">invoke_job</span></div><div class='line' id='LC49'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span><span class="o">.</span><span class="n">to</span> <span class="n">change</span><span class="p">(</span><span class="n">delivered_emails</span><span class="p">,</span> <span class="ss">:size</span><span class="p">)</span><span class="o">.</span><span class="n">by</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span></div><div class='line' id='LC50'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span><span class="o">.</span><span class="n">to</span> <span class="n">change</span><span class="p">(</span><span class="n">organization</span><span class="o">.</span><span class="n">invitations</span><span class="p">,</span> <span class="ss">:count</span><span class="p">)</span><span class="o">.</span><span class="n">by</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span></div><div class='line' id='LC51'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC52'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">invitation</span> <span class="o">=</span> <span class="n">organization</span><span class="o">.</span><span class="n">invitations</span><span class="o">.</span><span class="n">first</span></div><div class='line' id='LC53'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC54'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">signout</span></div><div class='line' id='LC55'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC56'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">click_first_link_in_email</span><span class="p">(</span><span class="n">delivered_emails</span><span class="o">.</span><span class="n">first</span><span class="p">)</span></div><div class='line' id='LC57'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC58'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">current_path</span><span class="o">.</span><span class="n">should</span> <span class="o">==</span> <span class="n">signup_path</span></div><div class='line' id='LC59'><br/></div><div class='line' id='LC60'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">fill_in_registration</span><span class="p">(</span><span class="ss">:name</span> <span class="o">=&gt;</span> <span class="s1">&#39;Mickey Dolenz&#39;</span><span class="p">)</span></div><div class='line' id='LC61'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC62'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">current_path</span><span class="o">.</span><span class="n">should</span> <span class="o">==</span> <span class="n">organization_invitation_path</span><span class="p">(</span><span class="n">organization</span><span class="p">,</span> <span class="n">invitation</span><span class="p">)</span></div><div class='line' id='LC63'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC64'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">user</span> <span class="o">=</span> <span class="no">User</span><span class="o">.</span><span class="n">find_by_email</span><span class="p">(</span><span class="s1">&#39;mickey@monkees.com&#39;</span><span class="p">)</span></div><div class='line' id='LC65'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">user</span><span class="o">.</span><span class="n">should</span> <span class="n">be_activated</span></div><div class='line' id='LC66'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC67'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">expect</span> <span class="p">{</span></div><div class='line' id='LC68'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">click_on</span> <span class="s1">&#39;Get Started Now!&#39;</span></div><div class='line' id='LC69'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span><span class="o">.</span><span class="n">to</span> <span class="n">change</span><span class="p">(</span><span class="n">user</span><span class="o">.</span><span class="n">organizations</span><span class="p">,</span> <span class="ss">:count</span><span class="p">)</span><span class="o">.</span><span class="n">by</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span></div><div class='line' id='LC70'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC71'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">current_path</span><span class="o">.</span><span class="n">should</span> <span class="o">==</span> <span class="n">organization_campaign_path</span><span class="p">(</span><span class="n">organization</span><span class="p">,</span> <span class="n">organization</span><span class="o">.</span><span class="n">campaigns</span><span class="o">.</span><span class="n">first</span><span class="p">)</span></div><div class='line' id='LC72'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC73'>&nbsp;&nbsp;</div><div class='line' id='LC74'><span class="k">end</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/854844/45d1d080b1d1a19954d6894e08e2261b1b368166/registration_spec.rb" style="float:right;">view raw</a>
            <a href="https://gist.github.com/854844#file_registration_spec.rb" style="float:right;margin-right:10px;color:#666">registration_spec.rb</a>
            <a href="https://gist.github.com/854844">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>While my Steak scripts a bit more wordy and are definitely not &#8216;human&#8217; readable and editable by stakeholders, they did achieve my goal of allowing me to write integration tests quickly.</p>
<p>So here you see I picked a very powerful tool, that has a lot of great benefits, Cucumber, but I picked it for the wrong reasons. I picked it because it was popular, and not because it would help me achieve my goals. If my goals where to have stakeholders write the stories and hand them off to development, than it would&#8217;ve been a better choice. But in the end my goal was to write integration tests and write them quickly, which is why Steak ended up being the right tool for that job.</p>
<p>This has all been a really long winded way of saying doing some research before choosing your testing frameworks, or any framework for that matter. Play with it, research it, make sure it meets your goals, not somebody else&#8217;s. If you choose the right tools then testing doesn&#8217;t need to be scary, complicated, frustrating, etc&#8230; Testing is a <a href="http://www.metabates.com/2010/07/01/testing-is-not-an-option/">requirement</a> and a must have, so why not make it fun?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.metabates.com/2011/03/04/407-testing-tools-arent-all-the-same-choose-wisely/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Building Interfaces and Abstract Classes in Ruby</title>
		<link>http://www.metabates.com/2011/02/07/building-interfaces-and-abstract-classes-in-ruby/</link>
		<comments>http://www.metabates.com/2011/02/07/building-interfaces-and-abstract-classes-in-ruby/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 20:45:05 +0000</pubDate>
		<dc:creator>Mark Bates</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.metabates.com/?p=393</guid>
		<description><![CDATA[So back in the dark ages of my career, pre-2006, I spent a long time coding Java. Yeah, I know, please don&#8217;t judge. Anyway, In Java, for those of you who are unaware were two constructs that I occasionally wish I had in Ruby, those are Interfaces and Abstract Classes. The difference between these two [...]]]></description>
			<content:encoded><![CDATA[<p>So back in the dark ages of my career, pre-2006, I spent a long time coding Java. Yeah, I know, please don&#8217;t judge. Anyway, In Java, for those of you who are unaware were two constructs that I occasionally wish I had in Ruby, those are <a href="http://download.oracle.com/javase/tutorial/java/concepts/interface.html" target="_blank">Interfaces</a> and <a href="http://download.oracle.com/javase/tutorial/java/IandI/abstract.html" target="_blank">Abstract Classes</a>. The difference between these two constructs is subtle, but important.</p>
<p>In Java an Interface is a basically a blueprint of methods that the class who implements the Interface needs to implement. For example:</p>
<div id="gist-814920" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="kd">interface</span> <span class="nc">Bicycle</span> <span class="o">{</span></div><div class='line' id='LC2'><br/></div><div class='line' id='LC3'>&nbsp;&nbsp;<span class="kt">void</span> <span class="nf">changeGear</span><span class="o">(</span><span class="kt">int</span> <span class="n">newValue</span><span class="o">);</span></div><div class='line' id='LC4'><br/></div><div class='line' id='LC5'>&nbsp;&nbsp;<span class="kt">void</span> <span class="nf">speedUp</span><span class="o">(</span><span class="kt">int</span> <span class="n">increment</span><span class="o">);</span></div><div class='line' id='LC6'><br/></div><div class='line' id='LC7'>&nbsp;&nbsp;<span class="kt">void</span> <span class="nf">applyBrakes</span><span class="o">(</span><span class="kt">int</span> <span class="n">decrement</span><span class="o">);</span></div><div class='line' id='LC8'><span class="o">}</span></div><div class='line' id='LC9'><br/></div><div class='line' id='LC10'><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ACMEBicycle</span> <span class="kd">implements</span> <span class="n">Bicycle</span> <span class="o">{</span></div><div class='line' id='LC11'>&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC12'>&nbsp;&nbsp;&nbsp;<span class="kd">public</span> <span class="kt">void</span> <span class="nf">changeGear</span><span class="o">(</span><span class="kt">int</span> <span class="n">newValue</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC13'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// do some work here</span></div><div class='line' id='LC14'>&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC15'>&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC16'>&nbsp;&nbsp;&nbsp;<span class="kd">public</span> <span class="kt">void</span> <span class="nf">speedUp</span><span class="o">(</span><span class="kt">int</span> <span class="n">increment</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC17'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// do some work here</span></div><div class='line' id='LC18'>&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC19'>&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC20'>&nbsp;&nbsp;&nbsp;<span class="kd">public</span> <span class="kt">void</span> <span class="nf">applyBrakes</span><span class="o">(</span><span class="kt">int</span> <span class="n">decrement</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC21'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// do some work here</span></div><div class='line' id='LC22'>&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC23'><br/></div><div class='line' id='LC24'><span class="o">}</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/814920/33db62faa407878926d6c84e03759ad77923053a/gistfile1.java" style="float:right;">view raw</a>
            <a href="https://gist.github.com/814920#file_gistfile1.java" style="float:right;margin-right:10px;color:#666">gistfile1.java</a>
            <a href="https://gist.github.com/814920">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>Here we have a <code>Bicycle</code> Interface that says there are three methods that need to be implemented. It is then the responsibility of the <code>ACMEBicycle</code> class to implement those methods. Now, an Abstract Class in Java is similar to an Interface in that it too is a blueprint of methods that the extending class may or may not need to implement. There in lies one of the differences between the two. Let&#8217;s take a look at the same example, but this time we want to implement the same behavior of all of our extending classes for the <code>applyBrakes</code> method:</p>
<div id="gist-814926" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="kd">abstract</span> <span class="kd">class</span> <span class="nc">Bicycle</span> <span class="o">{</span></div><div class='line' id='LC2'>&nbsp;&nbsp;</div><div class='line' id='LC3'>&nbsp;&nbsp;<span class="kd">abstract</span> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">changeGear</span><span class="o">(</span><span class="kt">int</span> <span class="n">newValue</span><span class="o">);</span></div><div class='line' id='LC4'><br/></div><div class='line' id='LC5'>&nbsp;&nbsp;<span class="kd">abstract</span> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">speedUp</span><span class="o">(</span><span class="kt">int</span> <span class="n">increment</span><span class="o">);</span></div><div class='line' id='LC6'><br/></div><div class='line' id='LC7'>&nbsp;&nbsp;<span class="kd">public</span> <span class="kt">void</span> <span class="nf">applyBrakes</span><span class="o">(</span><span class="kt">int</span> <span class="n">decrement</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC8'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// do some work here</span></div><div class='line' id='LC9'>&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC10'>&nbsp;&nbsp;</div><div class='line' id='LC11'><span class="o">}</span></div><div class='line' id='LC12'><br/></div><div class='line' id='LC13'><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ACMEBicycle</span> <span class="kd">extends</span> <span class="n">Bicycle</span> <span class="o">{</span></div><div class='line' id='LC14'>&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC15'>&nbsp;&nbsp;&nbsp;<span class="kd">public</span> <span class="kt">void</span> <span class="nf">applyBrakes</span><span class="o">(</span><span class="kt">int</span> <span class="n">decrement</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC16'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// do some work here</span></div><div class='line' id='LC17'>&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC18'><br/></div><div class='line' id='LC19'><span class="o">}</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/814926/378f523b40a1dc33ae616ee6ffc58e3b32cc5b23/gistfile1.java" style="float:right;">view raw</a>
            <a href="https://gist.github.com/814926#file_gistfile1.java" style="float:right;margin-right:10px;color:#666">gistfile1.java</a>
            <a href="https://gist.github.com/814926">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>An Abstract Class is a great way to provide a mix of fully implemented methods as well as providing subclasses with a mixture of methods that need to be implemented by the extending class.</p>
<p>The really powerful part of all of this is two fold. First, the Java compiler will happily yell at you and fail if it finds that you haven&#8217;t implemented some of the methods that you were told you had to. Second, you can easily see the methods that you need to document right there, you can even copy/paste their definitions right into your class so you can start to fill them out.</p>
<p>So, how does this bring us over to Ruby? Great question. I&#8217;d like to take a few moments and explore a few ways we can get some of this power in Ruby.</p>
<p>Unfortunately, or fortunately depending on how you look at it (I see it as a mixed blessing), there is no compiler in Ruby, so we don&#8217;t really have a good way of having the system yell at us if we don&#8217;t implement the methods we were supposed to. But, there is still plenty we can do to help those who are implementing our classes both know what they need to implement and to find out what they haven&#8217;t implemented when their program is executing.</p>
<p>Here is one implementation on we can gain a bit of that functionality back in Ruby:</p>
<div id="gist-815110" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="k">module</span> <span class="nn">AbstractInterface</span></div><div class='line' id='LC2'>&nbsp;&nbsp;</div><div class='line' id='LC3'>&nbsp;&nbsp;<span class="k">class</span> <span class="nc">InterfaceNotImplementedError</span> <span class="o">&lt;</span> <span class="no">NoMethodError</span></div><div class='line' id='LC4'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC5'>&nbsp;&nbsp;</div><div class='line' id='LC6'>&nbsp;&nbsp;<span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">included</span><span class="p">(</span><span class="n">klass</span><span class="p">)</span></div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">klass</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="ss">:include</span><span class="p">,</span> <span class="no">AbstractInterface</span><span class="o">::</span><span class="no">Methods</span><span class="p">)</span></div><div class='line' id='LC8'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">klass</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="ss">:extend</span><span class="p">,</span> <span class="no">AbstractInterface</span><span class="o">::</span><span class="no">Methods</span><span class="p">)</span></div><div class='line' id='LC9'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC10'>&nbsp;&nbsp;</div><div class='line' id='LC11'>&nbsp;&nbsp;<span class="k">module</span> <span class="nn">Methods</span></div><div class='line' id='LC12'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC13'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">def</span> <span class="nf">api_not_implemented</span><span class="p">(</span><span class="n">klass</span><span class="p">)</span></div><div class='line' id='LC14'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nb">caller</span><span class="o">.</span><span class="n">first</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="sr">/in \`(.+)\&#39;/</span><span class="p">)</span></div><div class='line' id='LC15'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">method_name</span> <span class="o">=</span> <span class="vg">$1</span></div><div class='line' id='LC16'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">raise</span> <span class="no">AbstractInterface</span><span class="o">::</span><span class="no">InterfaceNotImplementedError</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">#{</span><span class="n">klass</span><span class="o">.</span><span class="n">class</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> needs to implement &#39;</span><span class="si">#{</span><span class="n">method_name</span><span class="si">}</span><span class="s2">&#39; for interface </span><span class="si">#{</span><span class="nb">self</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">!&quot;</span><span class="p">)</span></div><div class='line' id='LC17'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC18'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC19'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC20'>&nbsp;&nbsp;</div><div class='line' id='LC21'><span class="k">end</span></div><div class='line' id='LC22'><br/></div><div class='line' id='LC23'><span class="k">class</span> <span class="nc">Bicycle</span></div><div class='line' id='LC24'>&nbsp;&nbsp;<span class="kp">include</span> <span class="no">AbstractInterface</span></div><div class='line' id='LC25'>&nbsp;&nbsp;</div><div class='line' id='LC26'>&nbsp;&nbsp;<span class="c1"># Some documentation on the change_gear method</span></div><div class='line' id='LC27'>&nbsp;&nbsp;<span class="k">def</span> <span class="nf">change_gear</span><span class="p">(</span><span class="n">new_value</span><span class="p">)</span></div><div class='line' id='LC28'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="no">Bicycle</span><span class="o">.</span><span class="n">api_not_implemented</span><span class="p">(</span><span class="nb">self</span><span class="p">)</span></div><div class='line' id='LC29'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC30'>&nbsp;&nbsp;</div><div class='line' id='LC31'>&nbsp;&nbsp;<span class="c1"># Some documentation on the speed_up method</span></div><div class='line' id='LC32'>&nbsp;&nbsp;<span class="k">def</span> <span class="nf">speed_up</span><span class="p">(</span><span class="n">increment</span><span class="p">)</span></div><div class='line' id='LC33'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="no">Bicycle</span><span class="o">.</span><span class="n">api_not_implemented</span><span class="p">(</span><span class="nb">self</span><span class="p">)</span></div><div class='line' id='LC34'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC35'>&nbsp;&nbsp;</div><div class='line' id='LC36'>&nbsp;&nbsp;<span class="c1"># Some documentation on the apply_brakes method</span></div><div class='line' id='LC37'>&nbsp;&nbsp;<span class="k">def</span> <span class="nf">apply_brakes</span><span class="p">(</span><span class="n">decrement</span><span class="p">)</span></div><div class='line' id='LC38'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1"># do some work here</span></div><div class='line' id='LC39'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC40'>&nbsp;&nbsp;</div><div class='line' id='LC41'><span class="k">end</span></div><div class='line' id='LC42'><br/></div><div class='line' id='LC43'><span class="k">class</span> <span class="nc">AcmeBicycle</span> <span class="o">&lt;</span> <span class="no">Bicycle</span></div><div class='line' id='LC44'><span class="k">end</span></div><div class='line' id='LC45'><br/></div><div class='line' id='LC46'><span class="n">bike</span> <span class="o">=</span> <span class="no">AcmeBicycle</span><span class="o">.</span><span class="n">new</span></div><div class='line' id='LC47'><span class="n">bike</span><span class="o">.</span><span class="n">change_gear</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="c1"># AbstractInterface::InterfaceNotImplementedError: AcmeBicycle needs to implement &#39;change_gear&#39; for interface Bicycle!</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/815110/86499cb60e04a53989d06d3763c44ff3d9a99984/gistfile1.rb" style="float:right;">view raw</a>
            <a href="https://gist.github.com/815110#file_gistfile1.rb" style="float:right;margin-right:10px;color:#666">gistfile1.rb</a>
            <a href="https://gist.github.com/815110">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>What we&#8217;ve done here is to inject a Module into our <code>Bicycle</code> class to give it a nice error it can raise and a little bit of help building a nice error message for the user. Then in our <code>Bicycle</code> class we define all the methods we want and in the ones we need the end user to define we can call the <code>api_not_implemented</code> method and it will raise the <code>AbstractInterface::InterfaceNotImplementedError</code> error for us.</p>
<p>We could simplify this a bit by having a nice little helper macro that we can use to build these methods, like this:</p>
<div id="gist-815133" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="k">module</span> <span class="nn">AbstractInterface</span></div><div class='line' id='LC2'>&nbsp;&nbsp;</div><div class='line' id='LC3'>&nbsp;&nbsp;<span class="k">class</span> <span class="nc">InterfaceNotImplementedError</span> <span class="o">&lt;</span> <span class="no">NoMethodError</span></div><div class='line' id='LC4'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC5'>&nbsp;&nbsp;</div><div class='line' id='LC6'>&nbsp;&nbsp;<span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">included</span><span class="p">(</span><span class="n">klass</span><span class="p">)</span></div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">klass</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="ss">:include</span><span class="p">,</span> <span class="no">AbstractInterface</span><span class="o">::</span><span class="no">Methods</span><span class="p">)</span></div><div class='line' id='LC8'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">klass</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="ss">:extend</span><span class="p">,</span> <span class="no">AbstractInterface</span><span class="o">::</span><span class="no">Methods</span><span class="p">)</span></div><div class='line' id='LC9'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">klass</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="ss">:extend</span><span class="p">,</span> <span class="no">AbstractInterface</span><span class="o">::</span><span class="no">ClassMethods</span><span class="p">)</span></div><div class='line' id='LC10'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC11'>&nbsp;&nbsp;</div><div class='line' id='LC12'>&nbsp;&nbsp;<span class="k">module</span> <span class="nn">Methods</span></div><div class='line' id='LC13'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC14'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">def</span> <span class="nf">api_not_implemented</span><span class="p">(</span><span class="n">klass</span><span class="p">,</span> <span class="n">method_name</span> <span class="o">=</span> <span class="kp">nil</span><span class="p">)</span></div><div class='line' id='LC15'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="n">method_name</span><span class="o">.</span><span class="n">nil?</span></div><div class='line' id='LC16'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nb">caller</span><span class="o">.</span><span class="n">first</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="sr">/in \`(.+)\&#39;/</span><span class="p">)</span></div><div class='line' id='LC17'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">method_name</span> <span class="o">=</span> <span class="vg">$1</span></div><div class='line' id='LC18'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC19'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">raise</span> <span class="no">AbstractInterface</span><span class="o">::</span><span class="no">InterfaceNotImplementedError</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">#{</span><span class="n">klass</span><span class="o">.</span><span class="n">class</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> needs to implement &#39;</span><span class="si">#{</span><span class="n">method_name</span><span class="si">}</span><span class="s2">&#39; for interface </span><span class="si">#{</span><span class="nb">self</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">!&quot;</span><span class="p">)</span></div><div class='line' id='LC20'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC21'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC22'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC23'>&nbsp;&nbsp;</div><div class='line' id='LC24'>&nbsp;&nbsp;<span class="k">module</span> <span class="nn">ClassMethods</span></div><div class='line' id='LC25'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC26'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">def</span> <span class="nf">needs_implementation</span><span class="p">(</span><span class="nb">name</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span></div><div class='line' id='LC27'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nb">self</span><span class="o">.</span><span class="n">class_eval</span> <span class="k">do</span></div><div class='line' id='LC28'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">define_method</span><span class="p">(</span><span class="nb">name</span><span class="p">)</span> <span class="k">do</span> <span class="o">|*</span><span class="n">args</span><span class="o">|</span></div><div class='line' id='LC29'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="no">Bicycle</span><span class="o">.</span><span class="n">api_not_implemented</span><span class="p">(</span><span class="nb">self</span><span class="p">,</span> <span class="nb">name</span><span class="p">)</span></div><div class='line' id='LC30'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC31'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC32'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC33'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC34'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC35'>&nbsp;&nbsp;</div><div class='line' id='LC36'><span class="k">end</span></div><div class='line' id='LC37'><br/></div><div class='line' id='LC38'><span class="k">class</span> <span class="nc">Bicycle</span></div><div class='line' id='LC39'>&nbsp;&nbsp;<span class="kp">include</span> <span class="no">AbstractInterface</span></div><div class='line' id='LC40'>&nbsp;&nbsp;</div><div class='line' id='LC41'>&nbsp;&nbsp;<span class="n">needs_implementation</span> <span class="ss">:change_gear</span><span class="p">,</span> <span class="ss">:new_value</span></div><div class='line' id='LC42'>&nbsp;&nbsp;<span class="n">needs_implementation</span> <span class="ss">:speed_up</span><span class="p">,</span> <span class="ss">:increment</span></div><div class='line' id='LC43'>&nbsp;&nbsp;</div><div class='line' id='LC44'>&nbsp;&nbsp;<span class="c1"># Some documentation on the apply_brakes method</span></div><div class='line' id='LC45'>&nbsp;&nbsp;<span class="k">def</span> <span class="nf">apply_brakes</span><span class="p">(</span><span class="n">decrement</span><span class="p">)</span></div><div class='line' id='LC46'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1"># do some work here</span></div><div class='line' id='LC47'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC48'>&nbsp;&nbsp;</div><div class='line' id='LC49'><span class="k">end</span></div><div class='line' id='LC50'><br/></div><div class='line' id='LC51'><span class="k">class</span> <span class="nc">AcmeBicycle</span> <span class="o">&lt;</span> <span class="no">Bicycle</span></div><div class='line' id='LC52'><span class="k">end</span></div><div class='line' id='LC53'><br/></div><div class='line' id='LC54'><span class="n">bike</span> <span class="o">=</span> <span class="no">AcmeBicycle</span><span class="o">.</span><span class="n">new</span></div><div class='line' id='LC55'><span class="n">bike</span><span class="o">.</span><span class="n">change_gear</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="c1"># AbstractInterface::InterfaceNotImplementedError: AcmeBicycle needs to implement &#39;change_gear&#39; for interface Bicycle!</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/815133/aacc6defab9cfa8801a042ab386daf27685e3981/gistfile1.rb" style="float:right;">view raw</a>
            <a href="https://gist.github.com/815133#file_gistfile1.rb" style="float:right;margin-right:10px;color:#666">gistfile1.rb</a>
            <a href="https://gist.github.com/815133">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>That approach certainly makes our code look a bit cleaner, I&#8217;m not denying that, however it has one really big flaw, at least for me anyway, it doesn&#8217;t give us a good to place to hang our documentation hat. In the previous approach we had actual methods that we could then document and that documentation would then show up in RDoc when it&#8217;s outputted. With the latter approach, however, we can document the hell out of the <code>needs_implementation</code> calls we have in the <code>Bicycle</code> class, but they won&#8217;t ever show up in the documentation. That means that users of our library have to crack open the actual code itself to see what it they are expected to implement.</p>
<p>Another approach we could&#8217;ve taken, which I bother to demonstrate here as I don&#8217;t think it offers a better approach is to have the <code>needs_implementation</code> method collect up the names of those methods and use <code>method_missing</code> to report that the method needs to be implemented. I mention it here only for completeness, but it definitely is not the best solution to this problem.</p>
<p>Finally, I would like to note that, as far as I can see, there is no way in Ruby to create a callback hook for when a class has been defined. If there was in fact such a hook we could use to it immediately notify the end user that they have forgotten to implement certain methods. Perhaps in Ruby 2.0??? That&#8217;s just pure hope on my part.</p>
<p>That&#8217;s it. I hope you enjoyed our brief (*cough*) look through implementing Interface and Abstract Classes in Ruby. I hope you&#8217;ve enjoyed it.</p>
<p>* PS, yes, I&#8217;m aware I didn&#8217;t talk about multiple vs. single inheritance in either Java or Ruby, nor did I talk about the fact that in Ruby you can&#8217;t really have Abstract Classes. I thought that was all a bit much for an already rather lengthy post as it was. Perhaps another day. <img src='http://www.metabates.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.metabates.com/2011/02/07/building-interfaces-and-abstract-classes-in-ruby/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 4.403 seconds -->

