1 / 11

Sinatra

require ' sinatra ‘ get ‘/' do "Hello World!" end. Sinatra. By: Maksim Surguy & Cesar Acosta. What is it ?. Web application framework in Ruby DSL* for defining RESTful HTTP actions Fast Fun!. What it is not ?. Not Rails Not MVC. *Domain specific Language.

jaafar
Télécharger la présentation

Sinatra

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. require 'sinatra‘ get ‘/' do "Hello World!" end Sinatra By: MaksimSurguy & Cesar Acosta

  2. What is it ? • Web application framework in Ruby • DSL* for defining RESTful HTTP actions • Fast • Fun! What it is not ? • Not Rails • Not MVC *Domain specific Language

  3. How does it work ? gem install sinatra vi my_app.rb set :port, 3000 require ‘sinatra’ get ‘/’ do ‘Hello World’ end ruby my_app.rb

  4. Gem Shotgun • Gems More Condensed • Changes to the App require to restart the server • gem install shotgun • Run => shotgun my_app.rb

  5. Got Parameters ? vi my_app2.rb require ‘sinatra’ set :port, 3000 get '/hello/:name' do "Hello #{params[:name]}" end ruby my_app2.rb

  6. Got REST ? get '/' do .. show something .. end post '/' do .. create something .. end put '/' do .. update something .. end delete '/' do .. annihilate something .. end options '/' do .. appease something .. end

  7. Got views? • Supports practically every template engine in Ruby: • HAML • ERB • Erubis • Builder • Nokogiri • Sass • Less • Liquid • And many, many more !!! (http://www.sinatrarb.com/intro.html) require ‘haml‘ get ‘/' do haml :index end • Renders ./views/index.haml

  8. What is good for ? • APIs • Web services (fast !!!) • Quick minimal applications • Lean web development (Largely static sites with some dynamic content) • Deploy on Heroku!

  9. In the wild… (Used by) • Heroku • GitHub services • Engine Yard • Apartment Therapy • Many Others More examples at : http://www.sinatrarb.com/wild.html

  10. Resources • http://www.sinatrarb.com • http://sinatra-book.gittr.com/ • http://bcc2010-sinatra.heroku.com/ • http://empty-journey-91.heroku.com/ • http://net.tutsplus.com/tutorials/ruby/singing-with-sinatra/ • http://www.slideshare.net/oisin/simple-web-services-with-sinatra-and-heroku-6882369 • http://sinatra-book-contrib.com

  11. Thanks!

More Related