Created
April 15, 2014 09:51
-
-
Save malpinder/10718785 to your computer and use it in GitHub Desktop.
Example modular Sinatra app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './lib/cool_art_client' | |
run CoolArtClient |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'totally_cool_art', git: "https://github.com/shjohnson/TotallyCoolArt" | |
gem 'sinatra' | |
group :test, :development do | |
gem 'rspec' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%# 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