Sinatra: A whirlwind tour!!

33ab5062beb333c981b7a1530024f7bc?s=47 Karmen Blake
September 26, 2011

Sinatra: A whirlwind tour!!

33ab5062beb333c981b7a1530024f7bc?s=128

Karmen Blake

September 26, 2011
Tweet

Transcript

  1. Sinatra: A Whirlwind Tour!

  2. The East Bay Ruby Meetup http://www.meetup.com/EBRuby/

  3. @kblake

  4. http://github.com/kblake

  5. http://blog.dudeblake.com

  6. More about me...

  7. More about me...

  8. More about me...

  9. More about me...

  10. More about me...

  11. Sinatra

  12. Sinatra 80's metal style...

  13. None
  14. None
  15. "Sinatra is a DSL for quickly creating web applications in

    Ruby with minimal effort" http://www.sinatrarb.com/intro
  16. None
  17. Why Sinatra?

  18. Change of scenery from Rails Less setup time Start quickly

    Go!
  19. Integrity Continuous Integration http://integrityapp.com/

  20. Showoff Presentation Software https://github.com/schacon/showoff

  21. Lots of apps http://www.sinatrarb.com/wild.html

  22. Outline •Setup •Routing •Static Files and Templates •Helpers •Settings

  23. Setup RVM http://rvm.beginrescueend.com/ •Install a ruby •Create gemset (optional)

  24. Setup Bundler Gemfile source :rubygems gem 'rack', '~> 1.1' gem

    'sinatra', :git => "git://github.com/sinatra/sinatra.git" # reload code in development gem 'rerun' # or shotgun
  25. Setup Bundler Sinatra app file, you need to add these

    lines: require 'bundler' Bundler.setup
  26. Routing RESTful get '/' do "hello world" end post '/'

    do # create something end put '/' do # update end delete '/' do # boom! end
  27. Routing named routes and parameters get '/hola' do "hello world"

    end get '/hola/:name' do "hello world " + params[:name] end get '/hola/:name' do |your_name| "hello world #{your_name}" end get '/hola.json' do {:greeting => "hello world"}.to_json end
  28. Directory Stucture

  29. Haml Templates get '/' do @projects = PivotalTracker::Project.all haml :index

    end Looks for views/index.haml
  30. SCSS Templates get '/styles.css' do scss :styles end Looks for

    views/styles.scss Template reference to generated css: <link href='/styles.css' rel='stylesheet' />
  31. Helpers #define the helpers block in your app helpers do

    def project_options(projects) projects.map do |project| "<option value='#{project.id}'>#{project.name}</option>" end.join end end Call helper methods in templates and route handlers
  32. Settings Set application-level variables set :member_name, 'John Doe' set :token,

    '1234' set :wip_story_limit, '3' Get variables from anywhere in application settings.member_name settings.token settings.wip_story_limit
  33. Demo "A Work In Progress (WIP) Limit Helps You Focus.

    If you set your WIP limit to two or three for tasks being “in progress”, it helps you focus on exactly those tasks. And you have an explicit motivation for getting those tasks done as you should only start new stuff if there is an empty space on your Kanban board for another “in progress” task. " http://www.agileweboperations.com/kanban- wip-limits-the-fine-art-of-focus
  34. Demo

  35. References • http://www.sinatrarb.com • http://sinatra-book.gittr.com/ • http://ididitmyway.heroku.com/ Demo Code: https://github.com/kblake/my-pivotal-wip

  36. Thank you!!! Karmen Blake @kblake http://github.com/kblake http://blog.dudeblake.com