<?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>Den Of Ubiquity &#187; apache</title>
	<atom:link href="http://www.denofubiquity.com/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.denofubiquity.com</link>
	<description>Buzzword-enriched Software Development Content</description>
	<lastBuildDate>Sun, 27 Sep 2009 20:10:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Barbler: Integrating JRuby Warbler into Apache Builder</title>
		<link>http://www.denofubiquity.com/ruby/barbler/</link>
		<comments>http://www.denofubiquity.com/ruby/barbler/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 21:54:14 +0000</pubDate>
		<dc:creator>ijonas</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[buildr]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[war]]></category>
		<category><![CDATA[warbler]]></category>

		<guid isPermaLink="false">http://www.denofubiquity.com/?p=319</guid>
		<description><![CDATA[After having used Apache Builder for a week and extracted our Warbler-code into a bonafide extension, I&#8217;m sharing it with the community under the fetching name Barbler.
Barbler integrates itself between the build and packaging stages of the Apache Builder lifecycle and makes calls into Warbler to automate WAR-file creation. Now Warbler does a really good [...]]]></description>
			<content:encoded><![CDATA[<p>After having used Apache Builder for a week and extracted our Warbler-code into a bonafide extension, I&#8217;m sharing it with the community under the fetching name <strong>Barbler</strong>.</p>
<p>Barbler integrates itself between the build and packaging stages of the Apache Builder lifecycle and makes calls into Warbler to automate WAR-file creation. Now Warbler does a really good job for packaging standalone Rails apps. Unfortunately I needed something more integrated into our application build process, that pulls in our Spring Framework-based Java code, Scala code, and Rails application and produces a single WAR-file containing all dependent libraries, Rails code, XML deployment descriptors and Java class files. Apache Builder does everything other than the Rails-packaging. Barbler steps to provide that missing step.</p>
<p>Create a barbler.rb file in your project folder, which also contains your buildfile and copy the following contents into it:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Barbler </span>
<span style="color:#008000; font-style:italic;"># is an Apache Builder extension to integrate the JRuby Warbler gem.</span>
<span style="color:#008000; font-style:italic;"># For tips on how to use Barbler checkout http://www.denofubiquity.com/ruby/barbler/</span>
<span style="color:#008000; font-style:italic;"># </span>
<span style="color:#008000; font-style:italic;"># This code is licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.txt)</span>
<span style="color:#008000; font-style:italic;"># Please distribute Barbler code with this code intact.</span>
<span style="color:#008000; font-style:italic;"># (c) Ijonas Kisselbach 2009</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'warbler'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">module</span> Barbler
  <span style="color:#9966CC; font-weight:bold;">include</span> Extension
&nbsp;
  first_time <span style="color:#9966CC; font-weight:bold;">do</span>
    <span style="color:#008000; font-style:italic;"># Define task not specific to any projet.</span>
    desc <span style="color:#996600;">'Warbles Rails sourcecode tree into a staging folder'</span>
    Project.<span style="color:#9900CC;">local_task</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'warble'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'build'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>name<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#996600;">&quot;Warbling #{name}&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>   
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  before_define <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>project<span style="color:#006600; font-weight:bold;">|</span>    
    project.<span style="color:#9900CC;">task</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'warble'</span><span style="color:#006600; font-weight:bold;">=&gt;</span>project.<span style="color:#9900CC;">task</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'build'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    project.<span style="color:#9900CC;">group</span> <span style="color:#006600; font-weight:bold;">||</span>= project.<span style="color:#9900CC;">parent</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> project.<span style="color:#9900CC;">parent</span>.<span style="color:#9900CC;">group</span> <span style="color:#006600; font-weight:bold;">||</span> project.<span style="color:#9900CC;">name</span>
    project.<span style="color:#9900CC;">version</span> <span style="color:#006600; font-weight:bold;">||</span>= project.<span style="color:#9900CC;">parent</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> project.<span style="color:#9900CC;">parent</span>.<span style="color:#9900CC;">version</span>    
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># To use this method in your project:</span>
  <span style="color:#008000; font-style:italic;">#   warble(:rails =&gt; path_to(:rails), :tasks =&gt; [:app, :public])</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> warble<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">*</span>args<span style="color:#006600; font-weight:bold;">&#41;</span>
    options = args.<span style="color:#9900CC;">pop</span>
    rails_path = options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:rails</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    warble_tasks = options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:tasks</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
    <span style="color:#008000; font-style:italic;"># Define the warble task for this particular project.</span>
    <span style="color:#6666ff; font-weight:bold;">Rake::Task</span>.<span style="color:#9900CC;">define_task</span> <span style="color:#996600;">'warble'</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>task<span style="color:#006600; font-weight:bold;">|</span>
      <span style="color:#008000; font-style:italic;"># get all the important components from the Rails GUI into the staging directory</span>
      <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Warbling #{rails_path}&quot;</span>
      <span style="color:#CC00FF; font-weight:bold;">Dir</span>.<span style="color:#9900CC;">chdir</span><span style="color:#006600; font-weight:bold;">&#40;</span>rails_path<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
        warble_cfg = <span style="color:#CC0066; font-weight:bold;">eval</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;config/warble.rb&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span> f.<span style="color:#9900CC;">read</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#6666ff; font-weight:bold;">Warbler::Task</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:war</span>, warble_cfg<span style="color:#006600; font-weight:bold;">&#41;</span>
        warble_tasks.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>task<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#6666ff; font-weight:bold;">Rake::Task</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;war:#{task}&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">invoke</span><span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#6666ff; font-weight:bold;">Buildr::Project</span>
  <span style="color:#9966CC; font-weight:bold;">include</span> Barbler
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Add the folllowing line to the top of your buildfile:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">warble<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:rails</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> path_to<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:rails</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#ff3333; font-weight:bold;">:tasks</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#ff3333; font-weight:bold;">:public</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>You can then define your warble task using the following line</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">warble<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:rails</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> path_to<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:rails</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#ff3333; font-weight:bold;">:tasks</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#ff3333; font-weight:bold;">:public</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p> whereby the first parameter is a path string to where your Rails code is located. You may locate your code in src/main/rails in which case you&#8217;d use</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">warble<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:rails</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> path_to<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:source</span>, <span style="color:#ff3333; font-weight:bold;">:main</span>, <span style="color:#ff3333; font-weight:bold;">:rails</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#ff3333; font-weight:bold;">:tasks</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#ff3333; font-weight:bold;">:public</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>The second parameter is the list of Warbler tasks that you&#8217;d like to have executed. See the Warbler documentation for more help, or check out the Warbler source code &#8211; it&#8217;s very readable.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.denofubiquity.com/ruby/barbler/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CouchDB Presentation at Railscamp UK</title>
		<link>http://www.denofubiquity.com/software-development/couchdb-presentation-at-railscamp-uk/</link>
		<comments>http://www.denofubiquity.com/software-development/couchdb-presentation-at-railscamp-uk/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 21:29:27 +0000</pubDate>
		<dc:creator>ijonas</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[addressability]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[documents]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[horizontal scaling]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[metadata]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://ijonas.wordpress.com/?p=108</guid>
		<description><![CDATA[I&#8217;ve been playing around with and kicking the tyres of CouchDB for a couple of weeks and I&#8217;m truly excited about the project. If I was to use tags to describe CouchDB I&#8217;d use the following:
apache, opensource, documents, metadata, database, json, javascript, REST, addressability, horizontal scaling, erlang.
So I found myself at Railscamp UK on the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing around with and kicking the tyres of CouchDB for a couple of weeks and I&#8217;m truly excited about the project. If I was to use tags to describe CouchDB I&#8217;d use the following:</p>
<p><code>apache, opensource, documents, metadata, database, json, javascript, REST, addressability, horizontal scaling, erlang.</code></p>
<p>So I found myself at Railscamp UK on the weekend without a ruby+rails topic to really talk about during the presentations part of the camp. I&#8217;m still a noob wrt. Rails, you see. Realising that CouchDB is relevant to most web developers because most developers deal with document-based content at some point and that Ruby, Rails, and Erlang are kindda like the current bratpack (<a href="http://en.wikipedia.org/wiki/John_Hughes_(film_director)">in a John Hughes-sense</a>) of computer languages, I thought it would be a great little topic for a 15-minute presentation.</p>
<p>So I thought I share the slides and some of the code I hacked up on the weekend. First of all the slides&#8230;</p>
<p style="text-align:center;"><a href="http://www.scribd.com/doc/4916889/CouchDB-Railscamp-UK"><img class="aligncenter size-medium wp-image-113" src="http://ijonas.files.wordpress.com/2008/08/couchdb_slides.png?w=300" alt="" width="300" height="225" /></a></p>
<p style="text-align:center;"><a href="http://www.scribd.com/doc/4916889/CouchDB-Railscamp-UK" target="_blank">(click me)</a></p>
<p>You can play about with some sample code that was expanded upon after the presentation. Here&#8217;s a little helper class to interface into CouchDB using JSON and HTTP:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'httparty'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'json/pure'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'find'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> CouchHack
  <span style="color:#9966CC; font-weight:bold;">include</span> HTTParty
  base_uri <span style="color:#996600;">'http://127.0.0.1:5984'</span>
  <span style="color:#CC0066; font-weight:bold;">format</span> <span style="color:#ff3333; font-weight:bold;">:json</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> update<span style="color:#006600; font-weight:bold;">&#40;</span> path, document <span style="color:#006600; font-weight:bold;">&#41;</span>
    options = <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:body</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> JSON.<span style="color:#9900CC;">generate</span><span style="color:#006600; font-weight:bold;">&#40;</span>document<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9966CC; font-weight:bold;">class</span>.<span style="color:#9900CC;">put</span><span style="color:#006600; font-weight:bold;">&#40;</span>path, options <span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> get<span style="color:#006600; font-weight:bold;">&#40;</span>path<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9966CC; font-weight:bold;">class</span>.<span style="color:#9900CC;">get</span><span style="color:#006600; font-weight:bold;">&#40;</span>path<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> create<span style="color:#006600; font-weight:bold;">&#40;</span>db_path, document <span style="color:#006600; font-weight:bold;">&#41;</span>
    options = <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:body</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> JSON.<span style="color:#9900CC;">generate</span><span style="color:#006600; font-weight:bold;">&#40;</span>document<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9966CC; font-weight:bold;">class</span>.<span style="color:#9900CC;">post</span><span style="color:#006600; font-weight:bold;">&#40;</span>db_path, options <span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> define_view<span style="color:#006600; font-weight:bold;">&#40;</span>db_path, design_doc_name, views <span style="color:#006600; font-weight:bold;">&#41;</span>
    document = <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;views&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> views <span style="color:#006600; font-weight:bold;">&#125;</span>
    options = <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:body</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> JSON.<span style="color:#9900CC;">generate</span><span style="color:#006600; font-weight:bold;">&#40;</span>document<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9966CC; font-weight:bold;">class</span>.<span style="color:#9900CC;">put</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;#{db_path}/_design/#{design_doc_name}&quot;</span>, options<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Once that&#8217;s in place you can use the CouchHack class by defining a view like so:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">ch = CouchHack.<span style="color:#9900CC;">new</span>
gem_views = <span style="color:#006600; font-weight:bold;">&#123;</span>
  <span style="color:#996600;">&quot;small_gems&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span>
    <span style="color:#006600; font-weight:bold;">&#123;</span>
      <span style="color:#996600;">&quot;map&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;function(doc) { if (doc.length &lt; 3000) emit(doc.path, doc) }&quot;</span>,
    <span style="color:#006600; font-weight:bold;">&#125;</span>,
  <span style="color:#996600;">&quot;large_gems&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span>
    <span style="color:#006600; font-weight:bold;">&#123;</span>
      <span style="color:#996600;">&quot;map&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;function(doc) { if (doc.length &gt; 3000) emit(doc.path, doc) }&quot;</span>,
    <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span>
ch.<span style="color:#9900CC;">define_view</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;/railscamp&quot;</span>, <span style="color:#996600;">&quot;gems&quot;</span>, gem_views<span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>This design document, as is its known in CouchDB parleance, defines two views (think &#8216;baked queries&#8217;), to return a list of small gems &#8211; those less than 3000 bytes &#8211; and a list of large gems &#8211; those larger than 3000 bytes.</p>
<p>So where do these gems come from and how do they end up in CouchDB ? That&#8217;s what the next and last little fragment of Ruby code does.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">Find</span>.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'/Library/Ruby/Gems/1.8/gems/'</span> <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span>
  <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">file</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>f<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">and</span> f.<span style="color:#9900CC;">ends_with</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'.rb'</span> <span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">begin</span>
      gem_contents = <span style="color:#CC00FF; font-weight:bold;">IO</span>.<span style="color:#9900CC;">read</span><span style="color:#006600; font-weight:bold;">&#40;</span>f<span style="color:#006600; font-weight:bold;">&#41;</span>
      gem_document = <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;path&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> f, <span style="color:#996600;">&quot;length&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> gem_contents.<span style="color:#9900CC;">length</span>, <span style="color:#996600;">&quot;content&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> gem_contents <span style="color:#006600; font-weight:bold;">&#125;</span>
      ch.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#996600;">&quot;/railscamp&quot;</span>, gem_document <span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#CC00FF; font-weight:bold;">Exception</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> bang
      <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Skipping #{f}&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>So what happens is that the last little fragment traverses the filesystem starting at /Library/Ruby/Gems/1.8/gems/ and looks for *.rb files. When it finds one it POSTs that whole document including the file length to CouchDB, where it becomes part of the resultset of one of the pre-defined views. These views can be accessed through the following two URLs (assuming the &#8216;railscamp&#8217; DB was used).</p>
<ul>
<li><a href="http://localhost:5984/railscamp/_view/gems/large_gems">http://localhost:5984/railscamp/_view/gems/large_gems</a></li>
<li><a href="http://localhost:5984/railscamp/_view/gems/small_gems">http://localhost:5984/railscamp/_view/gems/small_gems</a></li>
</ul>
<p>Feel free to post comments and ask questions.</p>
<p>Enjoy.</p>
<p>P.S. and if you get a chance to go to a *camp conference, GO! They&#8217;re an amazing format and you&#8217;ll learn soooo much!.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.denofubiquity.com/software-development/couchdb-presentation-at-railscamp-uk/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
