<?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>Blog &#124; Rubyyot &#187; rack</title>
	<atom:link href="http://blog.rubyyot.com/tag/rack/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.rubyyot.com</link>
	<description>Programming, Pragmatism and Getting By in the World</description>
	<lastBuildDate>Wed, 24 Mar 2010 00:14:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Building rubyyot.com from scratch with Rack and Git</title>
		<link>http://blog.rubyyot.com/2010/01/building-rubyyot-com-from-scratch-with-rack-and-git/</link>
		<comments>http://blog.rubyyot.com/2010/01/building-rubyyot-com-from-scratch-with-rack-and-git/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 04:33:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[rack]]></category>
		<category><![CDATA[rubyyot]]></category>

		<guid isPermaLink="false">http://blog.rubyyot.com/?p=695</guid>
		<description><![CDATA[2010 is here, where did the time go?
Huh?  It&#8217;s 2010?  I haven&#8217;t posted in 6 months?  What happened?
Summer of Learning Challenge
The Summer of Learning Challenge didn&#8217;t happen.  I didn&#8217;t even do it.  No excuses.  I did other things.
All is not lost
Around the end of 2009, I dusted off my [...]]]></description>
			<content:encoded><![CDATA[<h3>2010 is here, where did the time go?</h3>
<p>Huh?  It&#8217;s 2010?  I haven&#8217;t posted in 6 months?  What happened?</p>
<h3>Summer of Learning Challenge</h3>
<p>The <a href="http://blog.rubyyot.com/2009/05/summer-of-learning-challenge" target="_blank">Summer of Learning Challenge</a> didn&#8217;t happen.  I didn&#8217;t even do it.  No excuses.  I did other things.</p>
<h3>All is not lost</h3>
<p>Around the end of 2009, I dusted off my idea of creating a git based wiki like publishing portal with Rack.  I put it together in about a week or so and it&#8217;s slowly evolving and gaining some content.  It&#8217;s fun, even exciting, to bypass frameworks and DSLs and all the opinionated code and build something on the leanness that is Rack. A great learning opportunity to boot. So maybe something came of the challenge after all.</p>
<h3>Rubyyot &#8211; Rack + Git</h3>
<p>It&#8217;s up on <a href="http://www.rubyyot.com" target="_blank">rubyyot.com</a> with the <a href="http://github.com/rubyyot/rubyyot" target="_blank">source on github</a> still wonderfully rough around the edges and in need of a code review.  Ahh, to create something again.</p>
<h3>Flannel &#8211; Warm and fuzzy</h3>
<p>I made my own markup parser for this, it&#8217;s called<a title="Flannel" href="http://rubyyot.com/flannel" target="_blank"> flannel </a>and an liking it so far.  Of course it too is still in it&#8217;s infancy, but I&#8217;m not only using it to format my wiki thing, I&#8217;ve also given it a little command line attention to allow it to transform text files for my blog posts.  It&#8217;s warm, fuzzy and everything is just as I want it, and if not, I change it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rubyyot.com/2010/01/building-rubyyot-com-from-scratch-with-rack-and-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Plans for Rubyyot.com and the Summer of Learning Challenge</title>
		<link>http://blog.rubyyot.com/2009/05/summer-of-learning-challenge/</link>
		<comments>http://blog.rubyyot.com/2009/05/summer-of-learning-challenge/#comments</comments>
		<pubDate>Sun, 24 May 2009 18:17:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[rack]]></category>
		<category><![CDATA[rubyyot]]></category>
		<category><![CDATA[self-improvement]]></category>
		<category><![CDATA[summer of learning challenge]]></category>

		<guid isPermaLink="false">http://blog.rubyyot.com/?p=560</guid>
		<description><![CDATA[Plans for the future
In the past week I started playing with Rack and put together a little Rack application that generates content from my blog&#8217;s rss feed about the site.   As I stated in that post I really didn&#8217;t like having the &#8220;parked&#8221; page up there, and I also wanted to try out Rack, which [...]]]></description>
			<content:encoded><![CDATA[<h2>Plans for the future</h2>
<p>In the past week I started playing with Rack and put together a little Rack <a title="Using Rack to generate content from an rss feed" href="http://blog.rubyyot.com/2009/05/using-rack-to-generate-content-from-an-rss-feed/" target="_blank">application that generates content from my blog&#8217;s rss feed about the site</a>.   As I stated in that post I really didn&#8217;t like having the &#8220;parked&#8221; page up there, and I also wanted to try out Rack, which has gotten so much press of late.   I was very impressed with Rack, and how easy it was to put together a simple web application with it.</p>
<p>Until that point, I had used Rails, used non-Ruby web frameworks and used Ruby for other non web-based projects, but I had not created a Ruby based web application with anything other than Rails.  It was an enlightening experience.   It got me thinking about Rails, what it provides out of the box:</p>
<ul>
<li><a title="ActiveRecord" href="http://ar.rubyonrails.org/" target="_blank">ActiveRecord</a> for persistent, vendor agnostic storage and model building goodness</li>
<li>Built in support for <a title="AJAX on Rails" href="http://railsonedge.blogspot.com/2008/03/tutorial-beginning-ajax-with-rails-20.html" target="_blank">AJAX</a> and <a title="Partial views" href="http://addictedtonew.com/archives/149/a-bit-on-rails-partials/" target="_blank">partial views</a>.</li>
<li>Controllers to coordinate between them</li>
<li>Simple support for <a title="Restful Rails" href="http://www.sitepoint.com/blogs/2008/02/04/restful-rails-part-i/" target="_blank">REST</a> web services</li>
<li><a title="ActionMailer" href="http://wiki.rubyonrails.org/rails/pages/HowToSendEmailsWithActionMailer" target="_blank">ActionMailer</a> for email handling</li>
<li>Flexible <a title="Routing" href="http://api.rubyonrails.org/classes/ActionController/Routing.html" target="_blank">url routing</a></li>
<li>An active and growing community that provides a large number of useful and often cutting edge add-ons and <a title="Guides" href="http://guides.rubyonrails.org/" target="_blank">guides</a>.</li>
</ul>
<p>Additionally, many of these features are modular and can be swapped out or replaced with other modules to suit your tastes.  That is quite an impressive and list, and by no means comprehensive.  With Rails 3 on the horizon, there are even more great things on the way.   It&#8217;s no wonder, that I fell in love with Rails.</p>
<p>However, I realized that a number of things I use to develop Rails applications are not truly Rails features, but only supported by Rails.  This by no means a slight against Rails, but it is something great about Ruby and the Ruby community.   Here are some features and libraries that I make use of:</p>
<ul>
<li><a title="erb" href="http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html" target="_blank">erb</a> &#8211; Templating engine available in ruby itself.</li>
<li><a title="Rake" href="http://rake.rubyforge.org/" target="_blank">rake</a> &#8211; An essential make utility for automating reoccurring tasks.</li>
<li><a title="Test::Unit" href="http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit.html" target="_blank">Test::Unit</a> &#8211; Unit testing framework, baked into Ruby.</li>
<li><a title="Cucumber" href="http://cukes.info/" target="_blank">Cucumber</a>, <a title="RSpec intro" href="http://blog.davidchelimsky.net/2007/05/14/an-introduction-to-rspec-part-i/" target="_blank">RSpec</a> and friends &#8211; There are group of great libraries available for testing Rails and other Ruby apps.</li>
<li><a title="git" href="http://git-scm.com/" target="_blank">git</a> and <a title="Github" href="http://github.com/" target="_blank">github</a> &#8211; Fast, distributed source control and repository hosting.</li>
<li><a title="Rack" href="http://rack.rubyforge.org/" target="_blank">Rack</a> &#8211; The new hotness in standardized web server interfaces.</li>
<li><a title="Capistrano" href="http://www.capify.org/" target="_blank">Capistrano</a> &#8211; Automated deployment.</li>
<li><a title="Phusion Passenger - aka mod_rails" href="http://www.modrails.com/" target="_blank">Phusion Passenger</a> &#8211; Once called mod_rails, it is actually more than that, as it supports all Rack based applications.</li>
<li><strong>Dedication to best practices and self-improvement</strong> &#8211; While not technically a feature, it is ingrained in the Ruby and Rails communities and it&#8217;s contagious.</li>
</ul>
<p>Chances are, if you have done any Rails development you have encountered, used and enjoyed some or all of these.   My point here is not to say that Rails is only great because Ruby is great.  Rather that while Rails is awesome, there is a strong and viable codebase for building applications, web-based or otherwise, in the greater Ruby community.  The relationship between Rails and Ruby and the popularity of Rails as a framework have made both better and stronger tools.</p>
<h2>Building Cohesive Applications</h2>
<p>This relationship would not be as be strong, if Rails was<a title="Rails Myth -  Rails is a monolith" href="http://www.loudthinking.com/posts/33-myth-4-rails-is-a-monolith" target="_blank"> built as  a monolith</a>.  Instead, Rails is designed in to be modular.  The framework itself is broken up into no less than 6 gems:</p>
<pre>rubyyot@atlas:~$ jruby -S gem install rails
Successfully installed activesupport-2.3.2
Successfully installed activerecord-2.3.2
Successfully installed actionpack-2.3.2
Successfully installed actionmailer-2.3.2
Successfully installed activeresource-2.3.2
Successfully installed rails-2.3.2
6 gems installed</pre>
<p>Within that, as we saw, the standard way of building rails uses a number of other tools and libraries.  These parts are generally built to be <a title="Cohesion vs. Coupling" href="http://www.hokstad.com/why-coupling-is-always-bad-cohesion-vs-coupling.html" target="_blank">highly cohesive rather than highly coupled</a>.  This property of good design is probably best described by Uncle Bob&#8217;s <a title="S.O.L.I.D." href="http://www.lostechies.com/blogs/chad_myers/archive/2008/03/07/pablo-s-topic-of-the-month-march-solid-principles.aspx" target="_blank">SOLID principles</a>.  These are:</p>
<ul>
<li><strong><a href="http://www.objectmentor.com/resources/articles/srp.pdf">Single Responsibility Principle</a></strong>
<ul>
<li>There should never be more than one reason for a class to change</li>
</ul>
</li>
<li><strong><a href="http://www.objectmentor.com/resources/articles/ocp.pdf">Open Closed Principle</a></strong>
<ul>
<li> Software entities (classes, modules, functions, etc.) should be open for extention but closed for modification.</li>
</ul>
</li>
<li> <strong><a href="http://www.objectmentor.com/resources/articles/lsp.pdf">Liskov Substitution Principle</a></strong>
<ul>
<li>Functions that use &#8230; references to base classes must be able to use objects of derived classes without knowing it.</li>
</ul>
</li>
<li> <strong><a href="http://www.objectmentor.com/resources/articles/isp.pdf">Interface Segregation Principle</a></strong>
<ul>
<li>Clients should not be forced to depend upon interfaces that they do not use.</li>
</ul>
</li>
<li> <strong><a href="http://www.objectmentor.com/resources/articles/dip.pdf">Dependency Inversion Principle</a></strong>
<ul>
<li>High level modules should not depend on low level modules. Both should depend on abstractions.</li>
<li>Abstractions should not depend on details. Details should depend upon abstractions.</li>
</ul>
</li>
</ul>
<p>While these principles were written with less dynamic languages than Ruby in mind, such as Java and C#.  Understanding them and applying them  in any language will help you to write clean code.  Code with minimal dependencies that strangle it&#8217;s agility and make make maintenance a nightmare.  These SOLID principles also make code more modular and enable the long promised re-usability that all object-oriented programmers learn about in OO101.</p>
<h2>Ruby Web Frameworks</h2>
<p>One of the trends in the Ruby and Rails communities in the past year or two, has been the building of other web frameworks.  These were often termed micro-frameworks because they offered the ability to build ruby based web applications without having to run a full Rails stack.  The most notable of these are <a title="Merb" href="http://merbivore.com/" target="_blank">Merb</a> and <a title="Sinatra" href="http://www.sinatrarb.com/" target="_blank">Sinatra</a>.  While these began to splinter ruby based web development, my mantra for this year is:</p>
<blockquote><p>Change is good.</p></blockquote>
<p>These project went and approached the building of web applications in Ruby in different ways.  In doing so they opened up the doors to creativity and brought some improvements and  fresh ideas to the table.  The benefits of this are even now coming clear with the announcement that <a title="Merb to be merged into Rails 3" href="http://weblog.rubyonrails.org/2008/12/23/merb-gets-merged-into-rails-3" target="_blank">Merb will be merged into Rails 3</a>.  This promises to bring <a title="Rails 3 in Action" href="http://www.manning.com/katz/" target="_blank">more speed and modularity</a> to the Rails framework.</p>
<h2>Pragmatic Thinking and Learning</h2>
<p>I recently completed the book <a title="Pragmatic Thinking and Learning" href="http://www.pragprog.com/titles/ahptl/pragmatic-thinking-and-learning" target="_blank">Pragmatic Thinking and Learning</a>.  It was an excellent book that centers around bringing our innate creativity (<em>R</em>-mode) to the party to achieve goals and solve problems.  While it&#8217;s a book targeted to technical people it is not written for one specific language or even just for programmers.  It takes a number of interesting studies and theories, most notable for me is Betty Edwards&#8217; <a title="Drawing on the Right Side of the Brain" href="http://www.drawright.com/" target="_blank">Drawing on the Right Side of the Brain</a> and brings them together into a series of tips and hueristics for improving your thought processes.  It&#8217;s a very interesting book and I would recommend it to anyone interested in the topic.</p>
<h2>Rails and Lettuce</h2>
<p>In of the book, Andy Hunt is discussing personal wikis and shows a page from his WikiNotes (figure 8.3 ).  It shows a series of thoughts as follows:</p>
<blockquote>
<ul>
<li>U.S. per capita consumption of Romaine lettuce increased 162%</li>
<li>Lettuce consumption at a record High</li>
<li>Convenience of pre-washed, bagged lettuce outweighs cost.</li>
<li>MORAL: it&#8217;s got to be easy</li>
</ul>
</blockquote>
<p>I thought that this was a particularly interesting observation and in a way is a metaphor for Rails.</p>
<p>The sales of Romaine lettuce increased 162% by pre-washing and packaging it in convenient bags.   This packaging is widely popular in spite of the increased cost.  It&#8217;s clear that lettuce is a great product.  Everyone knows it&#8217;s healthy and it&#8217;s the building block of salads and great in sandwiches as well.  Still it&#8217;s popularity were greatly improved by giving it an instant, right out of the box, interface.   Similarly Ruby web frameworks are great products.  Rails packages that goodness up in an easy to learn, build and deploy.</p>
<h2>Reinventing the Wheel vs. Digging a Rut</h2>
<p><a title="Rack @ RailsGuides" href="http://rack.rubyforge.org/" target="_blank">Rails</a> is built on top of Rack.  Rack is written in <a title="Ruby" href="http://www.ruby-lang.org/en/" target="_blank">Ruby </a>and specifies the interface between the web server and the Rails framework.  In fact Merb and Sinatra are built on top of Rack as well.  Still, as we saw, Rack is available for building upon directly and of course Ruby and it&#8217;s libraries are available as well.  So why not build a Ruby web application without any framework at all?  Well the obvious answer is that you won&#8217;t have all of the nice things that these web frameworks provide.  Not to mention many of these pieces have now been used and tested by production applications for years now.  It may be a better question to ask:</p>
<blockquote><p>Why wouldn&#8217;t I want to use one of the pre-built frameworks?</p></blockquote>
<p>The answer to that question is what has been forming in my mind since I tried out Rack for the first time.</p>
<ul>
<li><strong>Frameworks remove options -</strong> Even the best framework on the planet is going to take away options.  Lean Methodologies include the idea of <a title="Delay decisions as long possible" href="http://en.wikipedia.org/wiki/Lean_software_development#Decide_as_late_as_possible" target="_blank">delaying decisions as long as possible</a> allowing for greater flexability later on.   Many times we want to use a framework, because it leave a clear path to a production ready application.  This comes at the cost of options and I don&#8217;t want these removed.</li>
<li><strong>Learning Opportunity</strong> -  Often the best way to learn something is to do it.  I&#8217;m not an expert with Rails, I still have more to learn, but I also want to learn more about writing and designing applications for the web in general.  Therefore it makes sense to bypass the framework and hook directly into Rack.</li>
<li><strong>Many libraries are still available</strong> &#8211; As we saw before, many of the tools used in the creation of Rails applications are still available for use.</li>
<li><strong>Completely Custom</strong> &#8211; I used to love watching shows like <a title="American Chopper" href="http://tlc.discovery.com/tv/american-chopper/american-chopper.html" target="_blank">American Chopper</a> and <a title="Monster Garage " href="http://en.wikipedia.org/wiki/Monster_Garage" target="_blank">Monster Garage</a> even though I know next to nothing about building a car or a bike.  The thrill was in watching highly skilled people create baddass and functional custom vehicles.  This is a similar though admittedly geekier endeavor.</li>
<li><a title="Beginner's Mind" href="http://www.ironpalm.com/beginner.html" target="_blank"><strong>Beginner&#8217;s Mind</strong></a> &#8211; This zen concept urges you to remove look at things without filtering them through your pre-conceived ideas and biases to gain greater understanding.  Approaching this project without relying on a pre-conceived framework should lead to similar results.</li>
</ul>
<p>All of these are great reasons for me to try making my own path and not generating yet another Rails application.  That&#8217;s not to say that Rails isn&#8217;t great, or I&#8217;m better than Rails.  It&#8217;s just not the right fit, right now for my project.  In the end I&#8217;d rather re-invent the wheel than dig myself into a rut.</p>
<h2>Vaporware and Playing to Learn</h2>
<p>One thing that I do when working with my personal projects is that I will have an idea and start to run with it.  After a while of working with the idea, more ideas will come and my attention will turn away from my original project and move on to other things.  Some examples of this are:</p>
<ul>
<li><a title="Resolvr" href="http://github.com/rubyyot/resolvr/tree" target="_blank">Resolvr</a> &#8211; A dependency injection mechanism for Ruby.</li>
<li><a title="Gippr" href="http://github.com/rubyyot/gippr/tree" target="_blank">Gippr</a> &#8211; A library for parsing the GIFT file format.</li>
<li><a title="RSimpy" href="http://github.com/rubyyot/rsimpy/tree" target="_blank">RSimpy</a> &#8211; A wrapper for the API to <a title="Simpy" href="http://Simpy.com" target="_blank">Simpy.com<br />
</a></li>
</ul>
<p>Will I ever get back to these and complete them?  Maybe.  Much of what I do in my personal projects is playing to learn.  Like when I was a kid and I wanted to build a giant working  robot or transformer out of legos.  Did I ever finish these projects?  No, but they were fun and I learned a number of interesting things along the way.  This is one of the great things about personal projects.  There is no one expecting you to deliver a product, so you are free to persue whatever interests you.  Even if that means that you abandon the project altogether and move on to another.</p>
<p>There is a character on the show Jimmy Neutron, that my kids watch,  called <a title="Professor Calamitous" href="http://jimmyneutron.wikia.com/wiki/Professor_Calamitous" target="_blank">Professor Calamitous</a>. He is a brilliant scientist bent on doing evil.  However, he is continually undone by his character flaw, that is that he can never finish anything.  I have often teased my wife, because she will get very excited about a project and work on it.  She won&#8217;t just do a little, but she really digs into it and attacks the subject.  After some time she will, almost overnight, lose interest and move on to something else.  I&#8217;ll tell her that her inner Professor Calamitous has struck.  In actuality, I&#8217;m just as guilty of it as she is if not more so (sorry for teasing you).</p>
<p>When viewed from a goals oriented perspective this is a horrible waste of time.  Why put all the energy into something that will be left to rot, unfinished?  From another perspective, that of a learning tool, it is a great accomplishment and a goal achieved.  The time wasn&#8217;t wasted because in doing something with the project, rather than just reading (or writing, speaking, etc.) about the topic, you develop hands on experience and engage much more of your mind (<em>R</em>-mode) than you would have otherwise.</p>
<h2>Personal Wiki</h2>
<p>Now I feel it&#8217;s my duty to bring all of these random thoughts together and issue a challenge to any out there who might be reading this.   The book, Pragmatic Thinking and Learning, recommends the use of a personal wiki to gather together your thoughts and organize them into an <a title="Exocortex" href="http://en.wikipedia.org/wiki/Exocortex" target="_blank">exocortex</a>.  I looked through all of the available wiki software out there and none of them really felt right.  That was a kind of personal decision and it&#8217;s nothing against any of the software available.  They either didn&#8217;t provide the features I wanted, or I didn&#8217;t like the look and feel.</p>
<h2>Requirements</h2>
<ul>
<li><strong>Good feel</strong> &#8211; If I&#8217;m going to do this, I will be spending a significant amount of time with it.  Any tool I will be spending that much time with, better not have annoyances, no matter how small.</li>
<li><strong>High Availability</strong> &#8211; While it may not need to be as available as a <a title="Ubiquitous Collection Tool" href="http://davecaolo.com/productivity/ubiquitous-capture-tool/" target="_blank">ubiquitous collection tool</a>, it should be available to me at work and at home, at the very least.</li>
<li><strong>Wiki Formatting </strong>- Whether via wiki markup, RedCloth or some other means it should be easy to build and grow as a wiki.  That&#8217;s kinda the point of a Personal Wiki</li>
<li><strong>Single user editing</strong> -  It may seem odd to have a wiki that is editable by a single person, but if it&#8217;s just for me, then it only makes sense.</li>
<li><strong>Public display</strong> &#8211; Some of the things I put in it would make sense to be available to others who are interested.</li>
<li><strong>Private display</strong> &#8211; Some of the things in it may be private and kept that way.</li>
<li><strong>Easy backup and recovery</strong> &#8211; If I&#8217;m going to go to all the trouble of writing and gardening a wiki, it should be safe and recoverable in the event of corruption, disaster or my own foolishness.</li>
<li><strong>Customizable</strong> &#8211; I may want to have dynamic content on some pages.  Perhaps it should pull in my bookmarks on a topic and display them with other content.</li>
</ul>
<p>That is quite a hefty list and I&#8217;m sure that there will be other things along the way that I&#8217;ll want to put in there.  It&#8217;s no wonder I couldn&#8217;t find what I wanted out of the box.</p>
<p>I&#8217;ve decided to build this directly on Rack, using git, github and other useful tools I would use in building a Rails app.  I&#8217;m not sure how this will go at this point, but it&#8217;s an exciting project and I hope to have something to show for it by the end of summer.</p>
<h2>The Summer of Learning Challenge</h2>
<p>We all have these kinds of ideas floating around in our heads, and the more creative ideas we listen to and act upon, the more will come to us.   I think that right now is a great time, as it is the beginning of Summer 2009 to act on one, or more, of these.  The summer provides a set time frame that is long enough to make something great, but short enough that we won&#8217;t put it off forever.  I think that it would be great to see others (you) find a project they are interested in a make a commitment to work on it this summer.  If you are a developer/programmer, make your project open-source.  It could be a great benefit to others.  It will defiantly be a great experience for you.</p>
<p>A few years ago I took part in and completed <a title="National Novel Writing Month" href="http://www.nanowrimo.org/" target="_blank">NaNoWriMo</a>.  My book wasn&#8217;t finished at the end, but I wrote 50,000 words of it in one month.  That was a great accomplishment for me, something that I didn&#8217;t think I could do when I started.  By setting the goal and working toward it I was able to complete it.  It felt great.  What could you do if you set your mind to it?</p>
<h2>What Will You Do?</h2>
<p>If you are interested in taking the challenge or just have an idea or a comment about mine.  Please leave feedback or blog about it yourself an leave a postback.  It&#8217;s going to be a great summer.  Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rubyyot.com/2009/05/summer-of-learning-challenge/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using Rack to generate content from an rss feed</title>
		<link>http://blog.rubyyot.com/2009/05/using-rack-to-generate-content-from-an-rss-feed/</link>
		<comments>http://blog.rubyyot.com/2009/05/using-rack-to-generate-content-from-an-rss-feed/#comments</comments>
		<pubDate>Wed, 20 May 2009 05:49:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[rack]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[rubyyot]]></category>

		<guid isPermaLink="false">http://blog.rubyyot.com/?p=544</guid>
		<description><![CDATA[The Hype
Rack is taking the Ruby and Rails worlds by storm.  It&#8217;s hard to find any recent Ruby related posts that don&#8217;t mention Rack in some way or other.  It&#8217;s obvious that Rack is here.  If you haven&#8217;t read up on it.  Jason Siefer has put together a good post full [...]]]></description>
			<content:encoded><![CDATA[<h2>The Hype</h2>
<p>Rack is taking the Ruby and Rails worlds by storm.  It&#8217;s hard to find any recent Ruby related posts that don&#8217;t mention Rack in some way or other.  It&#8217;s obvious that Rack is here.  If you haven&#8217;t read up on it.  Jason Siefer has put together a good <a href="http://jasonseifer.com/2009/04/08/32-rack-resources-to-get-you-started" title="32 Rack Resources to get you started" target="_blank">post full of links to get you started</a>.</p>
<h2>The Project</h2>
<p>
I recently killed Rubyyot.com, the GTD task management site.  It turns out that using computers to take notes just isn&#8217;t convenient.  I haven&#8217;t quite figured out what is, but I suspect that it involves pencil and paper.  In any case, I decided to take the site down since I wasn&#8217;t using it.  The site had a pretty &#8220;this domain is parked&#8221; page on it, which I wasn&#8217;t particularly fond of.</p>
<p>So to make the site more interesting, I wanted to be able to display an news items that I might have available about the domain.  However, I already have a blog, this one here.  I didn&#8217;t want to write a full rails app to post blog entries, or have yet another wordpress site.  What I wanted to be able to do was post to my blog and if the item had to do with the rubyyot domain have it show up in the page I have there as well.</p>
<p>
What I needed was a way to take an rss feed from my blog for the tag rubyyot and post the items to a page on Rubyyot.com.  That is exactly what I did in a few hours with some help from Rack.
</p>
<h2>The Host</h2>
<p>Rubyyot.com is hosted on Dreamhost which supports Passenger.  And here is one of the nice things about Rack.  Rack is a standard interface and so Passenger supports Rack. All Passenger needs to run a Rack app is a rackup file (config.ru) a public directory for css, images and other files available to the public.  Finally, it needs a file to trigger a Passenger restart, this is located at tmp/restart.txt. </p>
<p>It turns out that since Rails now runs on Rack, you can simply configure your app in the Dreamhost Webpanel as you would a Rails app.  Instead on putting the Rails app at this location, you simply put the Rack app there.  In my case I put a git repository there, though I may try to capify it in the future.</p>
<h2>The Experience</h2>
<p>All in all, it was a painless experience.  The code needs a little cleanup but it works. Dreamhost had Rack and Hpricot already installed on the server, not the current versions of the gems, but this didn&#8217;t cause an issue.  I wanted to put it out here to show how easy it can be.  In the future, I would like to use a similar technique to be able to post status or news messages to any of my sites from my blog.</p>
<h2>The Code</h2>
<p><em><strong>Note:</strong> The full code can be found <a href="http://github.com/rubyyot/rubyyot-status-rack/tree/first_post" title="rubyyot-status-rack" target="_blank">on github tagged as first_post</a></em></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#config.ru</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rack'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubyyot_status'</span>
&nbsp;
run RubyyotStatus.<span style="color:#9900CC;">new</span></pre></div></div>

<p>and</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#rubyyot_status.rb</span>
<span style="color:#9966CC; font-weight:bold;">class</span> RubyyotStatus
  <span style="color:#9966CC; font-weight:bold;">def</span> call<span style="color:#006600; font-weight:bold;">&#40;</span>env<span style="color:#006600; font-weight:bold;">&#41;</span>
    <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;">'hpricot'</span>
    <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'open-uri'</span>
&nbsp;
    <span style="color:#008000; font-style:italic;"># Setup beginning of page and initial status value</span>
    text = <span style="color:#996600;">&quot;&lt;h2&gt;Rubyyot.com is going through changes&lt;/h2&gt;&quot;</span>
    text <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;&lt;p&gt;If you are looking for my blog you can find it &lt;a href='http://blog.rubyyot.com'&gt;here&lt;/a&gt;&lt;p&gt;&quot;</span>
    text <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;&lt;h3&gt;Latest Updates&lt;/h3&gt;&lt;ul&gt;&quot;</span>
&nbsp;
    css = <span style="color:#996600;">'&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/rubyyot.css&quot; /&gt;'</span>
    response_body = <span style="color:#996600;">&quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;Rubyyot&lt;/title&gt;&lt;/head&gt;#{css}&lt;body&gt;#{text}&quot;</span>
    status = <span style="color:#996600;">&quot;200&quot;</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">begin</span>
      <span style="color:#008000; font-style:italic;"># read rss feed</span>
      doc = Hpricot.<span style="color:#9900CC;">XML</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;http://blog.rubyyot.com/tag/rubyyot/feed/rss&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
      <span style="color:#006600; font-weight:bold;">&#40;</span>doc<span style="color:#006600; font-weight:bold;">/</span><span style="color:#996600;">&quot;item&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>item<span style="color:#006600; font-weight:bold;">|</span>
	<span style="color:#008000; font-style:italic;"># get link, description and title from feed</span>
	link = <span style="color:#006600; font-weight:bold;">&#40;</span>item<span style="color:#006600; font-weight:bold;">/</span><span style="color:#996600;">&quot;link&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">inner_html</span>
	description = <span style="color:#006600; font-weight:bold;">&#40;</span>item<span style="color:#006600; font-weight:bold;">/</span><span style="color:#996600;">&quot;description&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">inner_html</span>
	title = <span style="color:#006600; font-weight:bold;">&#40;</span>item<span style="color:#006600; font-weight:bold;">/</span><span style="color:#996600;">&quot;title&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">inner_html</span>
&nbsp;
	<span style="color:#008000; font-style:italic;"># add each post to page</span>
	response_body <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;&lt;li&gt;&lt;h4&gt;&lt;a href='#{link}'&gt;#{title}&lt;a&gt;&lt;/h4&gt;#{description}&lt;/li&gt;&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">rescue</span>
      status = <span style="color:#996600;">&quot;500&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#008000; font-style:italic;"># finish off page</span>
    response_body <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;&lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;&quot;</span>
&nbsp;
    <span style="color:#008000; font-style:italic;"># add headers</span>
    headers = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
    headers<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;Content-Length&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = response_body.<span style="color:#9900CC;">length</span>.<span style="color:#9900CC;">to_s</span>
    headers<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;Content-Type&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;text/html&quot;</span>
&nbsp;
    <span style="color:#008000; font-style:italic;"># return values</span>
    <span style="color:#006600; font-weight:bold;">&#91;</span>status, headers, response_body<span style="color:#006600; font-weight:bold;">&#93;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<h2>See it in action</h2>
<p>Working version (at least for now) is at <a href="http://www.rubyyot.com" title="Rubyyot" target="_blank">Rubyyot.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rubyyot.com/2009/05/using-rack-to-generate-content-from-an-rss-feed/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
