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: My Way
Search
Matthew Conway
July 19, 2012
Programming
8
1.1k
Sinatra: My Way
How I'm using Sinatra: structure and useful scripts
Matthew Conway
July 19, 2012
Tweet
Share
More Decks by Matthew Conway
See All by Matthew Conway
Building Heroku Add-ons
mattonrails
2
720
Other Decks in Programming
See All in Programming
「影響が少ない」を自分の目でみてみる
o0h
PRO
2
990
メモリウォールを超えて:キャッシュメモリ技術の進歩
kawayu
0
1.9k
State of Namespace
tagomoris
4
770
AI Coding Agent Enablement - エージェントを自走させよう
yukukotani
13
5.8k
Qiita Bash
mercury_dev0517
1
190
Do Dumb Things
mitsuhiko
0
430
[NG India] Event-Based State Management with NgRx SignalStore
markostanimirovic
1
110
Memory API : Patterns, Performance et Cas d'Utilisation
josepaumard
0
110
Compose Hot Reload is here, stop re-launching your apps! (Android Makers 2025)
zsmb
1
480
DomainException と Result 型で作る型安全なエラーハンドリング
karszawa
0
890
AWSで雰囲気でつくる! VRChatの写真変換ピタゴラスイッチ
anatofuz
0
150
プロダクト横断分析に役立つ、事前集計しないサマリーテーブル設計
hanon52_
2
390
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
251
12k
Gamification - CAS2011
davidbonilla
81
5.2k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Thoughts on Productivity
jonyablonski
69
4.6k
For a Future-Friendly Web
brad_frost
176
9.7k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
9
740
Fireside Chat
paigeccino
37
3.4k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.7k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
30k
Embracing the Ebb and Flow
colly
85
4.6k
Testing 201, or: Great Expectations
jmmastey
42
7.4k
4 Signs Your Business is Dying
shpigford
183
22k
Transcript
SINATRA my way
MATTHEW CONWAY @mattonrails
what is this? why am i here?
we’re going to learn you some standards! sinatra: you’re great.
but
we’re going to learn you some standards! sinatra: you’re great.
but (yeah, don’t tell him i said that)
to avoid confusion, we need to make some rules...
not ‘all the time’ rules, but within an application
ring-a ding-ding
you need... more structure handy scripts
so... we’re doin it your way?
(frank’s a smart guy)
STRUCTURE
classic style modular style not
the simple app
Gemfile Procfile app.rb config.ru script/
# Gemfile source :rubygems gem ‘sinatra’ gem ‘foreman’ gem ‘unicorn’
group :development do gem ‘shotgun’ gem ‘thin’ end
# Procfile web: bundle exec unicorn --port $PORT
# app.rb module Haiku class App < Sinatra::Base get ‘/’
do @haiku = Redis.srandmember(‘haiku’) haml :home end ... end end
# config.ru require ‘./app’ run Haiku::App
as it grows
Gemfile Procfile Rakefile app/ config/ config.ru db/ script/
Com Fl With M ...or collaborate with me ...or something
where do I start?
is bundler installed? do i have the required ruby? o
noes imagemagick! forgot to migrate... nice of you to mention those environment variables I apparently need to set yum install all --the --things brew uninstall patience mysqladmin -u wizard create blawg_development
None
script/bootstrap
“Never send a README to do a setup script’s job.”
@trek Trek Glowacki
script/bootstrap dependency checks bundler database setup does your job
HOW IS SINATRA SERVER FORMED?* * http://cl.ly/ICAy
ruby le_app.rb rackup -p 5000 thin --rackup config.ru start shotgun
-p 5000 bieber_site.rb
None
script/server
look familiar?
script/console
BONUS!
know how to get a console to sinatra on heroku?
maybe that’s a trick question
maybe that’s a trick question (since it depends)
heroku run script/console
now you can!
IN SUMMARY
Furthe Reading
Sinatra: Up and Running Alan Harris Konstantin Haase
YOU develop your own conventions for building sinatra apps share
them with the community
Thanks!
Asap, Omnibus Type Lavenderi , Lost Typ Menlo