You are on page 1of 44

RubyWeb

~ loop{@sinatra+=1} ~

Uchio Kondo
.rb @ 2011-12-20
Jelly Jelly Cafe

Uchio Kondo(@udzura)

http://udzura.jp & http://blog.udzura.jp

Works:

Padrino framework contributor & evangelist(?

kaminari gem collaborator(sinatra)

rspec-padrino / rack-block / rack-session-dbm

Interest:

Ruby/Sinatra/TDD/Agile/non-blocking IO/Haskell...

Sinatra Padrino / Rack /

http://jp.rubyist.net/magazine/?0036-SinatraReintroduction

Ruby

or

Ruby

Rails

Ruby

Sinatra

Rails

dis

Ruby

Ruby on Rails

Merb

Ramaze

Camping

Sinatra

Padrino

Cramp

Renee

Rack

Ruby on Rails

Merb

Ramaze

Camping

Sinatra

Padrino

(Cramp)

Renee

Rack

Ruby on Rails

Merb

Ramaze

Camping

Sinatra

Padrino

(Cramp)

Renee

Apache
(mod_rails)

NginX
Webrick
Unicorn
Thin
FastCGI

Rack

Rack
/

(config.ru)

herokudotcloud

cf.

Ruby Rack

Python WSGI()

Perl PSGI/Plack

HaskellCommon Lisp

Java

PHP

Ruby

1:

Rails(1.x, 2.x)

Rail

2:

Sinatra

DSL

ModularityAgnosticism

Rails 3 Padrino

Rails 1.x
Rails 2.x

Full-stack

Sinatra
Camping
Renee

Microframework

(Merb)
Rails 3.x ~
Padrino

Modular &
Agnostic

Rack

Remember the Rack

Rack

Basic/Digest

ReCaptcha

Deflate

Rack Middleware

Rails plugins, Sinatra/Padrino Extensions

Ruby + Web

Rack

Sinatra

Simple

You may know:


require 'sinatra'
get '/' do
'My way!'
end

Sinatra

Padrino

RackRack
Rack Middleware

Rails

1,500
...

rack=>1193.26rps
camping=>897.41rps
sinatra=>603.23rps
padrino=>570.75rps
merb=>367.69rps
ramaze=>248.59rps
rails=>139.62rps
https://github.com/DAddYE/web-frameworks-benchmark


require 'sinatra'
get '/' do
'My way!'
end
get '/:name' do
params[:name] + '\'s way!'
end

$ ruby app.rb

Hello, world


require 'sinatra'
require 'haml'
get '/' do
'My way!'
end
get '/:name' do
@name = params[:name]
haml :hello
end
__END__
@@ layout
!!! 5
%html
%head
%title Hello Sinatra
%body
= yield
@@ hello
%h1= "Hello, #{@name}"
%p
= @name
's Way!

$ gem install haml

haml


require 'sinatra/base'
require 'haml'
class App < Sinatra::Base
use Rack::Auth::Basic do |user, pass|
user == 'udzura' && pass == 'XXXX'
end
enable :inline_templates
get '/' do
'My way!'
end
get '/:name' do
@name = params[:name]
haml :hello
end
end
App.run!

__END__
@@ layout
!!! 5
%html
%head
%title Hello Sinatra
%body
= yield
@@ hello
%h1= "Hello, #{@name}"
%p
= @name
's Way!

Basic

Rack Middleware

use Rack::Auth::Basic do |user, pass|


user == 'udzura' && pass == 'XXXX'
end


Rack Application

Server

Rack::Auth::Basic

Rack::Request
()

App

OK?

()

Rack::Response

Heroku

git
$ heroku create
$ git add . && git commit -m 'init'
$ git push heroku master

Dotcloud, fluxflex, etc...


Apache2+Passenger, NginX+unicorn

Sinatra

WEB+DB PRESS vol. 57

Ruby in your hands Sinatra

Sinatra Up and Running

The first Sinatra book in the world

Alan Harris
(Pro, C#)

Konstantin Haase
(@rkh, currently Sinatra's main commiter)

or

Sinatra

Web

@ruedup (HerokuWeb
10)
( http://d.hatena.ne.jp/ruedap/20110509)

Rails

Many many documents

Padrino(hot!)

Sinatra

Rails

ActiveRecord

Padrino[PR]

blog.udzura.jp - PadrinoMongoDBHeroku

(http://blog.udzura.jp/2011/02/23/app-in-5-min-with-padrinomongodb-heroku/)

(http://jp.padrinorb.com/guides/blog-tutorial)

(http://jp.rubyist.net/magazine/?0036-SinatraReintroduction)

Rails

Ruby/Sinatra/Rack
web

Rails

CGIRack

Sinatra

Enjoy Ruby & Enjoy Programming!

Thanks

@aereal

http://speakerdeck.com/u/aereal/p/the-brief-seeds-of-padrino

WAF3

__END__