Want to stay on top? Ruby Weekly is a once-weekly e-mail newsletter covering the latest Ruby and Rails news.
     Feed Icon

Pancake: How To Stack and Loosely Couple Rack-Based Webapps Together

By grantmichaels / December 4, 2009

stack-o-pancakesMuch of Merb's momentum has been merged into Rails 3, but one-time Engine Yard developer Daniel Neighman has found himself moving in a new direction, inspired by what they had once achieved with Merb Slices. Since then, he's taken fully-mountable Rack applications to the extreme in creating Pancake, a tool & framework to let you stack and loosely couple Rack-based webapps.

Daniel states that web "applications should be self contained rack applications, able to function as gems, able to pick up an entire application and mount it inside another, able to inherit the whole application and take care of the low level plumbing," and also "let you create your own type of application when required." Pancake achieves this by building upon some excellent existing projects, including Tilt for templating, Usher for routing, and Hashie to extend the features of Ruby's hashes and give them additional object-like functionality.

Joining Apps With Rails (And Each Other..)

Yehuda Katz was first seen using Usher in his blog entry How to Build Sinatra in Rails 3 and it is being used for developing Pancake guaranteeing that anything you build with it is going to be mountable in Rails 3. Pancake stacks can be used with the current versions of Rails via Metal, and examples are given on Pancake's blog for doing so.

Sinatra apps are mountable through Pancake, as are any other fully Rack-compliant parts, and Rack middleware can be applied to either the entire Pancake stack, or to individual stacks within the container app. One can first make gems of stacks, which can then be inherited by their containing app or stack. While this sounds like it could become messy quickly, Pancake employs namespacing to keep everything distinct.

Installation and Usage

To get started with Pancake, I ended up installing via:

sudo gem install usher rake pancake haml rcov rack-test rspec racksh

I then created a stack by issuing:

sudo pancake-gen short ri_example    ## pancake-gen {short || micro} 

To move further, check out two projects: Pancake Blog (mountable basic blogging) and CouchDB Proxy (mountable couchdb proxy)

Comments

  1. Mat Schaffer says:

    I think this makes http://www.nerdmeritbadges.com/products/06-full-stack-web-developer all the more relevant.

  2. Botanicus says:

    BTW Rango has mentioned usher as a default router and mountable apps via pancake is coming in 0.3 release next January.

Other Posts to Enjoy

Twitter Mentions