Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Sinatra::Ftw
Search
Luciano Sousa
September 18, 2010
Programming
110
0
Share
Sinatra::Ftw
An introduction about Sinatra Framework
Luciano Sousa
September 18, 2010
More Decks by Luciano Sousa
See All by Luciano Sousa
Playing with Sorbet
lucianosousa
0
55
Knowing mina deploy
lucianosousa
1
81
Creating your startup without Developer
lucianosousa
0
180
Patterns Falacy v2
lucianosousa
0
130
Project Management like Software Developer
lucianosousa
1
120
The Patterns Falacy - Rails Version
lucianosousa
1
130
Other Decks in Programming
See All in Programming
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3k
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
200
inferと仲良くなる10分間
ryokatsuse
1
290
Old Dog, New Tricks: The Java 25 Reinvention - JNation
bazlur_rahman
0
140
Moments When Things Go Wrong
aurimas
3
130
AI駆動開発勉強会 広島支部 第一回勉強会 AI駆動開発概要とワークショップ
hayatoshimiu
0
420
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
110
OSもどきOS
arkw
0
350
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
11
3.1k
Swiftのレキシカルスコープ管理
kntkymt
0
200
AI時代のUIはどこへ行く?その2!
yusukebe
15
4.8k
Migrations : C'est une question d'hygiène !
vinceamstoutz
0
2.5k
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
331
21k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
460
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
200
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Odyssey Design
rkendrick25
PRO
2
650
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
30 Presentation Tips
portentint
PRO
1
310
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
380
Making the Leap to Tech Lead
cromwellryan
135
9.9k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
160
How to build a perfect <img>
jonoalderson
1
5.5k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
340
Transcript
http://twitter.com/lucianosousa 1 Sinatra::Ftw Luciano Sousa
[email protected]
http://lucianosousa.net http://twitter.com/lucianosousa http://github.com/lucianosousa
http://twitter.com/lucianosousa 2 Sinatra::WTF? ✔ Micro Framework web ✔ DSL ✔
Rotas ✔ Múltiplos Templates ✔ Filtros ✔ Exemplos
http://twitter.com/lucianosousa 3 Sinatra::Description Micro Framework para desenvolvimento de aplicações web
com o mínimo de esforço.
http://twitter.com/lucianosousa 4 Sinatra::DSL get '/hi' do “hello world!” end Domain
Specific Language
http://twitter.com/lucianosousa 5 Sinatra::Routes get '/' do “get in index” end
post '/' do “post in index” end put '/' do “put in index” end delete '/' do “delete in index” end get '/:name' do “Hello #{params[:name]}!” end
http://twitter.com/lucianosousa 6 Sinatra::Templates get '/' do “hello world!” end get
'/' do erb :index end get '/' do haml :index end get '/' do erubis :index end
http://twitter.com/lucianosousa 7 Sinatra::Layout get '/' do erb :index end Carrega
arquivo arquivo layout.template dentro da pasta views automagicamente
http://twitter.com/lucianosousa 8
http://twitter.com/lucianosousa 9
http://twitter.com/lucianosousa 10
http://twitter.com/lucianosousa 11
http://twitter.com/lucianosousa 12 Sinatra::Helpers helpers do def sum(value) "Result: #{value.to_i+100}" end
end get '/:value' do sum(params[:value]) end Obs: O parâmetro :value é passado como string para o helper.
http://twitter.com/lucianosousa 13
http://twitter.com/lucianosousa 14 Sinatra::Filters after do puts "Response status is: #{response.status}"
end
http://twitter.com/lucianosousa 15
http://twitter.com/lucianosousa 16 Sinatra::Example