Skip to content

Instantly share code, notes, and snippets.

@malpinder
Created April 15, 2014 09:51
Show Gist options
  • Save malpinder/10718785 to your computer and use it in GitHub Desktop.
Save malpinder/10718785 to your computer and use it in GitHub Desktop.
Example modular Sinatra app
require './lib/cool_art_client'
run CoolArtClient
# in ./lib/cool_art_client.rb
require 'sinatra/base'
class CoolArtClient < Sinatra::Base
get "/" do
# render an erb view
erb :index
end
post "/tickets" do
# ...or just return a string
"You've bought a ticket!"
end
end
source 'https://rubygems.org'
gem 'totally_cool_art', git: "https://github.com/shjohnson/TotallyCoolArt"
gem 'sinatra'
group :test, :development do
gem 'rspec'
end
<%# in ./lib/views/index.erb %>
I'm in an <%= 'erb file' %>!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment