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
730
Other Decks in Programming
See All in Programming
Javaのルールをねじ曲げろ!禁断の操作とその代償から学ぶメタプログラミング入門 / A Guide to Metaprogramming: Lessons from Forbidden Techniques and Their Price
nrslib
2
1.6k
TypeScript製IaCツールのAWS CDKが様々な言語で実装できる理由 ~他言語変換の仕組み~ / cdk-language-transformation
gotok365
7
400
DevTalks 25 - Create your own AI-infused Java apps with ease
kdubois
2
130
Zennの運営完全に理解した #完全に理解したTalk
wadayusuke
1
150
『Python → TypeScript』オンボーディング奮闘記
takumi_tatsuno
1
140
從零到一:搭建你的第一個 Observability 平台
blueswen
0
270
Perlで痩せる
yuukis
1
670
Parallel::Pipesの紹介
skaji
2
880
技術懸念に立ち向かい 法改正を穏便に乗り切った話
pop_cashew
0
980
當開發遇上包裝:AI 如何讓產品從想法變成商品
clonn
0
2.7k
コードに語らせよう――自己ドキュメント化が内包する楽しさについて / Let the Code Speak
nrslib
5
1.1k
AI Coding Agent Enablement in TypeScript
yukukotani
17
7.4k
Featured
See All Featured
Building Adaptive Systems
keathley
41
2.6k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
25
2.8k
Build The Right Thing And Hit Your Dates
maggiecrowley
35
2.7k
The Straight Up "How To Draw Better" Workshop
denniskardys
233
140k
The Power of CSS Pseudo Elements
geoffreycrofte
76
5.8k
Statistics for Hackers
jakevdp
799
220k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.6k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.3k
Stop Working from a Prison Cell
hatefulcrawdad
269
20k
Mobile First: as difficult as doing things right
swwweet
223
9.6k
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