<?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>xambr::blog &#187; web</title>
	<atom:link href="http://blog.xambr.com/tag/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.xambr.com</link>
	<description>crafting my thoughts</description>
	<lastBuildDate>Tue, 20 Jul 2010 18:57:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Getting Classy with Sinatra</title>
		<link>http://blog.xambr.com/2009/04/07/getting-classy-with-sinatra/</link>
		<comments>http://blog.xambr.com/2009/04/07/getting-classy-with-sinatra/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 00:05:59 +0000</pubDate>
		<dc:creator>max.rb</dc:creator>
				<category><![CDATA[Discoveries]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sinatra]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.xambr.com/?p=85</guid>
		<description><![CDATA[I had heard about the Sinatra Ruby web DSL a while back but I had not had a chance to play with it until a few days ago. I&#8217;m happy to say it was a highly enjoyable experience. I accomplished what I was trying to do very quickly thanks to the good documentation and intuitive [...]]]></description>
			<content:encoded><![CDATA[<p>I had heard about the <a href="http://www.sinatrarb.com/" target="_blank">Sinatra</a> <a href="http://www.ruby-lang.org/en/" target="_blank">Ruby</a> web DSL a while back but I had not had a chance to play with it until a few days ago. I&#8217;m happy to say it was a highly enjoyable experience. I accomplished what I was trying to do very quickly thanks to the good documentation and intuitive interface. It is not a replacement for MVC frameworks such as <a href="http://rubyonrails.org/" target="_blank">Rails</a>, <a href="http://merbivore.com/" target="_blank">Merb</a>, <a href="http://ramaze.net/" target="_blank">Ramaze</a>, etc but it certainly compliments them.</p>
<h2>Sinatra Features</h2>
<p>The <a href="http://www.sinatrarb.com/intro.html">Sinatra README</a> is a great resource for getting a run down of its features and I&#8217;m not going to regurgitate it here. However, I&#8217;d like to whet your appetite with a few of the features that caught my eye when I first scoped it out.</p>
<h3>Rides on Rack</h3>
<p><a href="http://www.sinatrarb.com/" target="_blank">Sinatra</a> rides on <a href="http://rack.rubyforge.org/" target="_blank">Rack</a> and thus supports a wide variety of handlers such as: <a href="http://code.macournoyer.com/thin/" target="_blank">Thin</a>, <a href="http://mongrel.rubyforge.org/" target="_blank">Mongrel</a>, <a href="http://www.modrails.com/" target="_blank">Phusion Passenger</a>, etc (a full list is available on the <a href="http://rack.rubyforge.org/" target="_blank">Rack</a> website). It can also be used to develop <a href="http://rack.rubyforge.org/" target="_blank">Rack</a> middleware. More information about this is available on the <a href="http://www.sinatrarb.com/intro.html">README</a>. If you&#8217;re interested in Rack middleware in general, <a href="http://blog.joncrosby.me/" target="_blank">Jon Crosby</a> gave a great <a href="http://mwrc2009.confreaks.com/13-mar-2009-11-05-in-a-world-of-middleware-who-needs-monolithic-applications-jon-crosby.html" target="_blank">intro</a> at the <a href="http://mwrc2009.confreaks.com/index.html" target="_blank">Moutain West Ruby Conf 2009</a>.</p>
<h3>Flexible Routing</h3>
<p>The routing in <a href="http://www.sinatrarb.com/" target="_blank">Sinatra</a> is powerful, supporting RESTful actions, named parameters, regular expressions, splats and user agents. See the Gist bellow for an example. The <a href="http://www.sinatrarb.com/intro.html">README</a> page describes these options in more detail.<br />
<script src="http://gist.github.com/91271.js"></script></p>
<h3>View/Template Support</h3>
<p>There are a host of template options available when using <a href="http://www.sinatrarb.com/" target="_blank">Sinatra</a>. Currently it supports <a href="http://haml.hamptoncatlin.com/docs/rdoc/classes/Haml.html" target="_blank">HAML</a>, <a href="http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/" target="_blank">ERB</a>, <a href="http://builder.rubyforge.org/" target="_blank">Builder</a> and <a href="http://haml.hamptoncatlin.com/docs/rdoc/classes/Sass.html" target="_blank">SASS</a> and automatic layout templates (provided you give it a &#8220;layout&#8221; template to work with). Again, checkout the <a href="http://www.sinatrarb.com/intro.html">README</a> page for more details.</p>
<h2>My Impressions</h2>
<p>What struck me while I was working with <a href="http://www.sinatrarb.com/" target="_blank">Sinatra</a> was how light it was and how out of the way it stayed. It was only present when I needed it to do something — outside of that, it let me build what I wanted, how I wanted. If <a href="http://rubyonrails.org/" target="_blank">Rails</a> is the web developer&#8217;s assembly line then <a href="http://www.sinatrarb.com/" target="_blank">Sinatra</a> is their essential toolkit — one drives you and the other is driven by you.</p>
<p>While having a pre-baked MVC web framework such as <a href="http://rubyonrails.org/" target="_blank">Rails</a> and <a href="http://merbivore.com/" target="_blank">Merb</a> is great, it does lock you in to one way of thinking about web development. With <a href="http://www.sinatrarb.com/" target="_blank">Sinatra</a> you have the freedom to dabble and experiment — and I don&#8217;t think that can ever be a bad thing.</p>
<h2>Resources</h2>
<p>Here are some resources that I found to be useful in my first adventure with <a href="http://www.sinatrarb.com/" target="_blank">Sinatra</a>.</p>
<ul>
<li><a href="http://www.sinatrarb.com/intro.html" target="_blank">README</a></li>
<li><a href="http://www.sinatrarb.com/api/" target="_blank">API</a></li>
<li><a href="http://www.sinatrarb.com/documentation.html" target="_blank">Official Documentation Page</a></li>
<li><a href="http://www.modrails.com/documentation/Users%20guide.html" target="_blank">Sinatra on Apache + Phusion Passenger</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.xambr.com/2009/04/07/getting-classy-with-sinatra/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
