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
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
690
Other Decks in Programming
See All in Programming
受け取る人から提供する人になるということ
little_rubyist
0
230
みんなでプロポーザルを書いてみた
yuriko1211
0
260
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
190
Contemporary Test Cases
maaretp
0
130
現場で役立つモデリング 超入門
masuda220
PRO
15
3.2k
初めてDefinitelyTypedにPRを出した話
syumai
0
400
Remix on Hono on Cloudflare Workers
yusukebe
1
280
CSC509 Lecture 12
javiergs
PRO
0
160
色々なIaCツールを実際に触って比較してみる
iriikeita
0
330
ヤプリ新卒SREの オンボーディング
masaki12
0
130
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
1
110
詳細解説! ArrayListの仕組みと実装
yujisoftware
0
580
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
45
6.7k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
Fireside Chat
paigeccino
34
3k
Practical Orchestrator
shlominoach
186
10k
Embracing the Ebb and Flow
colly
84
4.5k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Scaling GitHub
holman
458
140k
YesSQL, Process and Tooling at Scale
rocio
169
14k
4 Signs Your Business is Dying
shpigford
180
21k
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