0
.. annihilate something ..
0
+NOTE: <tt>put</tt> and <tt>delete</tt> are triggered when a <tt>_method</tt> param is set to PUT or DELETE and the HTTP_REQUEST_METHOD is a POST
0
+NOTE: Routes are looked up in order of declaration
0
+ # matches /sinatra and the like and sets params[:name]
0
+ # matches /message/1/2/3/4/5
0
+ get '/foo', :agent => /Songbird (\d\.\d)[\d\/]*?/ do
0
+ "You're using Songbird version #{params[:agent][0]}"
0
+ # matches non-songbird browsers
0
= Views (if you need MVC)
0
All views are looked up in:
0
+These are run in Sinatra::EventContext
0
.. this code will run before each event ..
0
Get the gist? If you want more fun with this then checkout <tt>to_result</tt> on Array, Symbol, Fixnum, NilClass.
0
+= Configuration & Re-loading
0
+Sinatra supports multiple environments and re-loading. Re-loading happens on every request when in :development. Wrap your configurations in <tt>configure</tt> (i.e. Database connections, Constants, etc.) to protect them from re-loading and to only work in certain environments.
0
+ configure :production do
0
+ configure :production, :test do
0
+This is also really nifty for error handling.
0
+Remember: These are run inside the Sinatra::EventContext which means you get all the goodies is has to offer (i.e. haml, erb, :halt, etc.)
0
+Whenever NotFound is raised this will be called
0
+ 'This is nowhere to be found'
0
+ # this is where the error is stored for you to grab
0
+ name = env['sinatra.error'].class.name
0
+Because Sinatra give you a default <tt>not_found</tt> and <tt>error</tt> do :production that are secure. If you want to customize only for :production but want to keep the friendly helper screens for :development then do this:
0
+ configure :production do
0
+ "We're so sorry, but we don't what this is"
0
+ "Something really nasty happened. We're on it!"
0
+ require 'my_sinatra_app'
0
+ require 'sinatra/test/unit'
0
+ class MyAppTest < Test::Unit::TestCase
0
+ assert_equal 'My Default Page!', @response.body
0
+ get_it '/', :agent => 'Songbird'
0
+ assert_equal 'You're in Songbird!', @response.body
0
+ require 'my_sinatra_app'
0
+ require 'sinatra/test/spec'
0
+ should "show a default page" do
0
+ @response.body.should.equal 'My Default Page!'
0
+See Sinatra::Test::Methods
0
+This will be back in soon
0
+Run your sinatra file like:
0
+ ruby myapp.rb [options]
0
+ -p # set the port (default is 4567)
0
+ -e # set the environment (default is development)
0
+ -x # turn on the mutext lock (default is off)
+ cd where/you/keep/your/projects
0
+ git clone git://github.com/bmizerany/sinatra.git
0
+at the top of your sinatra.rb file
0
+ $:.unshift File.dirname(__FILE__) + '/sinatra/lib'
0
+ "I'm running on Version " + Sinatra::Version.combined
Comments
This should be ln -s ../sinatra (no trailing slash)
you’re right. thx.