public
Description: Stackem Up!
Homepage: http://pancakestacks.wordpress.com
Clone URL: git://github.com/hassox/pancake.git
name age message
file .gitignore Sat Sep 19 05:55:54 -0700 2009 Adds the tmp directories fo the generators [hassox]
file LICENSE Sat Aug 01 08:14:24 -0700 2009 Fixes some bugs with my Yard dox [hassox]
file MIDDLEWARE_LIST Sun Jun 07 06:04:47 -0700 2009 Adds mappable middleware to stacks and pancake [hassox]
file README.textile Mon Aug 03 13:44:28 -0700 2009 still trying.. [glenndavy]
file Rakefile Sat Sep 19 05:44:17 -0700 2009 updates to use jeweler [hassox]
file TODO Thu Oct 08 23:32:59 -0700 2009 Borrows the logger from merb and installs it as... [hassox]
file VERSION Loading commit data...
directory bin/ Sun Oct 04 12:50:02 -0700 2009 Bit of a tidy up [hassox]
directory example/ Thu Jul 23 15:09:19 -0700 2009 Added first draft of readme [glenndavy]
directory lib/
file pancake.gemspec
directory spec/ Mon Oct 12 13:05:45 -0700 2009 Updates view context with the request helper a... [hassox]
README.textile

This read me is getting thrown to get there in little bits of time snatched between other bits of snatched time… it will be magnificient, eventually… please bare with it…

Whats this then

A tool for making pancake stacks. Where, as you know, pancake == ruby web thing.

It essentially takes the awesome rack and rack router and mixes it with flour and water and eggs to bind it together into a pancake thin layer of goodness providing a structured way of orgnaising (stacking) your assortment of ruby web things. In doing so, it allows you to provide each of your ruby web things (lets call them “middlewares”) with some underlying contextual functionality.

Why stack pancakes?

Well, simply put, reuse! I’m building something… and what do you know i need another forum/asset manager/bla thing etc. Typically I can:

  • Write/include the functionality directly in to my current app.
  • Add a second app, theme it up similarly and use apache/nginx/other configs to glue it up, and perhaps come up with a devious approach for auth with some cunning SSO… or not

What we’d like to facilitate with pancake is you take your existing much loved forum/asset manager/bla thing etc and mount it into pancake, sharing auth and other contextual information between apps.

Insert helpful diagram here…

Getting Started

You’ll need to have installed (as well as your usual ruby stuffs)…

  • wycats-thor
  • Carllerches rack router

Installing

  $sudo gem install hassox-pancake

Create your own stack

  $pancake-gen stack yummy-app

Does it work?

(I’ve used curl here, feel free to use your point your browser to http://localhost:9292/ instead)


$cd yummy-app/lib/yummy-app
$rackup config.ru
Loading Development Environment

Now in your browser, visit http://localhost:9292/
Or, with curl like here:


$curl -I localhost:9292
127.0.0.1 – - [26/Jul/2009 15:42:55] “HEAD / HTTP/1.1” 404 9 0.0011
HTTP/1.1 404 Not Found
Connection: close
Date: Sun, 26 Jul 2009 05:42:55 GMT
Content-Type: text/plain
Content-Length: 9

You should see ‘NOT FOUND’ in your browser window and something like this appear in your rackup console window.

  127.0.0.1 - - [26/Jul/2009 15:42:55] "GET / HTTP/1.1" 404 9 0.0011

That 404 is good news! The stack is running.. we just haven’t cooked any pancakes yet, theres nothing to find. Next step add something…

Routing

Edit config/router.rb with:


home = lambda {|e| [200,{"Content-Type" => “text/plain”, “Content-Length” => "12"}, “Welcome home” ]}

YummyApp.add_routes do |r| r.map “/”, :to => home end


Now, restart the server (^C) and try again:

$rackup config.ru
Loading Development Environment

Reload you page and you should see “Welcome home”.
And, in your console window, rack should log the request like so:

127.0.0.1 – - [26/Jul/2009 16:16:23] “GET / HTTP/1.1” 200 12 0.0012
127.0.0.1 – - [26/Jul/2009 16:16:23] “GET /favicon.ico HTTP/1.1” 200 12 0.0012

Whats next:

Well we don’t want to be writing our apps as lambdas jemmied into the router, instead next we start to build stacks, out of other middlewares… merbs, other pancake stacks, some sinatra, more rack ups or what ever.

To be continued…