<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>RubyHam</title>
	<atom:link href="http://rubyham.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://rubyham.wordpress.com</link>
	<description>Promoting Ruby in the 'Ham</description>
	<lastBuildDate>Wed, 09 Jul 2008 14:03:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='rubyham.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>RubyHam</title>
		<link>http://rubyham.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://rubyham.wordpress.com/osd.xml" title="RubyHam" />
	<atom:link rel='hub' href='http://rubyham.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Distributed Processing with EC2 using PoolParty</title>
		<link>http://rubyham.wordpress.com/2008/07/09/distributed-processing-with-ec2-using-poolparty/</link>
		<comments>http://rubyham.wordpress.com/2008/07/09/distributed-processing-with-ec2-using-poolparty/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 03:59:31 +0000</pubDate>
		<dc:creator>Josh Adams</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[pool party]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://rubyham.wordpress.com/?p=41</guid>
		<description><![CDATA[So PoolParty seems nice.  Tonight I&#8217;ll be attempting to use it (primarily because it gives me shared disk across instances via S3 for free) to replace a script&#8217;s use of Sun Grid Engine (SGE) with EC2.  This happens to be all I need to pull this off fairly easily. So I&#8217;m using this to parallelize [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=41&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So <a title="Pool Party" href="http://poolpartyrb.com">PoolParty</a> seems nice.  Tonight I&#8217;ll be attempting to use it (primarily because it gives me shared disk across instances via S3 for free) to replace a script&#8217;s use of Sun Grid Engine (SGE) with EC2.  This happens to be all I need to pull this off fairly easily.</p>
<p>So I&#8217;m using this to parallelize <a href="http://www.fmrib.ox.ac.uk/fsl/index.html">FSL</a>, a bit of software that analyzes fMRI data.  Specifically, I&#8217;m modifying the parallelization function to handle EC2 on top of the Sun Grid Engine support it already has.  The current process ends up with a file called commands.txt.  Each line needs to be run on its own EC2 instance with access to the shared data directory, in which the output will be placed.  The current shell script will then take over, as that&#8217;s the behaviour that SGE ends up with for this task.</p>
<p>To help with this, Ari (the poolparty guy) wrote up <a href="http://github.com/auser/poolparty-sge-plugin/tree/master">a nice PoolParty Plugin for this very task</a>.</p>
<p>We&#8217;ll ignore the actual use case (just makes a good story) and simplify the problem to: launch a pool party that outputs a command to /data/log/output1, output2, etc.</p>
<p>My commands.txt file looks like:</p>
<p>ls /bin &gt; /data/output1<br />
ls /root &gt; /data/output2</p>
<p>Then it&#8217;s just a matter of pool -v -i -I ami-1234 -b shared_bucket.  This launches the appropriate number of instances and at the end of the process all of the data has been written to the appropriate place.</p>
<p>I actually wrote no ruby code for this.  Ari wrote the plugin that handled my whole use case, but it was really nice to see how tiny the plugin can be.  Ultimately, this gem looks intensely interesting for our generic use case, which was simply distributed processing of a massively parallelizable computation.  It completely replaces the need for Sun Grid Engine in this case.</p>
<p>Everyone join the <a href="http://poolpartyrb.com/">Pool Party</a>.</p>
<p>NOTE: Documentation is sparse at present, but Ari is available on Freenode#poolpartyrb and I would be glad to help anyone that wants to talk about how to use PoolParty in whatever small way I can.  Ari has said that this week is to be documentation week for the project.  And go <a href="http://pledgie.org/campaigns/1012">donate to the project if you can</a>.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/rubyham.wordpress.com/41/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/rubyham.wordpress.com/41/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rubyham.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rubyham.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rubyham.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rubyham.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rubyham.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rubyham.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rubyham.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rubyham.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rubyham.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rubyham.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rubyham.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rubyham.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rubyham.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rubyham.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=41&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rubyham.wordpress.com/2008/07/09/distributed-processing-with-ec2-using-poolparty/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c4a96dd75948ddd20ff31785b9a1966d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">knewter</media:title>
		</media:content>
	</item>
		<item>
		<title>Gitting git-svn working on mac</title>
		<link>http://rubyham.wordpress.com/2008/02/17/gitting-git-svn-working-on-mac/</link>
		<comments>http://rubyham.wordpress.com/2008/02/17/gitting-git-svn-working-on-mac/#comments</comments>
		<pubDate>Sun, 17 Feb 2008 16:54:38 +0000</pubDate>
		<dc:creator>russellkt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rubyham.wordpress.com/?p=40</guid>
		<description><![CDATA[I woke up fired up and ready to try git; unfortunately, it is three hours later and I&#8217;m just gitting started. The problem was getting git-svn to work. Despite the numerous posts including: post1 post2 post3 and post4 I absolutely could not get it to work. Finally, here are two techniques that worked for me: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=40&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I woke up fired up and ready to try git; unfortunately, it is three hours later and I&#8217;m just gitting started.  The problem was getting git-svn to work.  Despite the numerous posts including: <a href="http://speirs.org/2007/07/22/getting-git-svn-working-on-the-mac">post1</a> <a href="http://www.trawlr.com/items/3189156">post2</a> <a href="http://gvinu.blogspot.com/2007/10/git-on-mac-os-x-tiger-macbook.html">post3</a> and  <a href="http://larrytheliquid.com/2007/12/29/compiling-git-and-git-svn-on-osx-tiger/">post4</a> I absolutely could not get it to work.   Finally, here are two techniques that worked for me:<br />
<b>Port Method</b><br />
sudo port install subversion-perlbindings<br />
sudo port install git-core</p>
<p>or <b>Method2</b></p>
<p>follow <a href="http://speirs.org/2007/07/22/getting-git-svn-working-on-the-mac/">Fraser Spiers post</a></code></p>
<p>except</p>
<p>export PERL5LIB="/opt/subversion/lib/svn-perl:$PERL5LIb"</p>
<p>In other words, the package installs the subversion perl bindings in /opt/subversion/lib/svn-perl not /usr/local/lib/svn-perl.</p>
<p>Time to start gitting it done!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/rubyham.wordpress.com/40/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/rubyham.wordpress.com/40/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rubyham.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rubyham.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rubyham.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rubyham.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rubyham.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rubyham.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rubyham.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rubyham.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rubyham.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rubyham.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rubyham.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rubyham.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rubyham.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rubyham.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=40&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rubyham.wordpress.com/2008/02/17/gitting-git-svn-working-on-mac/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/926b6efbd4ae4ad4096df266e1693584?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">russellkt</media:title>
		</media:content>
	</item>
		<item>
		<title>First contribution from Brian: a class for recursive time-based operations, and our use in a Rails project</title>
		<link>http://rubyham.wordpress.com/2007/11/20/first-contribution-from-brian-a-class-for-recursive-time-based-operations-and-our-use-in-a-rails-project/</link>
		<comments>http://rubyham.wordpress.com/2007/11/20/first-contribution-from-brian-a-class-for-recursive-time-based-operations-and-our-use-in-a-rails-project/#comments</comments>
		<pubDate>Tue, 20 Nov 2007 01:31:45 +0000</pubDate>
		<dc:creator>Josh Adams</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[recursive events]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[time-based]]></category>

		<guid isPermaLink="false">http://rubyham.wordpress.com/2007/11/20/first-contribution-from-brian-a-class-for-recursive-time-based-operations-and-our-use-in-a-rails-project/</guid>
		<description><![CDATA[by Josh Adams Ever wanted to be able to do something like an Outlook-style recursive event generator? Say, schedule an event each MWF for the next six weeks from 8:00 &#8211; 8:30 AM? There&#8217;s a nice library called RUNT that I ran across today that makes this kind of temporal work easier. Then Brian, the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=39&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>by <strong>Josh Adams<br />
</strong><br />
Ever wanted to be able to do something like an Outlook-style recursive event generator?  Say, schedule an event each MWF for the next six weeks from 8:00 &#8211; 8:30 AM?  There&#8217;s <a href="http://runt.rubyforge.org/">a nice library called RUNT</a> that I ran across today that makes this kind of temporal work easier.</p>
<p>Then Brian, the newest hire at <a href="http://www.isotope11.com">isotope11</a>, created a library to ease the particular use case we had, which was using a form similar to the following:</p>
<p><a href="http://www.flickr.com/photos/knewter/2048173743/" title="Screenshot by knewter, on Flickr"><img src="http://farm3.static.flickr.com/2372/2048173743_1423efdb50.jpg" alt="Screenshot" height="313" width="500" /></a></p>
<p>The code for the GroupEvent class is as follows:</p>
<pre><code>
require 'runt'

class GroupEvent
  include Runt
  def self.schedule(start, finished, weekdays, type, &amp;date)
    case type
    when /w/i
      self.weekly(start, finished, weekdays) { |day| date.call(day) }
    when /b/i
      self.biweekly(start, finished, weekdays) { |day| date.call(day) }
    when /m/i
      self.monthly(start, finished) { |day| date.call(day) }
    when /y/i
      self.yearly(start, finished) { |day| date.call(day) }
    end
  end 

  def self.weekly(start, finished, weekdays, &amp;day)
    day = nil
    exp = nil
    for i in weekdays
      if (exp.nil?)
        exp = DIWeek.new(i)
      else
        exp ||= DIWeek.new(i)
      end
    end
    for day in (start..finished)
      if(exp.include?(day))
        yield(day)
      end
    end
  end

  def self.biweekly(start, finished, weekdays, &amp;biday)
    self.weekly(start, finished, weekdays) do |biday|
      if((biday.day%2) == (start.day%2))
        yield(biday)
      end
    end
  end

  def self.monthly(start, finished, &amp;month)
    current = start
    begin
      yield(current)
      current = current.to_time.months_since 1
    end while(current.to_time &lt; finished.to_time)
  end

  def self.yearly(start, finished, &amp;year)
    current = start
    begin
      yield(current)
      current = current.to_time.years_since 1
    end while(current.to_time &lt; finished.to_time)
  end
end

</code></pre>
<p>Inside the controller that form points to, I call the following (*horrendously ugly*) method:</p>
<pre><code>
  def create_events
    if params[:recursive]
      start_date = Date.new(params[:start_date][:year].to_i, params[:start_date][:month].to_i, params[:start_date][:day].to_i)
      end_date = Date.new(params[:end_date][:year].to_i, params[:end_date][:month].to_i, params[:end_date][:day].to_i)
      GroupEvent.schedule(start_date, end_date, params[:days].map(&amp;:to_i), params[:period]) do |date|
        starts_at = DateTime.new(date.year, date.month, date.day, params[:start_time][:hour].to_i, params[:start_time][:minute].to_i)
        ends_at = DateTime.new(date.year, date.month, date.day, params[:end_time][:hour].to_i, params[:end_time][:minute].to_i)
        DateEvent.create( :starts_at =&gt; starts_at, :ends_at =&gt; ends_at, :description =&gt; params[:event][:description])
      end
    else
      @event = DateEvent.new(params[:event])
    end
  end
</code></pre>
<p>Please, please forgive me for that code.  It was well past five and we just wanted to get it working, okay?  That code was mine, the good looking stuff above was Brian&#8217;s.  Don&#8217;t pin my trespasses on him.</p>
<p>Anyway, the code appears to do exactly what we want so far, haven&#8217;t found any quirks yet.  We&#8217;ll get better test coverage of this stuff tomorrow.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/rubyham.wordpress.com/39/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/rubyham.wordpress.com/39/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rubyham.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rubyham.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rubyham.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rubyham.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rubyham.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rubyham.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rubyham.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rubyham.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rubyham.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rubyham.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rubyham.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rubyham.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rubyham.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rubyham.wordpress.com/39/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=39&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rubyham.wordpress.com/2007/11/20/first-contribution-from-brian-a-class-for-recursive-time-based-operations-and-our-use-in-a-rails-project/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c4a96dd75948ddd20ff31785b9a1966d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">knewter</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2372/2048173743_1423efdb50.jpg" medium="image">
			<media:title type="html">Screenshot</media:title>
		</media:content>
	</item>
		<item>
		<title>RSS to synthesized speech in 47 inefficient lines</title>
		<link>http://rubyham.wordpress.com/2007/08/07/rss-to-synthesized-speech-in-49-inefficient-lines/</link>
		<comments>http://rubyham.wordpress.com/2007/08/07/rss-to-synthesized-speech-in-49-inefficient-lines/#comments</comments>
		<pubDate>Tue, 07 Aug 2007 12:16:15 +0000</pubDate>
		<dc:creator>Josh Adams</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rubyham.wordpress.com/2007/08/07/rss-to-synthesized-speech-in-49-inefficient-lines/</guid>
		<description><![CDATA[A few posts back I mentioned a ruby aggregator in 26 lines of code. I&#8217;ve spent the last fifteen minutes or so tying it to festival so it can read out RSS feeds. If you just want to read the script fast, click here. The code&#8217;s all there, but the coolest thing is the library [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=38&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A few posts back I mentioned <a href="http://rubyham.wordpress.com/2007/03/22/rss-aggregator-in-26-tasty-lines-of-ruby-code/">a ruby aggregator in 26 lines of code.</a>  I&#8217;ve spent the last fifteen minutes or so <a href="http://code.google.com/p/ruby-rss-to-speech/">tying it to festival so it can read out RSS feeds.</a></p>
<p><a href="http://ruby-rss-to-speech.googlecode.com/svn/trunk/rss_to_speech.rb">If you just want to read the script fast, click here.</a></p>
<p>The code&#8217;s all there, but the coolest thing is the library I found, <a href="festivaltts4r.rubyforge.org">FestivalTTS4Ruby</a>.</p>
<p>To actually run the code, you&#8217;ll need festival installed (I just shell out to it).  Fire up irb, and:</p>
<pre><code>
require 'rss_to_speech'
RSSToSpeech.new
</code></pre>
<p>That will read in each line of feeds.txt, suck down the posts for the feed, pipe it through a python script called html2text.py, then pipe that through festival &#8211;tts.  More lines than I&#8217;d like it to be, but I don&#8217;t feel like working on it any more  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/rubyham.wordpress.com/38/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/rubyham.wordpress.com/38/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rubyham.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rubyham.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rubyham.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rubyham.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rubyham.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rubyham.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rubyham.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rubyham.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rubyham.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rubyham.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rubyham.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rubyham.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rubyham.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rubyham.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=38&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rubyham.wordpress.com/2007/08/07/rss-to-synthesized-speech-in-49-inefficient-lines/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c4a96dd75948ddd20ff31785b9a1966d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">knewter</media:title>
		</media:content>
	</item>
		<item>
		<title>Ruby Require Idiom</title>
		<link>http://rubyham.wordpress.com/2007/05/21/ruby-require-idiom/</link>
		<comments>http://rubyham.wordpress.com/2007/05/21/ruby-require-idiom/#comments</comments>
		<pubDate>Mon, 21 May 2007 21:26:16 +0000</pubDate>
		<dc:creator>Mr.G</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rubyham.wordpress.com/2007/05/21/ruby-require-idiom/</guid>
		<description><![CDATA[I just posted an article about ruby&#8217;s require on my blog: http://ghouston.blogspot.com/2007/05/ruby-require-idiom.html It is fairly basic ruby stuff, but if you don&#8217;t know how Kernel#require works you can get bitten by files getting loaded multiple times. = Greg<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=37&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I just posted an article about ruby&#8217;s require on my blog: <a href="http://ghouston.blogspot.com/2007/05/ruby-require-idiom.html" title="Ruby Require Idiom">http://ghouston.blogspot.com/2007/05/ruby-require-idiom.html</a></p>
<p>It is fairly basic ruby stuff, but if you don&#8217;t know how Kernel#require works you can get bitten by files getting loaded multiple times.</p>
<p>= Greg</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/rubyham.wordpress.com/37/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/rubyham.wordpress.com/37/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rubyham.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rubyham.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rubyham.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rubyham.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rubyham.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rubyham.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rubyham.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rubyham.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rubyham.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rubyham.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rubyham.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rubyham.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rubyham.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rubyham.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=37&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rubyham.wordpress.com/2007/05/21/ruby-require-idiom/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ae6375984133343c1208b59a2317ba86?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ghouston</media:title>
		</media:content>
	</item>
		<item>
		<title>Thanks O&#8217;Reilly</title>
		<link>http://rubyham.wordpress.com/2007/04/13/thanks-oreilly/</link>
		<comments>http://rubyham.wordpress.com/2007/04/13/thanks-oreilly/#comments</comments>
		<pubDate>Fri, 13 Apr 2007 18:30:53 +0000</pubDate>
		<dc:creator>Mr.G</dc:creator>
				<category><![CDATA[O'Reilly]]></category>

		<guid isPermaLink="false">http://rubyham.wordpress.com/2007/04/13/thanks-oreilly/</guid>
		<description><![CDATA[Rubyham wants to say thanks to O&#8217;Reilly!  Through their User Group program, they have sponsored Rubyham with books.  At next month&#8217;s TechMixer 3.0 you can find Rubyham along with some of O&#8217;Reilly&#8217;s Ruby books to browse. O&#8217;Reilly is offering 35% off to Rubyham members, and &#8220;Orders over $29.95 qualify for free shipping in the US.&#8221;<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=35&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.oreilly.com/store/" title="ug_discount_336×280.gif"><img src="http://rubyham.files.wordpress.com/2007/04/ug_discount_336x280.gif?w=500" alt="O'Reilly Discount Code DSUG for 35% Off" /></a></p>
<p>Rubyham wants to say thanks to O&#8217;Reilly!  Through their User Group program, they have sponsored Rubyham with books.  At next month&#8217;s <a href="http://techmixer.org" title="TechMixer 3.0">TechMixer 3.0</a> you can find Rubyham along with some of O&#8217;Reilly&#8217;s Ruby books to browse. O&#8217;Reilly is offering 35% off to Rubyham members, and &#8220;Orders over $29.95 qualify for free shipping in the US.&#8221;</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/rubyham.wordpress.com/35/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/rubyham.wordpress.com/35/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rubyham.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rubyham.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rubyham.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rubyham.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rubyham.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rubyham.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rubyham.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rubyham.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rubyham.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rubyham.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rubyham.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rubyham.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rubyham.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rubyham.wordpress.com/35/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=35&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rubyham.wordpress.com/2007/04/13/thanks-oreilly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ae6375984133343c1208b59a2317ba86?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ghouston</media:title>
		</media:content>

		<media:content url="http://rubyham.files.wordpress.com/2007/04/ug_discount_336x280.gif" medium="image">
			<media:title type="html">O'Reilly Discount Code DSUG for 35% Off</media:title>
		</media:content>
	</item>
		<item>
		<title>RSS Aggregator in 26 tasty lines of Ruby code</title>
		<link>http://rubyham.wordpress.com/2007/03/22/rss-aggregator-in-26-tasty-lines-of-ruby-code/</link>
		<comments>http://rubyham.wordpress.com/2007/03/22/rss-aggregator-in-26-tasty-lines-of-ruby-code/#comments</comments>
		<pubDate>Thu, 22 Mar 2007 13:31:32 +0000</pubDate>
		<dc:creator>Josh Adams</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rubyham.wordpress.com/2007/03/22/rss-aggregator-in-26-tasty-lines-of-ruby-code/</guid>
		<description><![CDATA[By Josh Adams This story on an RSS Aggregator written in Ruby, brought to you by me via an RSS Aggregator written in something else. Get your library knowledge on. From the article: A liberal RSS aggregator in 26 lines of Ruby &#8211; may be hard to believe, but it’s true. On top of that, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=33&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>By <a href="http://knewter.wordpress.com">Josh Adams</a></p>
<p>This story <a href="http://www.igvita.com/blog/2007/03/22/agile-rss-aggregator-in-ruby/">on an RSS Aggregator written in Ruby</a>, brought to you by me via <a href="http://netvibes.com">an RSS Aggregator written in something else.</a></p>
<p>Get your library knowledge on.   From <a href="http://www.igvita.com/blog/2007/03/22/agile-rss-aggregator-in-ruby/">the article</a>:</p>
<p>A liberal RSS aggregator in 26 lines of Ruby &#8211; may be hard to believe, but it’s true. On top of that, it is also capable of serving static files, has a templating engine, and accepts an arbitrary number and types of RSS feeds &#8211; talk about squeezing functionality out of every line!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/rubyham.wordpress.com/33/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/rubyham.wordpress.com/33/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rubyham.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rubyham.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rubyham.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rubyham.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rubyham.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rubyham.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rubyham.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rubyham.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rubyham.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rubyham.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rubyham.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rubyham.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rubyham.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rubyham.wordpress.com/33/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=33&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rubyham.wordpress.com/2007/03/22/rss-aggregator-in-26-tasty-lines-of-ruby-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c4a96dd75948ddd20ff31785b9a1966d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">knewter</media:title>
		</media:content>
	</item>
		<item>
		<title>Deprec currently broken, but there&#8217;s an easy fix.</title>
		<link>http://rubyham.wordpress.com/2007/03/16/deprec-currently-broken-but-theres-an-easy-fix/</link>
		<comments>http://rubyham.wordpress.com/2007/03/16/deprec-currently-broken-but-theres-an-easy-fix/#comments</comments>
		<pubDate>Fri, 16 Mar 2007 15:04:46 +0000</pubDate>
		<dc:creator>Josh Adams</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rubyham.wordpress.com/2007/03/16/deprec-currently-broken-but-theres-an-easy-fix/</guid>
		<description><![CDATA[Mike Bailey, creator of Deprec, is apparently in Africa or something right now. Apache&#8217;s been updated, and the version of httpd that deprec points to (2.2.3) has been removed and replaced (2.2.4). To get deprec working for you, just edit your deprec recipe to correct this. Mine was at /usr/lib/ruby/gems/1.8/gems/deprec-1.3.1/recipes.rb I think. Search for 2.2.3 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=32&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Mike Bailey, creator of Deprec, is apparently in Africa or something right now.  Apache&#8217;s been updated, and the version of httpd that deprec points to (2.2.3) has been removed and replaced (2.2.4).  To get deprec working for you, just edit your deprec recipe to correct this.  Mine was at /usr/lib/ruby/gems/1.8/gems/deprec-1.3.1/recipes.rb I think.  Search for 2.2.3 and replace it with 2.2.4.  Fini.</p>
<p>Oh yeah, for the googlers, here&#8217;s the error I was seeing.</p>
<pre><code>
  * executing "sudo      sh -c \"cd /usr/local/src &amp;&amp; test -f httpd-2.2.3.tar.gz  &amp;&amp; echo 'f72ffb176e2dc7b322be16508c09f63c  httpd-2.2.3.tar.gz' | md5sum -c -  || wget --timestamping http://www.apache.org/dist/httpd/httpd-2.2.3.tar.gz\""
    servers: ["208.75.85.114"]
    [208.75.85.114] executing command
 ** [out :: 208.75.85.114] --14:56:39--  http://www.apache.org/dist/httpd/httpd-2.2.3.tar.gz
 ** [out :: 208.75.85.114] =&gt; `httpd-2.2.3.tar.gz'
 ** [out :: 208.75.85.114] Resolving www.apache.org...
 ** [out :: 208.75.85.114] 140.211.11.130
 ** [out :: 208.75.85.114] Connecting to www.apache.org|140.211.11.130|:80...
 ** [out :: 208.75.85.114] connected.
 ** [out :: 208.75.85.114] HTTP request sent, awaiting response...
 ** [out :: 208.75.85.114] 404 Not Found
 ** [out :: 208.75.85.114] 14:56:40 ERROR 404: Not Found.
    command finished
command "sudo      sh -c \"cd /usr/local/src &amp;&amp; test -f httpd-2.2.3.tar.gz  &amp;&amp; echo 'f72ffb176e2dc7b322be16508c09f63c  httpd-2.2.3.tar.gz' | md5sum -c -  || wget --timestamping http://www.apache.org/dist/httpd/httpd-2.2.3.tar.gz\"" failed on 208.75.85.114
</code></pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/rubyham.wordpress.com/32/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/rubyham.wordpress.com/32/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rubyham.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rubyham.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rubyham.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rubyham.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rubyham.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rubyham.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rubyham.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rubyham.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rubyham.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rubyham.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rubyham.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rubyham.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rubyham.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rubyham.wordpress.com/32/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=32&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rubyham.wordpress.com/2007/03/16/deprec-currently-broken-but-theres-an-easy-fix/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c4a96dd75948ddd20ff31785b9a1966d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">knewter</media:title>
		</media:content>
	</item>
		<item>
		<title>Google Spreadsheets Go Camping</title>
		<link>http://rubyham.wordpress.com/2007/03/07/google-spreadsheets-go-camping/</link>
		<comments>http://rubyham.wordpress.com/2007/03/07/google-spreadsheets-go-camping/#comments</comments>
		<pubDate>Wed, 07 Mar 2007 18:49:27 +0000</pubDate>
		<dc:creator>russellkt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rubyham.wordpress.com/2007/03/07/google-spreadsheets-go-camping/</guid>
		<description><![CDATA[Being such a pretty day in Birmingham, I decided to take google spreadsheets camping. I&#8217;m starting to use Google Spreadsheets more and more and have very little to complain about. However, the interface leaves much to be desired. My chief problem is the reliance on opening up multiple tabs( windows for non firefoxers ) for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=27&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Being such a pretty day in Birmingham, I decided to take google spreadsheets <a href="http://code.whytheluckystiff.net/camping/">camping</a>.  I&#8217;m starting to use Google Spreadsheets more and more and have very little to complain about.  However, the interface leaves much to be desired.  My chief problem is the reliance on opening up multiple tabs( windows for non firefoxers ) for each spreadsheet.  For instance:</p>
<p><a href="http://rubyham.files.wordpress.com/2007/03/picture-1.png" title="before"><img src="http://rubyham.files.wordpress.com/2007/03/picture-1.thumbnail.png?w=500" alt="before" /></a></p>
<p>What I&#8217;d really like is a simple:</p>
<p><a href='http://rubyham.files.wordpress.com/2007/03/after-camping.png' title='after camping'><img src='/files/2007/03/after-camping.thumbnail.png' alt='after camping' /></a></p>
<p>And something lightweight would be great.  First off, getting a list of the available sheets borrowing some code from the <a href="http://rubyforge.org/projects/gdata-ruby/">gdata rubyforge project</a></p>
<pre width="600"><span class="ident">require</span> <span class="punct">'</span><span class="string">net/http</span><span class="punct">'</span>
<span class="ident">require</span> <span class="punct">'</span><span class="string">net/https</span><span class="punct">'</span>
<span class="ident">require</span> <span class="punct">'</span><span class="string">uri</span><span class="punct">'</span>
<span class="ident">require</span> <span class="punct">'</span><span class="string">hpricot</span><span class="punct">'</span>

<span class="keyword">module </span><span class="module">Net</span>
  <span class="keyword">class </span><span class="class">HTTPS</span> <span class="punct">&lt;</span> <span class="constant">HTTP</span>
    <span class="keyword">def </span><span class="method">initialize</span><span class="punct">(</span><span class="ident">address</span><span class="punct">,</span> <span class="ident">port</span> <span class="punct">=</span> <span class="constant">nil</span><span class="punct">)</span>
      <span class="keyword">super</span><span class="punct">(</span><span class="ident">address</span><span class="punct">,</span> <span class="ident">port</span><span class="punct">)</span>
      <span class="constant">self</span><span class="punct">.</span><span class="ident">use_ssl</span> <span class="punct">=</span> <span class="constant">true</span>
    <span class="keyword">end</span>
  <span class="keyword">end</span>
<span class="keyword">end</span>

<span class="keyword">class </span><span class="class">GoogleSpreadsheet</span>
  <span class="ident">attr_accessor</span> <span class="symbol">:id</span><span class="punct">,</span> <span class="symbol">:links</span><span class="punct">,</span> <span class="symbol">:title</span><span class="punct">,</span> <span class="symbol">:link</span><span class="punct">,</span> <span class="symbol">:key</span>
  <span class="constant">SPREADSHEETS_ROOT</span> <span class="punct">=</span> <span class="punct">"</span><span class="string">http://spreadsheets.google.com/ccc</span><span class="punct">"</span>
  <span class="constant">URL_ROOT</span> <span class="punct">=</span> <span class="punct">"</span><span class="string"><span class="expr">#{SPREADSHEETS_ROOT}</span>?key=</span><span class="punct">"</span>
  <span class="constant">NEW_LINK</span> <span class="punct">=</span> <span class="punct">"</span><span class="string"><span class="expr">#{SPREADSHEETS_ROOT}</span>?new</span><span class="punct">"</span>
  <span class="keyword">def </span><span class="method">initialize</span><span class="punct">(</span><span class="ident">entry</span><span class="punct">)</span>
    <span class="attribute">@id</span> <span class="punct">=</span> <span class="ident">entry</span><span class="punct">['</span><span class="string">id</span><span class="punct">'][</span><span class="number">0</span><span class="punct">]</span>
    <span class="attribute">@key</span> <span class="punct">=</span> <span class="attribute">@id</span><span class="punct">.</span><span class="ident">split</span><span class="punct">('</span><span class="string">/</span><span class="punct">').</span><span class="ident">last</span>
    <span class="attribute">@links</span> <span class="punct">=</span> <span class="ident">entry</span><span class="punct">['</span><span class="string">link</span><span class="punct">']</span>
    <span class="attribute">@link</span> <span class="punct">=</span> <span class="constant">URL_ROOT</span> <span class="punct">+</span> <span class="attribute">@key</span><span class="punct">.</span><span class="ident">to_s</span>
    <span class="attribute">@title</span> <span class="punct">=</span> <span class="ident">entry</span><span class="punct">['</span><span class="string">content</span><span class="punct">']['</span><span class="string">content</span><span class="punct">']</span>
  <span class="keyword">end</span>

  <span class="keyword">def </span><span class="method">document</span>
    <span class="constant">XmlSimple</span><span class="punct">.</span><span class="ident">xml_in</span><span class="punct">(</span><span class="attribute">@link</span><span class="punct">)</span>
  <span class="keyword">end</span>
<span class="keyword">end</span>

<span class="keyword">class </span><span class="class">GoogleUser</span>
  <span class="constant">GOOGLE_SPREADSHEET_LIST_URL</span> <span class="punct">=</span> <span class="punct">'</span><span class="string">/feeds/spreadsheets/private/full</span><span class="punct">'</span>
  <span class="constant">GOOGLE_LOGIN_URL</span> <span class="punct">=</span> <span class="constant">URI</span><span class="punct">.</span><span class="ident">parse</span><span class="punct">('</span><span class="string">https://www.google.com/accounts/ClientLogin</span><span class="punct">')</span>
  <span class="ident">attr_accessor</span> <span class="symbol">:email</span><span class="punct">,</span> <span class="symbol">:password</span><span class="punct">,</span> <span class="symbol">:token</span><span class="punct">,</span> <span class="symbol">:spreadsheets</span>
  <span class="keyword">def </span><span class="method">initialize</span><span class="punct">(</span><span class="ident">email</span><span class="punct">,</span> <span class="ident">password</span><span class="punct">)</span>
    <span class="constant">self</span><span class="punct">.</span><span class="ident">email</span><span class="punct">=</span><span class="ident">email</span>
    <span class="constant">self</span><span class="punct">.</span><span class="ident">password</span><span class="punct">=</span><span class="ident">password</span>
    <span class="constant">self</span><span class="punct">.</span><span class="ident">authenticate</span>
  <span class="keyword">end</span>

  <span class="keyword">def </span><span class="method">authenticate</span>
    <span class="global">$VERBOSE</span> <span class="punct">=</span> <span class="constant">nil</span>
    <span class="ident">response</span> <span class="punct">=</span> <span class="constant">Net</span><span class="punct">::</span><span class="constant">HTTPS</span><span class="punct">.</span><span class="ident">post_form</span><span class="punct">(</span><span class="constant">GOOGLE_LOGIN_URL</span><span class="punct">,</span>
      <span class="punct">{'</span><span class="string">Email</span><span class="punct">'</span>   <span class="punct">=&gt;</span> <span class="ident">email</span><span class="punct">,</span>
       <span class="punct">'</span><span class="string">Passwd</span><span class="punct">'</span>  <span class="punct">=&gt;</span> <span class="ident">password</span><span class="punct">,</span>
       <span class="punct">'</span><span class="string">source</span><span class="punct">'</span>  <span class="punct">=&gt;</span> <span class="punct">"</span><span class="string">formula</span><span class="punct">",</span>
       <span class="punct">'</span><span class="string">service</span><span class="punct">'</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">wise</span><span class="punct">'</span> <span class="punct">})</span>
    <span class="attribute">@headers</span> <span class="punct">=</span> <span class="punct">{</span>
     <span class="punct">'</span><span class="string">Authorization</span><span class="punct">'</span> <span class="punct">=&gt;</span> <span class="punct">"</span><span class="string">GoogleLogin auth=<span class="expr">#{response.body.split(/=/).last}</span></span><span class="punct">",</span>
     <span class="punct">'</span><span class="string">Content-Type</span><span class="punct">'</span>  <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">application/atom+xml</span><span class="punct">'</span>
    <span class="punct">}</span>
  <span class="keyword">end</span>

  <span class="keyword">def </span><span class="method">get_spreadsheets</span>
    <span class="ident">the_list</span> <span class="punct">=</span> <span class="constant">XmlSimple</span><span class="punct">.</span><span class="ident">xml_in</span><span class="punct">(</span><span class="ident">spreadsheets_list</span><span class="punct">)</span>
    <span class="attribute">@spreadsheets</span> <span class="punct">=</span> <span class="punct">[]</span>
    <span class="ident">the_list</span><span class="punct">['</span><span class="string">entry</span><span class="punct">'].</span><span class="ident">each</span><span class="punct">{|</span><span class="ident">entry</span><span class="punct">|</span>
      <span class="attribute">@spreadsheets</span> <span class="punct">&lt;&lt;</span> <span class="constant">GoogleSpreadsheet</span><span class="punct">.</span><span class="ident">new</span><span class="punct">(</span><span class="ident">entry</span><span class="punct">)</span>
    <span class="punct">}</span>
    <span class="attribute">@spreadsheets</span>
  <span class="keyword">end</span>

  <span class="keyword">def </span><span class="method">spreadsheets_list</span>
    <span class="ident">request</span><span class="punct">(</span><span class="constant">GOOGLE_SPREADSHEET_LIST_URL</span><span class="punct">)</span>
  <span class="keyword">end</span>

  <span class="ident">private</span>
  <span class="keyword">def </span><span class="method">request</span><span class="punct">(</span><span class="ident">path</span><span class="punct">)</span>
    <span class="ident">response</span><span class="punct">,</span> <span class="ident">data</span> <span class="punct">=</span> <span class="ident">get_http</span><span class="punct">.</span><span class="ident">get</span><span class="punct">(</span><span class="ident">path</span><span class="punct">,</span> <span class="attribute">@headers</span><span class="punct">)</span>
    <span class="ident">data</span>
  <span class="keyword">end</span>

  <span class="keyword">def </span><span class="method">post</span><span class="punct">(</span><span class="ident">path</span><span class="punct">,</span> <span class="ident">entry</span><span class="punct">)</span>
    <span class="ident">get_http</span><span class="punct">.</span><span class="ident">post</span><span class="punct">(</span><span class="ident">path</span><span class="punct">,</span> <span class="ident">entry</span><span class="punct">,</span> <span class="attribute">@headers</span><span class="punct">)</span>
  <span class="keyword">end</span>

  <span class="keyword">def </span><span class="method">get_http</span>
    <span class="ident">http</span> <span class="punct">=</span> <span class="constant">Net</span><span class="punct">::</span><span class="constant">HTTP</span><span class="punct">.</span><span class="ident">new</span><span class="punct">('</span><span class="string">spreadsheets.google.com</span><span class="punct">',</span> <span class="number">80</span><span class="punct">)</span>
    <span class="ident">http</span>
  <span class="keyword">end</span>
<span class="keyword">end</span></pre>
<p>Then for the single file camping interface:</p>
<pre><span class="comment">#!/usr/bin/ruby</span>
<span class="punct">%w(</span><span class="string">rubygems camping gspreadsheet</span><span class="punct">).</span><span class="ident">each</span> <span class="punct">{</span> <span class="punct">|</span><span class="ident">lib</span><span class="punct">|</span> <span class="ident">require</span> <span class="ident">lib</span> <span class="punct">}</span>

<span class="constant">Camping</span><span class="punct">.</span><span class="ident">goes</span> <span class="symbol">:CampingInSheets</span>

<span class="keyword">module </span><span class="module">CampingInSheets::Controllers</span>
  <span class="keyword">class </span><span class="class">Index</span> <span class="punct">&lt;</span> <span class="constant">R</span> <span class="punct">'</span><span class="string">/</span><span class="punct">'</span>
    <span class="keyword">def </span><span class="method">get</span>
      <span class="ident">render</span> <span class="symbol">:index</span>
    <span class="keyword">end</span>
    <span class="keyword">def </span><span class="method">post</span>
      <span class="attribute">@user</span> <span class="punct">=</span> <span class="constant">GoogleUser</span><span class="punct">.</span><span class="ident">new</span><span class="punct">(</span><span class="ident">input</span><span class="punct">.</span><span class="ident">username</span><span class="punct">,</span> <span class="ident">input</span><span class="punct">.</span><span class="ident">password</span><span class="punct">)</span>
      <span class="attribute">@spreadsheets</span> <span class="punct">=</span> <span class="attribute">@user</span><span class="punct">.</span><span class="ident">get_spreadsheets</span>
      <span class="ident">render</span> <span class="symbol">:index</span>
    <span class="keyword">end</span>
  <span class="keyword">end</span>
  <span class="keyword">class </span><span class="class">Style</span> <span class="punct">&lt;</span> <span class="constant">R</span> <span class="punct">'</span><span class="string">/styles.css</span><span class="punct">'</span>
    <span class="keyword">def </span><span class="method">get</span>
      <span class="attribute">@headers</span><span class="punct">["</span><span class="string">Content-Type</span><span class="punct">"]</span> <span class="punct">=</span> <span class="punct">"</span><span class="string">text/css; charset=utf-8</span><span class="punct">"</span>
      <span class="attribute">@body</span> <span class="punct">=</span> <span class="punct">%{</span><span class="string">
          iframe{width: 100%; height: 80%;</span><span class="punct">}</span>
      <span class="punct">}</span>
    <span class="keyword">end</span>
  <span class="keyword">end</span>
<span class="keyword">end</span>

<span class="keyword">module </span><span class="module">CampingInSheets::Views</span>
  <span class="attribute">@@mab</span> <span class="punct">=</span> <span class="constant">Markaby</span><span class="punct">::</span><span class="constant">Builder</span><span class="punct">.</span><span class="ident">new</span>
  <span class="constant">SPREADSHEETS_ROOT</span> <span class="punct">=</span> <span class="punct">"</span><span class="string">http://spreadsheets.google.com/ccc</span><span class="punct">"</span>
  <span class="constant">NEW_LINK</span> <span class="punct">=</span> <span class="punct">"</span><span class="string"><span class="expr">#{SPREADSHEETS_ROOT}</span>?new</span><span class="punct">"</span>
  <span class="keyword">def </span><span class="method">spreadsheet_link</span> <span class="ident">spreadsheet</span>
    <span class="ident">link_to</span> <span class="ident">spreadsheet</span><span class="punct">.</span><span class="ident">title</span><span class="punct">,</span> <span class="ident">spreadsheet</span><span class="punct">.</span><span class="ident">link</span><span class="punct">,</span> <span class="symbol">:target</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">sheets</span><span class="punct">'</span>
  <span class="keyword">end</span>
  <span class="keyword">def </span><span class="method">spreadsheet_dropdown</span> <span class="ident">spreadsheets</span>
    <span class="ident">options</span> <span class="punct">=</span> <span class="ident">spreadsheets</span><span class="punct">.</span><span class="ident">map</span><span class="punct">{|</span><span class="ident">x</span><span class="punct">|</span> <span class="punct">"</span><span class="string">&lt;option value='<span class="expr">#{ x.link }</span>'&gt;<span class="expr">#{x.title}</span>&lt;/option&gt;</span><span class="punct">"}</span>
    <span class="ident">options</span> <span class="punct">=</span> <span class="punct">"</span><span class="string">&lt;option value='<span class="expr">#{NEW_LINK}</span>'&gt;New Spreadsheet&lt;/option&gt;</span><span class="punct">"</span> <span class="punct">+</span> <span class="ident">options</span><span class="punct">.</span><span class="ident">join</span>
    <span class="ident">options</span> <span class="punct">=</span> <span class="punct">"</span><span class="string">&lt;option&gt;&lt;/option&gt;</span><span class="punct">"</span> <span class="punct">+</span> <span class="ident">options</span>
    <span class="attribute">@@mab</span><span class="punct">.</span><span class="ident">html</span><span class="punct">{</span>
     <span class="ident">form</span><span class="punct">{</span>
      <span class="ident">select</span><span class="punct">(</span><span class="symbol"> <img src='http://s1.wp.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> nchange</span> <span class="punct">=&gt;</span> <span class="punct">"</span><span class="string">var l = this.options[this.selectedIndex].value; if( l != '' ){ sheets.location.href=l; }</span><span class="punct">"){</span>
       <span class="constant">self</span> <span class="punct">&lt;&lt;</span> <span class="ident">options</span>
      <span class="punct">}</span>
     <span class="punct">}</span>
    <span class="punct">}</span>
  <span class="keyword">end</span>
  <span class="keyword">def </span><span class="method">layout</span>
    <span class="ident">html</span> <span class="keyword">do</span>
      <span class="ident">head</span> <span class="keyword">do</span>
        <span class="ident">title</span> <span class="punct">'</span><span class="string">Camping in Sheets</span><span class="punct">'</span>
        <span class="ident">link</span> <span class="symbol">:href=</span><span class="punct">&gt;</span><span class="constant">R</span><span class="punct">(</span><span class="constant">Style</span><span class="punct">),</span> <span class="symbol">:rel=</span><span class="punct">&gt;'</span><span class="string">stylesheet</span><span class="punct">',</span> <span class="symbol">:type=</span><span class="punct">&gt;'</span><span class="string">text/css</span><span class="punct">'</span>
      <span class="keyword">end</span>
      <span class="ident">body</span> <span class="keyword">do</span>
        <span class="ident">div</span><span class="punct">.</span><span class="ident">content</span> <span class="keyword">do</span>
          <span class="constant">self</span> <span class="punct">&lt;&lt;</span> <span class="keyword">yield</span>
        <span class="keyword">end</span>
      <span class="keyword">end</span>
    <span class="keyword">end</span>
  <span class="keyword">end</span>
  <span class="keyword">def </span><span class="method">index</span>
    <span class="keyword">if</span> <span class="attribute">@user</span>
      <span class="ident">h1</span> <span class="punct">"</span><span class="string"><span class="expr">#{@user.email.gsub(/@.*/,'')}</span> google spreadsheets</span><span class="punct">"</span>
      <span class="constant">self</span> <span class="punct">&lt;&lt;</span> <span class="ident">spreadsheet_dropdown</span><span class="punct">(</span><span class="attribute">@spreadsheets</span><span class="punct">)</span>
      <span class="ident">iframe</span><span class="punct">(</span><span class="symbol">:name</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">sheets</span><span class="punct">')</span>
    <span class="keyword">else</span>
      <span class="ident">_login</span>
    <span class="keyword">end</span>
  <span class="keyword">end</span>
  <span class="keyword">def </span><span class="method">_login</span>
    <span class="ident">h1</span> <span class="punct">'</span><span class="string">Google Email and Password needed to Camp</span><span class="punct">'</span>
    <span class="ident">form</span> <span class="symbol">:action</span> <span class="punct">=&gt;</span> <span class="constant">R</span><span class="punct">(</span><span class="constant">Index</span><span class="punct">),</span> <span class="symbol">:method</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">post</span><span class="punct">'</span> <span class="keyword">do</span>
      <span class="ident">label</span> <span class="punct">'</span><span class="string">Username</span><span class="punct">',</span> <span class="symbol">:for</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">username</span><span class="punct">';</span> <span class="ident">br</span>
      <span class="ident">input</span> <span class="symbol">:name</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">username</span><span class="punct">',</span> <span class="symbol">:type</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">text</span><span class="punct">';</span> <span class="ident">br</span>

      <span class="ident">label</span> <span class="punct">'</span><span class="string">Password</span><span class="punct">',</span> <span class="symbol">:for</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">password</span><span class="punct">';</span> <span class="ident">br</span>
      <span class="ident">input</span> <span class="symbol">:name</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">password</span><span class="punct">',</span> <span class="symbol">:type</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">password</span><span class="punct">';</span> <span class="ident">br</span>

      <span class="ident">input</span> <span class="symbol">:type</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">submit</span><span class="punct">',</span> <span class="symbol">:name</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">login</span><span class="punct">',</span> <span class="symbol">:value</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">Login</span><span class="punct">'</span>
    <span class="keyword">end</span>
  <span class="keyword">end</span>
<span class="keyword">end</span></pre>
<p>And hardcore campers could rightly say that the code is horribly inefficient but it works for me.  Combining this with a mousehole script to proxy all request to google spreadsheets to the camping interface would make this even better.</p>
<p>In order to make the two files work together, install the gems necessary for camping, save the second code snippet as camping_in_sheets.rb, the first as gspreadsheet.rb, and then from the command line type:</p>
<p>camping camping_in_sheets.rb</p>
<p>and enjoy.  If anyone gets it going with mousehole, let me know.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/rubyham.wordpress.com/27/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/rubyham.wordpress.com/27/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rubyham.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rubyham.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rubyham.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rubyham.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rubyham.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rubyham.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rubyham.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rubyham.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rubyham.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rubyham.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rubyham.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rubyham.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rubyham.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rubyham.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=27&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rubyham.wordpress.com/2007/03/07/google-spreadsheets-go-camping/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/926b6efbd4ae4ad4096df266e1693584?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">russellkt</media:title>
		</media:content>

		<media:content url="http://rubyham.files.wordpress.com/2007/03/picture-1.thumbnail.png" medium="image">
			<media:title type="html">before</media:title>
		</media:content>

		<media:content url="/files/2007/03/after-camping.thumbnail.png" medium="image">
			<media:title type="html">after camping</media:title>
		</media:content>
	</item>
		<item>
		<title>JSON like ruby object</title>
		<link>http://rubyham.wordpress.com/2007/03/07/json-like-ruby-object/</link>
		<comments>http://rubyham.wordpress.com/2007/03/07/json-like-ruby-object/#comments</comments>
		<pubDate>Wed, 07 Mar 2007 17:43:20 +0000</pubDate>
		<dc:creator>russellkt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rubyham.wordpress.com/2007/03/07/json-like-ruby-object/</guid>
		<description><![CDATA[Recently when creating a rails backed dsl for interacting with Quickbooks SDK, I found myself desiring the ability to have json like behavior on a ruby object. By this I mean being able to create an object with attributes and subobjects on the fly and then being able to access them easily. My solution and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=26&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently when creating a rails backed dsl for interacting with Quickbooks SDK, I found myself desiring the ability to have json like behavior on a ruby object.  By this I mean being able to create an object with attributes and subobjects on the fly and then being able to access them easily.  My solution and with quite a bit of help from <a href="http://knewter.wordpress.com">jadams</a> was first to reopen the Hash class and insert a method missing to allow for accessing hash['attribute'] with the more rubyesque hash.attribute.  The technique and my first ever metaprogramming was inspired by <a href="http://ola-bini.blogspot.com/2006/09/ruby-metaprogramming-techniques.html">Ola Bini&#8217;s excellent blog post</a>, specifically method 4 which uses an example from <a href="http://code.whytheluckystiff.net/camping/"> why&#8217;s fantastic camping project</a>.</p>
<pre><span class="keyword">class </span><span class="class">Hash</span>
  <span class="keyword">def </span><span class="method">method_missing</span><span class="punct">(</span><span class="ident">m</span><span class="punct">,*</span><span class="ident">a</span><span class="punct">)</span>
    <span class="keyword">if</span> <span class="ident">m</span><span class="punct">.</span><span class="ident">to_s</span> <span class="punct">=~</span> <span class="punct">/</span><span class="regex">=$</span><span class="punct">/</span>
      <span class="constant">self</span><span class="punct">[</span><span class="global">$`</span><span class="punct">]</span> <span class="punct">=</span> <span class="ident">a</span><span class="punct">[</span><span class="number">0</span><span class="punct">]</span>
    <span class="keyword">elsif</span> <span class="ident">a</span><span class="punct">.</span><span class="ident">empty?</span>
      <span class="constant">self</span><span class="punct">[</span><span class="ident">m</span><span class="punct">]={}</span> <span class="keyword">unless</span> <span class="constant">self</span><span class="punct">[</span><span class="ident">m</span><span class="punct">]</span>
      <span class="constant">self</span><span class="punct">[</span><span class="ident">m</span><span class="punct">]</span>
    <span class="keyword">else</span>
      <span class="keyword">raise</span> <span class="constant">NoMethodError</span><span class="punct">,</span> <span class="punct">"</span><span class="string"><span class="expr">#{m}</span></span><span class="punct">"</span>
    <span class="keyword">end</span>
  <span class="keyword">end</span>
<span class="keyword">end</span></pre>
<p>The next step was simply to create a generic object with an attr_accessor to create a hash:</p>
<pre><span class="keyword">class </span><span class="class">JSONLikeObject</span>
  <span class="ident">attr_accessor</span> <span class="symbol">:type</span><span class="punct">,</span> <span class="symbol">:attributes</span>
  <span class="keyword">def </span><span class="method">initialize</span><span class="punct">(</span><span class="ident">type</span><span class="punct">,</span> <span class="ident">attributes</span> <span class="punct">=</span> <span class="punct">{})</span>
    <span class="attribute">@type</span> <span class="punct">=</span> <span class="ident">type</span>
    <span class="attribute">@attributes</span> <span class="punct">=</span> <span class="ident">attributes</span>
  <span class="keyword">end</span>
<span class="keyword">end</span></pre>
<p>Great!  Now I&#8217;m able to say foo = JsonLikeObject.new and then say foo.attributes.attribute to access foo.attributes['attribute'].  Closer, but I really wanted to be able to say foo.attribute, so I defined method missing for the JSONLikeObject class:</p>
<pre><span class="keyword">def </span><span class="method">method_missing</span><span class="punct">(</span><span class="ident">m</span><span class="punct">,*</span><span class="ident">a</span><span class="punct">)</span>
    <span class="keyword">if</span> <span class="ident">m</span><span class="punct">.</span><span class="ident">to_s</span> <span class="punct">=~</span> <span class="punct">/</span><span class="regex">=$</span><span class="punct">/</span>
      <span class="attribute">@attributes</span><span class="punct">.</span><span class="ident">send</span><span class="punct">(</span><span class="ident">m</span><span class="punct">,</span><span class="ident">a</span><span class="punct">[</span><span class="number">0</span><span class="punct">])</span>
    <span class="keyword">else</span>
      <span class="attribute">@attributes</span><span class="punct">[</span><span class="ident">m</span><span class="punct">]={}</span> <span class="keyword">unless</span> <span class="attribute">@attributes</span><span class="punct">[</span><span class="ident">m</span><span class="punct">]</span>
      <span class="attribute">@attributes</span><span class="punct">[</span><span class="ident">m</span><span class="punct">]</span>
    <span class="keyword">end</span>
  <span class="keyword">end</span></pre>
<p>Mission accomplished, but I really would like a more complicated/richer tree. For example, customer = JSONLikeObject.new and be able to write customer.contact.address.line1 = &#8216;Ruby Drive&#8217; and it create customer.attributes['contact']['address']['line1'] = &#8216;Ruby Drive&#8217; without blowing up.  Off to read Ola&#8217;s post again and there in example 1 lies the solution:</p>
<pre><span class="keyword">module </span><span class="module">Kernel</span>
  <span class="keyword">def </span><span class="method">singleton_class</span>
    <span class="keyword">class </span><span class="punct">&lt;&lt;</span> <span class="constant">self</span><span class="punct">;</span> <span class="constant">self</span><span class="punct">;</span> <span class="keyword">end</span>
  <span class="keyword">end</span>
<span class="keyword">end</span></pre>
<p>Now it is simply a matter of taking the method missing from the class and wrapping it in a module that can be included upon initialization:</p>
<pre><span class="keyword">class </span><span class="class">Hash</span>
  <span class="keyword">def </span><span class="method">method_missing</span><span class="punct">(</span><span class="ident">m</span><span class="punct">,*</span><span class="ident">a</span><span class="punct">)</span>
    <span class="keyword">if</span> <span class="ident">m</span><span class="punct">.</span><span class="ident">to_s</span> <span class="punct">=~</span> <span class="punct">/</span><span class="regex">=$</span><span class="punct">/</span>
      <span class="constant">self</span><span class="punct">[</span><span class="global">$`</span><span class="punct">]</span> <span class="punct">=</span> <span class="ident">a</span><span class="punct">[</span><span class="number">0</span><span class="punct">]</span>
    <span class="keyword">elsif</span> <span class="ident">a</span><span class="punct">.</span><span class="ident">empty?</span>
      <span class="constant">self</span><span class="punct">[</span><span class="ident">m</span><span class="punct">]={}</span> <span class="keyword">unless</span> <span class="constant">self</span><span class="punct">[</span><span class="ident">m</span><span class="punct">]</span>
      <span class="constant">self</span><span class="punct">[</span><span class="ident">m</span><span class="punct">]</span>
    <span class="keyword">else</span>
      <span class="keyword">raise</span> <span class="constant">NoMethodError</span><span class="punct">,</span> <span class="punct">"</span><span class="string"><span class="expr">#{m}</span></span><span class="punct">"</span>
    <span class="keyword">end</span>
  <span class="keyword">end</span>
<span class="keyword">end</span>
<span class="keyword">module </span><span class="module">Kernel</span>
  <span class="keyword">def </span><span class="method">singleton_class</span>
    <span class="keyword">class </span><span class="punct">&lt;&lt;</span> <span class="constant">self</span><span class="punct">;</span> <span class="constant">self</span><span class="punct">;</span> <span class="keyword">end</span>
  <span class="keyword">end</span>
<span class="keyword">end</span>
<span class="keyword">module </span><span class="module">Mod</span>
  <span class="keyword">def </span><span class="method">method_missing</span><span class="punct">(</span><span class="ident">m</span><span class="punct">,*</span><span class="ident">a</span><span class="punct">)</span>
    <span class="keyword">if</span> <span class="ident">m</span><span class="punct">.</span><span class="ident">to_s</span> <span class="punct">=~</span> <span class="punct">/</span><span class="regex">=$</span><span class="punct">/</span>
      <span class="attribute">@attributes</span><span class="punct">.</span><span class="ident">send</span><span class="punct">(</span><span class="ident">m</span><span class="punct">,</span><span class="ident">a</span><span class="punct">[</span><span class="number">0</span><span class="punct">])</span>
    <span class="keyword">else</span>
      <span class="attribute">@attributes</span><span class="punct">[</span><span class="ident">m</span><span class="punct">]={}</span> <span class="keyword">unless</span> <span class="attribute">@attributes</span><span class="punct">[</span><span class="ident">m</span><span class="punct">]</span>
      <span class="attribute">@attributes</span><span class="punct">[</span><span class="ident">m</span><span class="punct">]</span>
    <span class="keyword">end</span>
  <span class="keyword">end</span>
<span class="keyword">end</span>
<span class="keyword">class </span><span class="class">JSONLikeObject</span>
  <span class="ident">attr_accessor</span> <span class="symbol">:type</span><span class="punct">,</span> <span class="symbol">:attributes</span>
  <span class="keyword">def </span><span class="method">initialize</span><span class="punct">(</span><span class="ident">type</span><span class="punct">,</span> <span class="ident">attributes</span> <span class="punct">=</span> <span class="punct">{})</span>
    <span class="attribute">@type</span> <span class="punct">=</span> <span class="ident">type</span>
    <span class="attribute">@attributes</span> <span class="punct">=</span> <span class="ident">attributes</span>
    <span class="ident">singleton_class</span><span class="punct">.</span><span class="ident">class_eval</span> <span class="keyword">do</span>
      <span class="ident">include</span> <span class="constant">Mod</span>
    <span class="keyword">end</span>
  <span class="keyword">end</span>
<span class="keyword">end</span></pre>
<p>And bingo, a json like object in ruby.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/rubyham.wordpress.com/26/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/rubyham.wordpress.com/26/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rubyham.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rubyham.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rubyham.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rubyham.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rubyham.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rubyham.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rubyham.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rubyham.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rubyham.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rubyham.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rubyham.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rubyham.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rubyham.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rubyham.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubyham.wordpress.com&amp;blog=399763&amp;post=26&amp;subd=rubyham&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rubyham.wordpress.com/2007/03/07/json-like-ruby-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/926b6efbd4ae4ad4096df266e1693584?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">russellkt</media:title>
		</media:content>
	</item>
	</channel>
</rss>
