<?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>ObjectThought</title>
	<atom:link href="http://objectthought.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://objectthought.com/blog</link>
	<description>a thousand-yard stare at software development and, well, life</description>
	<lastBuildDate>Wed, 22 Sep 2010 15:46:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>OFX for Ruby</title>
		<link>http://objectthought.com/blog/2007/07/16/ofx-for-ruby/</link>
		<comments>http://objectthought.com/blog/2007/07/16/ofx-for-ruby/#comments</comments>
		<pubDate>Mon, 16 Jul 2007 02:14:46 +0000</pubDate>
		<dc:creator>Chris Guidry</dc:creator>
				<category><![CDATA[OFX]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://objectthought.com/blog/2007/07/16/ofx-for-ruby/</guid>
		<description><![CDATA[Okay, it&#8217;s official. I&#8217;ve put my money where my loud mouth is; my first open-source project. I know what you&#8217;re thinking: so? Well, for me, this is an important step. I&#8217;m a leecher. I&#8217;ve been a leecher since I was Icarus on Capricious Alliance (I tried to find any reference to this Baton Rouge-based BBS [...]]]></description>
			<content:encoded><![CDATA[<p>
Okay, it&#8217;s official.  I&#8217;ve put my money where my loud mouth is; my first <a href="http://rubyforge.org/projects/ofx/">open-source project</a>.  I know what you&#8217;re thinking: so?
</p>
<p>
Well, for me, this is an important step.  I&#8217;m a leecher.  I&#8217;ve been a leecher since I was Icarus on Capricious Alliance (I tried to find any reference to this Baton Rouge-based BBS system for href-ing purposes, but alas).  Open-source challenges me to stop leeching, to give something back, to do more than lurk and hide.
</p>
<p>
I&#8217;ve been working on a home management system in Ruby for some time now.  It&#8217;s my classic side-project/magnum opus, a toy in Ruby and Rails that&#8217;s growing into something that might be worth it.  It&#8217;s far too early to tell, and definitely too early to release anything, or even put the code up for public perusal/contribution.  It&#8217;s not that I&#8217;m unsure about my intentions; this project/system will definitely be open-sourced in the long run.
</p>
<p>
One of the major subsystems of the home management system is the finance package, which includes a full double-entry accounting package (inspired by <a href="http://www.martinfowler.com/">Fowler</a>&#8216;s <a href="http://martinfowler.com/books.html#ap"><em>Analysis Patterns</em> (1997)</a> &#8212; an incredible read with updates still coming on his website).  The overriding principle of the home management system (I&#8217;m just calling it &#8220;Home&#8221; for now, but I&#8217;m sure that&#8217;s too broad of a name to trademark) is to bring enterprise-level systems to the home.  I also grew interested in building an accounting package for Linux, for which the pickin&#8217;s are indeed slim (no offense, <a href="http://www.gnucash.org/">GnuCash</a>, you guys have a great product, but there must be options!)
</p>
<p>
After going down the path of building a manual journal for entering transactions and a very rough <a href="http://en.wikipedia.org/wiki/Quicken_Interchange_Format"><acronym title="Quicken Interchange Format">QIF</acronym></a> import utility, I knew I&#8217;d never use the thing myself (and would never recommend it to anyone else) unless it had online banking.  In the US, this pretty much means <a href="http://www.ofx.net"><acronym title="Open Financial Exchange">OFX</acronym></a>.  So I needed a parser.
</p>
<p>
I didn&#8217;t know the first thing about parsers, so I scoured open-source land looking for any kind of OFX implementation that might get me started.  I had the peculiar constraint of insisting on pure Ruby, so this left <a href="http://www.libofx.org">libofx</a> and friends right out (although, trust me, I tried to sell myself on it).  Other than that, I found the <a href="http://rubyforge.org/projects/ofxrb">ofxrb</a> project that was in it&#8217;s adolescence, run by Adam Williams.  I touched base with Adam, but I think we had some different goals in mind.  So I went it alone (for now), and developed <a href="http://rubyforge.org/projects/ofx">OFX for Ruby</a>.
</p>
<p>
Even now, it&#8217;s capable of exchanging nearly all of the read-only message sets with an OFX 1.0.2 financial institution (which was my first immediate need).  I am explicitly going to have to steer clear of the destructive message sets (bill payments, transfers, etc.), because my fanatical need to write and run tests and my critical lack of a test server are fundamentally incompatible at the moment.  (Open solicitation to any financial institution with a friendly attitude to open-source: give me access to a test server and you won&#8217;t regret it!)
</p>
<p>
Thanks to the administrators of <a href="rubyforge.org">RubyForge</a> (Tom, I think it was) for the excellent turnaround on provisioning the project and just for having a great system in general.</p>
]]></content:encoded>
			<wfw:commentRss>http://objectthought.com/blog/2007/07/16/ofx-for-ruby/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A R&#233;sum&#233;?</title>
		<link>http://objectthought.com/blog/2007/03/16/a-resume/</link>
		<comments>http://objectthought.com/blog/2007/03/16/a-resume/#comments</comments>
		<pubDate>Fri, 16 Mar 2007 03:28:11 +0000</pubDate>
		<dc:creator>Chris Guidry</dc:creator>
				<category><![CDATA[Chris Guidry]]></category>
		<category><![CDATA[resume]]></category>

		<guid isPermaLink="false">http://objectthought.com/blog/2007/03/16/a-resume/</guid>
		<description><![CDATA[Looks like it. Check it out here.]]></description>
			<content:encoded><![CDATA[<p>Looks like it.  Check it out <a title="Chris' r&eacute;sum&eacute;" href="http://www.objectthought.com/resume.html">here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://objectthought.com/blog/2007/03/16/a-resume/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First post (again)/Ruby (again)</title>
		<link>http://objectthought.com/blog/2007/02/03/first-post-againruby-again/</link>
		<comments>http://objectthought.com/blog/2007/02/03/first-post-againruby-again/#comments</comments>
		<pubDate>Sat, 03 Feb 2007 15:46:11 +0000</pubDate>
		<dc:creator>Chris Guidry</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[test::unit]]></category>

		<guid isPermaLink="false">http://objectthought.com/blog/2007/02/03/first-post-againruby-again/</guid>
		<description><![CDATA[Got bit by the Typo bug, then got bit by Typo, so I changed to WordPress (I still love you, Rails). I&#8217;m starting this blog off with a little re-cap of my Ruby and Rails flails over the last few months. I&#8217;m infected with Ruby/Rails. It&#8217;s a disease. Every conversation I have with someone about [...]]]></description>
			<content:encoded><![CDATA[<p>
Got bit by the Typo bug, then got bit by Typo, so I changed to WordPress (I still love you, Rails).  I&#8217;m starting this blog off with a little re-cap of my Ruby and Rails flails over the last few months.
</p>
<p>
I&#8217;m infected with <a target="_blank" title="Ruby" href="http://www.ruby-lang.org/">Ruby</a>/<a target="_blank" title="Ruby on Rails" href="http://www.ruby-lang.org/">Rails</a>.  It&#8217;s a disease.  Every conversation I have with someone about technology, programming, and the Web ends up coming back to Ruby and Rails.  My friends are sick of me, seriously.  It&#8217;s not my fault, I just have to tell people the Truth, and when I do, it ends up referring back to Ruby and Rails.
</p>
<p>
My friends in strong-typed land, please give me one chance to change your mind with a little story about Ruby.  Ruby has an (okay) unit testing library called <a title="Test::Unit" target="_blank" href="http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit.html">Test::Unit</a> that is now part of the standard Ruby library.  It has the features you&#8217;d expect of a unit testing library, like defining test suites, running test methods, making assertions and outputting little dots to the console as each test passes.  I usually do all my testing from the console, whether I&#8217;m using nunit-console.exe or Test::Unit scripts in Rails.  I find that I get much more rapid feedback about my tests and I have long ago let go of my need to literally see the red/green lights to iterate my <a title="Test Driven Development" target="_blank" href="http://en.wikipedia.org/wiki/Test-driven_development">red-green-refactor</a> cycle.
</p>
<p>
One pet peeve of my (I have few) is when either my code or (worse) someone else&#8217;s code is writing out to the console during my unit tests and messing up my beautiful uninterrupted string of dots.  So I&#8217;m working on some console-style scripts to augment a Rails application I&#8217;ve started recently (don&#8217;t worry, once they&#8217;re something to blog about, it will be here), and like a good tester bee, I want all of my features to be tested.  So I whipped up some integration tests that would flex out my console tools, replete with <a target="_blank" title="OptionParser (Ruby's standard library)" href="http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/classes/OptionParser.html">OptionsParser</a>  testing to make sure all of my console options were covered.  Looked great.  So I ran my first tests, which just used the &#8220;backtick&#8221; method to invoke a console command from the Kernel.  Which looks something like this in Ruby code:<br />
<code>`myscript --option-one -a=abc`</code><br />
and will run that text verbatim at a new shell for your OS (<a target="_blank" title="GNU Bash" href="http://www.gnu.org/software/bash/">bash</a> for me). My tests passed and things were groovy.  Then I checked my <a title="Code Coverage" target="_blank" href="http://en.wikipedia.org/wiki/Code_coverage">code coverage</a> report from <a title="RCov" target="_blank" href="http://eigenclass.org/hiki.rb?rcov">RCov</a> (I&#8217;ll post later on how I use RCov in my Rails work), and found that my console tools weren&#8217;t getting covered by RCov.  They&#8217;re forked off in new processes by the backtick method, and RCov isn&#8217;t going to instrument them there.  D&#8217;oh!
</p>
<p>
At this point I hadn&#8217;t lost faith, so i decided to use the load method for my scripts:<br />
<code>load 'path/to/myscript.rb'</code><br />
but I was lacking a way to pass my command-line arguments, and I ended up just making a hacky global variable for them.  So I run my tests again and see to my horror that all of the console junk I was writing out in my console scripts was showing up in my test results (my beautiful linear dots!)
</p>
<p>
Now I&#8217;m getting serious.  I&#8217;ve got coverage, but I&#8217;ve also got this mess.  So I start thinking about Ruby and how it&#8217;s supposed to let you do anything you want.  If I want to redirect the console output for the duration of a test method, I should be able to do that, right?  Well, the answer I came up with might seem a little extreme, but it worked wonderfully, and I also have some code to share:<br />
<code><br />
    def execute_console_tool(consoleTool, arguments)<br />
        # redefine puts<br />
        Kernel::module_eval(< <end_of_eval<br />
            @@old_puts = method(:puts)</p>
<p>            @@output = ''<br />
            def output<br />
                @@output<br />
            end</p>
<p>            def puts(*args)<br />
                args.each do |arg|<br />
                    @@output += arg.to_s + "\n"<br />
                end if (args != nil)<br />
            end<br />
end_of_eval<br />
)</p>
<p>        # set the command-line arguments and run<br />
        $commandLineArguments = arguments<br />
        load consoleTool<br />
        Kernel::output</p>
<p>    ensure<br />
        # make sure puts is always put back<br />
        Kernel::module_eval(<<end_of_eval<br />
            remove_method :output<br />
            remove_method :puts<br />
            define_method(:puts) { |*args|<br />
                @@old_puts.call(*args)<br />
            }<br />
end_of_eval<br />
)<br />
    end<br />
</code></p>
<p>
I dropped this method into my Rails test_helper.rb class, and then I can call it from my unit tests:<br />
<code>execute_console_tool('path/to/myscript', ['--version', '-a=b'])</code>
</p>
<p>
How sweet is that?  Okay, I admit, this isn't really "elegant" in the sense that most Ruby code is elegant.  But what I want to illustrate here is that Ruby is truly dynamic and even the "built-in" features are malleable at run-time.  This is <em>impossible</em> in a statically typed language (or at minimum would require an enormous array of hacks, much more than this code).
</p>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://objectthought.com/blog/2007/02/03/first-post-againruby-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

