Small Ruby Webstack

2,007 views
1,942 views

Published on

Short presentation showing Rack and Sinatra, for when Rails is just to much.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,007
On SlideShare
0
From Embeds
0
Number of Embeds
16
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • 9 lines of code and it works!
  • So how much code are we talking about for Ruby and Radiant
    Our small server is not visible
    Radiant’s core => 174908 loc (usually extended with plugins and own code)
    Rails’s core => 131990 loc
  • Rack, This is what almost all Ruby based web frameworks build on
    Basically it translates http to ruby
  • Rack, This is what almost all Ruby based web frameworks build on
    Basically it translates http to ruby
  • Even merb
    Default Merb
    46595 loc
  • Apache + passenger, mongrel, thin, webrick
  • But there is still an other player out there...
  • But there is still an other player out there...
  • But there is still an other player out there...
  • 6 lines of code (and a Rack compatible server) and we are off
  • This is Rails’ Rack stack
    Each class in use stack is called Middleware
  • This is a piece of middelware, that doesn’t do much
  • Rack::Lock executes the call in a synchronize block (Mutex)
    ActionController::Failsafe will render 500.html if it catches an exception
    Rails::Rack::Metal is basically a wrapper around middleware for ease of use in a rails app
    ...
    Your own... insert google analytic tags, filter out bad words...
  • again 6 lines of code (and a Rack compatible server) and we are off
  • Each page is defined by it’s
    - verb (get, post, put, delete)
    - URI, supporting parameters, wildcards and regex
    - And it should (usually) respond
  • Rendering templates
    - erb + haml + builder from files, inline, or defined template methods
    - With layout files!
  • Rendering templates
    - erb + haml + builder from files, inline, or defined template methods
    - With layout files!
  • Before Filters!
    Passing allows for better structured code
    404’s
    and error handeling
  • Rack as a stack
    Sinatra for non-data driven apps (isdemax.be, design prototyping)
  • ×