<?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>ijonas.com &#187; apache</title>
	<atom:link href="http://ijonas.com/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://ijonas.com</link>
	<description>Habitual Ramblings of an Indiginous Ijonous</description>
	<lastBuildDate>Mon, 02 Jan 2012 15:12:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Barbler: Integrating JRuby Warbler into Apache Builder</title>
		<link>http://ijonas.com/software-development/ruby/319/</link>
		<comments>http://ijonas.com/software-development/ruby/319/#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 &#8230; <a href="http://ijonas.com/software-development/ruby/319/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></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>
<pre lang="ruby"># Barbler
# is an Apache Builder extension to integrate the JRuby Warbler gem.
# For tips on how to use Barbler checkout http://www.denofubiquity.com/ruby/barbler/
#
# This code is licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.txt)
# Please distribute Barbler code with this code intact.
# (c) Ijonas Kisselbach 2009

require 'warbler'

module Barbler
  include Extension

  first_time do
    # Define task not specific to any projet.
    desc 'Warbles Rails sourcecode tree into a staging folder'
    Project.local_task('warble' => 'build') { |name| "Warbling #{name}" }
  end

  before_define do |project|
    project.task('warble'=>project.task('build'))
    project.group ||= project.parent &#038;&#038; project.parent.group || project.name
    project.version ||= project.parent &#038;&#038; project.parent.version
  end

  # To use this method in your project:
  #   warble(:rails => path_to(:rails), :tasks => [:app, :public])
  def warble(*args)
    options = args.pop
    rails_path = options[:rails]
    warble_tasks = options[:tasks]

    # Define the warble task for this particular project.
    Rake::Task.define_task 'warble' do |task|
      # get all the important components from the Rails GUI into the staging directory
      puts "Warbling #{rails_path}"
      Dir.chdir(rails_path) do
        warble_cfg = eval(File.open("config/warble.rb") {|f| f.read})
        Warbler::Task.new(:war, warble_cfg)
        warble_tasks.each {|task| Rake::Task["war:#{task}"].invoke}
      end
    end
  end

end

class Buildr::Project
  include Barbler
end</pre>
<p>Add the folllowing line to the top of your buildfile:</p>
<pre lang="ruby">warble(:rails => path_to(:rails), :tasks => [:app, :public])</pre>
<p>You can then define your warble task using the following line</p>
<pre lang="ruby">warble(:rails => path_to(:rails), :tasks => [:app, :public])</pre>
<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>
<pre lang="ruby">warble(:rails => path_to(:source, :main, :rails), :tasks => [:app, :public])</pre>
<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>
<div style="padding-top:5px;padding-right:0px;padding-bottom:5px;padding-left:0px;;">
											<iframe
												style="height:25px !important; border:0px solid gray !important; overflow:hidden !important; width:460px !important;" frameborder="0" scrolling="no" allowTransparency="true"
												src="http://www.linksalpha.com/social?blog=ijonas.com&link=http%3A%2F%2Fijonas.com%2Fsoftware-development%2Fruby%2F319%2F&title=Barbler%3A+Integrating+JRuby+Warbler+into+Apache+Builder&desc=After+having+used+Apache+Builder+for+a+week+and+extracted+our+Warbler-code+into+a+bonafide+extension%2C+I%27m+sharing+it+with+the+community+under+the+fetching+name+Barbler.%0A%0ABarbler+integrates+itself+betw&fc=333333&fs=arial&fblname=like&fblref=facebook&fbllang=en_US&fblshow=1&fbsbutton=0&fbsctr=1&fbslang=en&fbsendbutton=0&twbutton=1&twlang=en&twmention=ijonas&twrelated1=&twrelated2=&twctr=1&lnkdshow=noshow&lnkdctr=1&buzzbutton=0&buzzlang=en&buzzctr=1&diggbutton=1&diggctr=1&stblbutton=1&stblctr=1&g1button=1&g1ctr=1&g1lang=en-US">
											</iframe>
										</div>]]></content:encoded>
			<wfw:commentRss>http://ijonas.com/software-development/ruby/319/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CouchDB Presentation at Railscamp UK</title>
		<link>http://ijonas.com/software-development/108/</link>
		<comments>http://ijonas.com/software-development/108/#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, &#8230; <a href="http://ijonas.com/software-development/108/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></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>
<pre lang="ruby">require 'rubygems'
require 'httparty'
require 'json/pure'
require 'find'

class CouchHack
  include HTTParty
  base_uri 'http://127.0.0.1:5984'
  format :json

  def update( path, document )
    options = { :body => JSON.generate(document) }
    puts self.class.put(path, options )
  end

  def get(path)
    self.class.get(path)
  end

  def create(db_path, document )
    options = { :body => JSON.generate(document) }
    self.class.post(db_path, options )
  end

  def define_view(db_path, design_doc_name, views )
    document = { "views" => views }
    options = { :body => JSON.generate(document) }
    self.class.put("#{db_path}/_design/#{design_doc_name}", options)
  end
end</pre>
<p>Once that&#8217;s in place you can use the CouchHack class by defining a view like so:</p>
<pre lang="ruby">ch = CouchHack.new
gem_views = {
  "small_gems" =>
    {
      "map" => "function(doc) { if (doc.length < 3000) emit(doc.path, doc) }",
    },
  "large_gems" =>
    {
      "map" => "function(doc) { if (doc.length > 3000) emit(doc.path, doc) }",
    }
}
ch.define_view("/railscamp", "gems", gem_views)</pre>
<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>
<pre lang="ruby">Find.find('/Library/Ruby/Gems/1.8/gems/' ) do |f|
  if File.file?(f) and f.ends_with?('.rb' )
    begin
      gem_contents = IO.read(f)
      gem_document = { "path" => f, "length" => gem_contents.length, "content" => gem_contents }
      ch.create( "/railscamp", gem_document )
    rescue Exception => bang
      puts "Skipping #{f}"
    end
  end
end</pre>
<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>
<div style="padding-top:5px;padding-right:0px;padding-bottom:5px;padding-left:0px;;">
											<iframe
												style="height:25px !important; border:0px solid gray !important; overflow:hidden !important; width:460px !important;" frameborder="0" scrolling="no" allowTransparency="true"
												src="http://www.linksalpha.com/social?blog=ijonas.com&link=http%3A%2F%2Fijonas.com%2Fsoftware-development%2F108%2F&title=CouchDB+Presentation+at+Railscamp+UK&desc=I%27ve+been+playing+around+with+and+kicking+the+tyres+of+CouchDB+for+a+couple+of+weeks+and+I%27m+truly+excited+about+the+project.+If+I+was+to+use+tags+to+describe+CouchDB+I%27d+use+the+following%3A%0A%0Aapache%2C+o&fc=333333&fs=arial&fblname=like&fblref=facebook&fbllang=en_US&fblshow=1&fbsbutton=0&fbsctr=1&fbslang=en&fbsendbutton=0&twbutton=1&twlang=en&twmention=ijonas&twrelated1=&twrelated2=&twctr=1&lnkdshow=noshow&lnkdctr=1&buzzbutton=0&buzzlang=en&buzzctr=1&diggbutton=1&diggctr=1&stblbutton=1&stblctr=1&g1button=1&g1ctr=1&g1lang=en-US">
											</iframe>
										</div>]]></content:encoded>
			<wfw:commentRss>http://ijonas.com/software-development/108/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

