Slide 1

Slide 1 text

SINATRA my way

Slide 2

Slide 2 text

MATTHEW CONWAY @mattonrails

Slide 3

Slide 3 text

what is this? why am i here?

Slide 4

Slide 4 text

we’re going to learn you some standards! sinatra: you’re great. but

Slide 5

Slide 5 text

we’re going to learn you some standards! sinatra: you’re great. but (yeah, don’t tell him i said that)

Slide 6

Slide 6 text

to avoid confusion, we need to make some rules...

Slide 7

Slide 7 text

not ‘all the time’ rules, but within an application

Slide 8

Slide 8 text

ring-a ding-ding

Slide 9

Slide 9 text

you need... more structure handy scripts

Slide 10

Slide 10 text

so... we’re doin it your way?

Slide 11

Slide 11 text

(frank’s a smart guy)

Slide 12

Slide 12 text

STRUCTURE

Slide 13

Slide 13 text

classic style modular style not

Slide 14

Slide 14 text

the simple app

Slide 15

Slide 15 text

Gemfile Procfile app.rb config.ru script/

Slide 16

Slide 16 text

# Gemfile source :rubygems gem ‘sinatra’ gem ‘foreman’ gem ‘unicorn’ group :development do gem ‘shotgun’ gem ‘thin’ end

Slide 17

Slide 17 text

# Procfile web: bundle exec unicorn --port $PORT

Slide 18

Slide 18 text

# app.rb module Haiku class App < Sinatra::Base get ‘/’ do @haiku = Redis.srandmember(‘haiku’) haml :home end ... end end

Slide 19

Slide 19 text

# config.ru require ‘./app’ run Haiku::App

Slide 20

Slide 20 text

as it grows

Slide 21

Slide 21 text

Gemfile Procfile Rakefile app/ config/ config.ru db/ script/

Slide 22

Slide 22 text

Com Fl With M ...or collaborate with me ...or something

Slide 23

Slide 23 text

where do I start?

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

script/bootstrap

Slide 27

Slide 27 text

“Never send a README to do a setup script’s job.” @trek Trek Glowacki

Slide 28

Slide 28 text

script/bootstrap dependency checks bundler database setup does your job

Slide 29

Slide 29 text

HOW IS SINATRA SERVER FORMED?* * http://cl.ly/ICAy

Slide 30

Slide 30 text

ruby le_app.rb rackup -p 5000 thin --rackup config.ru start shotgun -p 5000 bieber_site.rb

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

script/server

Slide 33

Slide 33 text

look familiar?

Slide 34

Slide 34 text

script/console

Slide 35

Slide 35 text

BONUS!

Slide 36

Slide 36 text

know how to get a console to sinatra on heroku?

Slide 37

Slide 37 text

maybe that’s a trick question

Slide 38

Slide 38 text

maybe that’s a trick question (since it depends)

Slide 39

Slide 39 text

heroku run script/console

Slide 40

Slide 40 text

now you can!

Slide 41

Slide 41 text

IN SUMMARY

Slide 42

Slide 42 text

Furthe Reading

Slide 43

Slide 43 text

Sinatra: Up and Running Alan Harris Konstantin Haase

Slide 44

Slide 44 text

YOU develop your own conventions for building sinatra apps share them with the community

Slide 45

Slide 45 text

Thanks!

Slide 46

Slide 46 text

Asap, Omnibus Type Lavenderi , Lost Typ Menlo