UPDATE 1 : The inspiration for this article came from here ( it predates yo mama ). It has abso-fucking-lutely nothing to do with merb whatsoever. And “fuck you to your face” is NOT directed towards anything/anyone :)
Just for fun and profit
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
require 'rubygems' require 'thin' require "action_controller" require 'dispatcher' # Rails pwned ActionController::Base.session = { :session_key => "_myapp_session", :secret => "some secret phrase of at least 30 characters" } ActionController::Routing.use_controllers! ['home'] ActionController::Dispatcher.unprepared = false Dependencies.mechanism = :require class ActionController::Dispatcher def prepare_application end end # And your routes ActionController::Routing::Routes.draw do |map| map.root :controller => 'home' map.connect ':controller/:action/:id' end # Application code class ::HomeController < ActionController::Base def index render :text => "fuck you to your face" end def hello render :text => params.inspect end end # Make Thin Happy class LifoAdapter def call(env) rack_response = Rack::Response.new rack_request = Rack::Request.new(env) cgi = Rack::Adapter::Rails::CGIWrapper.new(rack_request, rack_response) ActionController::Dispatcher.dispatch(cgi, ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, rack_response) rack_response.finish end end # Run LifoAdapter Thin::Server.start('0.0.0.0', 3000) do use Rack::CommonLogger run LifoAdapter.new end |
UPDATE 2
I just made a few more changes for funkification, which you can find at my github repository
With tinyrails, the “hello world” application looks like :
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# thin -p 3000 -r mini.rb start require 'tinyrails' routes { root :controller => 'home' } controller "home" do def index render :text => "Hello World" end end start |
You can also use models/views with tinyrails, as demonstrated here
UPDATE 3 : Fabiano França changed the code to run it with webrick/mongrel. He also has a funky microrest framework. His pastie can be found here





Fantastic! :)
I like what you’ve done here.
Lol! Wannabe camping!
I can only imagine who is the index action addressed to, but not sure I’m right ;) Care to clarify on this one?
absolutely awesome!
Anyone using this in production?
w00t!
but Thin is always happy, what are you talking about?
I can smell the sweet taste of beautiful sounding money rolling in. Nice.
Nice done man! It made me happy!
So fast.
Why do you have to do ::HomeController instead of just HomeController?
Chris, I don’t think the code is production ready yet. I still need to add some tests. But I’d really appreciate if you can probably try it in production and report back any bugs you’d encounter. Patches most welcome too !
Brian, that is to keep const_missing magic happy.
I am worried whether it can scale.
Benchmarks please.
Nice – and yes, of course it has nothing whatsoever to do with Merb :P
Yes, benchmarks. Thin is so January 2008. The new color is…. Ebb. ;)
Its awesome man!!
Why did you feel the need to have profanity in your code? What purpose is it serving?
David, it’s serving nothing but stupid humor really. I never planned to publish this code while I was working on it @ localhost. But when it worked, I just posted the code without giving it a lot of thoughts. I personally find it quite funny. That’s all.
Single file rails: Requests per second: 609.25 [#/sec] (mean) 25MB ram
Single file merb Requests per second: 1831.09 [#/sec] (mean) 13Mb ram
Just for fun and profit ;)
Hey…it’s a lot of fun and even more profit on my box ;-) :
All benchmarks done using Thin and ‘ab -n 2000 -c 50’
My Lesson ? Lets not compare apples to oranges
Fuckwords makes Agile Jesus™ cry. So stop it!
This has raised the bar for all the tiny framework developers out there.
I predict that within the next month we’ll see a web framework that fits in only half a file.
I see what you did there.
Rack support would be a useful thing as more and more ruby implementations are coming.
would test it with my projects and see if I can promote it for any specific use
Awesome!
@GG “half a file” ???? :P
fucking hot. ( need I say more? )
Hi,
Fantastic idea.
I’m change the code for use of Mongrel e WEBrick. See the code in http://pastie.caboo.se/pastes/155367
Hey Fabiano, That’s awesome ! I’ll update my main post and add a link to your pastie :)
Looks like a new Revolution on Ruby Frameworks, and most are getting faster.
how Awesome.
I love ruby