Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 524 lines (350 sloc) 11.012 kB
df800b5 Docs are started
Blake Mizerany authored
1 = Sinatra
2
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
3 Sinatra is a DSL for quickly creating web-applications in Ruby with minimal
4 effort.
df800b5 Docs are started
Blake Mizerany authored
5
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
6 == Sample App
df800b5 Docs are started
Blake Mizerany authored
7
8 # myapp.rb
9 require 'rubygems'
10 require 'sinatra'
11 get '/' do
12 'Hello world!'
13 end
14
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
15 Run with <tt>ruby myapp.rb</tt> and view at <tt>http://localhost:4567</tt>
df800b5 Docs are started
Blake Mizerany authored
16
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
17 == HTTP Methods
df800b5 Docs are started
Blake Mizerany authored
18
19 get '/' do
20 .. show things ..
21 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
22
df800b5 Docs are started
Blake Mizerany authored
23 post '/' do
24 .. create something ..
25 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
26
df800b5 Docs are started
Blake Mizerany authored
27 put '/' do
28 .. update something ..
29 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
30
df800b5 Docs are started
Blake Mizerany authored
31 delete '/' do
32 .. annihilate something ..
33 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
34
1776a80 Added Version and Docs
Blake Mizerany authored
35 head '/' do
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
36
1776a80 Added Version and Docs
Blake Mizerany authored
37 end
38
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
39 NOTE: <tt>put</tt> and <tt>delete</tt> are also triggered when a
40 <tt>_method</tt> parameter is set to PUT or DELETE and the HTTP request method
41 is POST
1776a80 Added Version and Docs
Blake Mizerany authored
42
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
43 == Routes
1776a80 Added Version and Docs
Blake Mizerany authored
44
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
45 Routes are matched based on the order of declaration. The first route that
46 matches the request is invoked.
1776a80 Added Version and Docs
Blake Mizerany authored
47
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
48 Simple:
1776a80 Added Version and Docs
Blake Mizerany authored
49
50 get '/hi' do
51 ...
52 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
53
54 Named parameters:
1776a80 Added Version and Docs
Blake Mizerany authored
55
56 get '/:name' do
57 # matches /sinatra and the like and sets params[:name]
58 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
59
60 Splat parameters:
1776a80 Added Version and Docs
Blake Mizerany authored
61
9c85e99 @vic Specs, documentation and fixes for splat'n routes
vic authored
62 get '/say/*/to/*' do
63 # matches /say/hello/to/world
64 params["splat"] # => ["hello", "world"]
65 end
66
67 get '/download/*.*' do
68 # matches /download/path/to/file.xml
69 params["splat"] # => ["path/to/file", "xml"]
1776a80 Added Version and Docs
Blake Mizerany authored
70 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
71
72 User agent matching:
73
1776a80 Added Version and Docs
Blake Mizerany authored
74 get '/foo', :agent => /Songbird (\d\.\d)[\d\/]*?/ do
75 "You're using Songbird version #{params[:agent][0]}"
76 end
77
78 get '/foo' do
79 # matches non-songbird browsers
80 end
df800b5 Docs are started
Blake Mizerany authored
81
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
82 == Static files
047edc6 update README with Static help
Blake Mizerany authored
83
84 Put all of your static content in the ./public directory
85
86 root
87 \ public
88
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
89 If a file exists that maps to the REQUEST_PATH then it is served and the
90 request ends. Otherwise, Sinatra will look for an event that matches the
91 path.
df800b5 Docs are started
Blake Mizerany authored
92
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
93 == Views
df800b5 Docs are started
Blake Mizerany authored
94
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
95 Views are searched for in a "views" directory in the same location as
96 your main application.
df800b5 Docs are started
Blake Mizerany authored
97
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
98 === Haml Templates
df800b5 Docs are started
Blake Mizerany authored
99
100 get '/' do
101 haml :index
102 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
103
104 Renders <tt>./views/index.haml</tt>.
105
106 === Erb
107
108 get '/' do
109 erb :index
110 end
111
112 Renders <tt>./views/index.erb</tt>
113
114 === Builder
115
116 See Sinatra::Builder
df800b5 Docs are started
Blake Mizerany authored
117
4144ac1 @nmeans Added Sass information to documentation.
nmeans authored
118 === Sass
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
119
4144ac1 @nmeans Added Sass information to documentation.
nmeans authored
120 get '/stylesheet.css' do
ccc19b0 @rtomayko content_type response helper with mime type lookup and parameter supp…
rtomayko authored
121 content_type 'text/css', :charset => 'utf-8'
4144ac1 @nmeans Added Sass information to documentation.
nmeans authored
122 sass :stylesheet
123 end
124
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
125 Renders <tt>./views/stylesheet.sass</tt>.
126
127 === Inline Templates
df800b5 Docs are started
Blake Mizerany authored
128
129 get '/' do
130 haml '%div.title Hello World'
131 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
132
133 Renders the inlined template string.
df800b5 Docs are started
Blake Mizerany authored
134
135 === Accessing Variables
136
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
137 Templates are evaluated within the Sinatra::EventContext instance
138 used to evaluate event blocks. Instance variables set in event
139 blocks can be accessed direcly in views:
df800b5 Docs are started
Blake Mizerany authored
140
141 get '/:id' do
142 @foo = Foo.find(params[:id])
95aca76 @bleything fix documentation of variable interpolation into templates
bleything authored
143 haml '%h1= @foo.name'
df800b5 Docs are started
Blake Mizerany authored
144 end
145
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
146 Or, specify an explicit Hash of local variables:
df800b5 Docs are started
Blake Mizerany authored
147
148 get '/:id' do
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
149 foo = Foo.find(params[:id])
95aca76 @bleything fix documentation of variable interpolation into templates
bleything authored
150 haml '%h1= foo.name', :locals => { :foo => foo }
df800b5 Docs are started
Blake Mizerany authored
151 end
152
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
153 This is typically used when rendering templates as partials from within
154 other templates.
155
156 === In-file Templates
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
157
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
158 Templates may be defined at the end of the source file:
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
159
160 get '/' do
161 haml :index
162 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
163
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
164 use_in_file_templates!
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
165
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
166 __END__
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
167
f71330e @bmizerany quick doc fix
bmizerany authored
168 @@ layout
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
169 X
170 = yield
171 X
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
172
f71330e @bmizerany quick doc fix
bmizerany authored
173 @@ index
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
174 %div.title Hello world!!!!!
175
480fbfa @rtomayko minor formatting tweaks to cypher's README updates
rtomayko authored
176 It's also possible to define named templates using the top-level template
177 method:
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
178
179 template :layout do
180 "X\n=yield\nX"
181 end
182
183 template :index do
184 '%div.title Hello World!'
185 end
186
187 get '/' do
188 haml :index
189 end
190
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
191 == Helpers
df800b5 Docs are started
Blake Mizerany authored
192
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
193 The top-level <tt>helpers</tt> method takes a block and extends all
194 EventContext instances with the methods defined:
df800b5 Docs are started
Blake Mizerany authored
195
196 helpers do
197 def bar(name)
198 "#{name}bar"
199 end
200 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
201
1776a80 Added Version and Docs
Blake Mizerany authored
202 get '/:name' do
203 bar(params[:name])
204 end
df800b5 Docs are started
Blake Mizerany authored
205
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
206 == Filters
df800b5 Docs are started
Blake Mizerany authored
207
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
208 These are run in Sinatra::EventContext before every event.
1776a80 Added Version and Docs
Blake Mizerany authored
209
df800b5 Docs are started
Blake Mizerany authored
210 before do
211 .. this code will run before each event ..
212 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
213
214 == Halt!
df800b5 Docs are started
Blake Mizerany authored
215
216 To immediately stop a request during a before filter or event use:
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
217
df800b5 Docs are started
Blake Mizerany authored
218 throw :halt
219
220 Set the body to the result of a helper method
221
222 throw :halt, :helper_method
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
223
224 Set the body to the result of a helper method after sending it parameters from
225 the local scope
226
df800b5 Docs are started
Blake Mizerany authored
227 throw :halt, [:helper_method, foo, bar]
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
228
df800b5 Docs are started
Blake Mizerany authored
229 Set the body to a simple string
230
231 throw :halt, 'this will be the body'
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
232
df800b5 Docs are started
Blake Mizerany authored
233 Set status then the body
234
235 throw :halt, [401, 'go away!']
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
236
df800b5 Docs are started
Blake Mizerany authored
237 Set the status then call a helper method with params from local scope
238
239 throw :halt, [401, [:helper_method, foo, bar]]
240
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
241 Run a proc inside the Sinatra::EventContext instance and set the body to the
242 result
df800b5 Docs are started
Blake Mizerany authored
243
244 throw :halt, lambda { puts 'In a proc!'; 'I just wrote to $stdout!' }
245
246 Create you own to_result
247
248 class MyResultObject
249 def to_result(event_context, *args)
250 event_context.body = 'This will be the body!
251 end
252 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
253
df800b5 Docs are started
Blake Mizerany authored
254 get '/' do
255 throw :halt, MyResultObject.new
256 end
257
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
258 Get the gist? If you want more fun with this then checkout <tt>to_result</tt>
259 on Array, Symbol, Fixnum, NilClass.
df800b5 Docs are started
Blake Mizerany authored
260
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
261 == Configuration and Reloading
1776a80 Added Version and Docs
Blake Mizerany authored
262
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
263 Sinatra supports multiple environments and reloading. Reloading happens
264 before every request when running under the :development environment. Wrap
265 your configurations in <tt>configure</tt> (i.e. Database connections, Constants,
266 etc.) to protect them from reloading or to target specific environments.
1776a80 Added Version and Docs
Blake Mizerany authored
267
268 All environments:
269
270 configure do
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
271 ...
1776a80 Added Version and Docs
Blake Mizerany authored
272 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
273
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
274 Production:
1776a80 Added Version and Docs
Blake Mizerany authored
275
276 configure :production do
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
277 ...
1776a80 Added Version and Docs
Blake Mizerany authored
278 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
279
1776a80 Added Version and Docs
Blake Mizerany authored
280 Two at a time:
281
282 configure :production, :test do
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
283 ...
1776a80 Added Version and Docs
Blake Mizerany authored
284 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
285
1776a80 Added Version and Docs
Blake Mizerany authored
286 This is also really nifty for error handling.
287
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
288 == Error handling
1776a80 Added Version and Docs
Blake Mizerany authored
289
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
290 Error handlers run inside the current Sinatra::EventContext instance, which
291 means you get all the goodies it has to offer (i.e. haml, erb, throw :halt,
292 etc.)
1776a80 Added Version and Docs
Blake Mizerany authored
293
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
294 === Not Found
1776a80 Added Version and Docs
Blake Mizerany authored
295
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
296 When Sinatra::NotFound is raised, the not_found handler is invoked:
1776a80 Added Version and Docs
Blake Mizerany authored
297
298 not_found do
299 'This is nowhere to be found'
300 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
301
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
302 === Error
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
303
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
304 By default, the +error+ handler is invoked on Sinatra::ServerError or when
305 an unknown error occurs.
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
306
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
307 The exception can be obtained from the 'sinatra.error' variable in
308 request.env.
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
309
1776a80 Added Version and Docs
Blake Mizerany authored
310 error do
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
311 'Sorry there was a nasty error - ' + request.env['sinatra.error'].name
312 end
313
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
314 Custom errors:
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
315
316 error MyCustomError do
e7e0e55 @rtomayko Minor docfixes in README.rdoc
rtomayko authored
317 'So what happened was...' + request.env['sinatra.error'].message
1776a80 Added Version and Docs
Blake Mizerany authored
318 end
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
319
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
320 Then, if this happens:
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
321
322 get '/' do
323 raise MyCustomError, 'something bad'
324 end
325
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
326 You get this:
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
327
328 So what happened was... something bad
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
329
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
330 Sinatra installs special not_found and error handlers when running under
331 the development.
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
332
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
333 == Mime types
334
335 When using send_file or static files you may have mime types Sinatra doesn't
336 understand. Use +mime+ in those cases.
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
337
338 mime :foo, 'text/foo'
1776a80 Added Version and Docs
Blake Mizerany authored
339
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
340 == Rack Middleware
bda21f1 @rtomayko add doc on using Rack middleware to README
rtomayko authored
341
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
342 Sinatra rides on Rack[http://rack.rubyforge.org/], a minimal standard
343 interface for Ruby web frameworks. One of Rack's most interesting capabilities
344 for application developers is support for "middleware" -- components that sit
345 between the server and your application monitoring and/or manipulating the
346 HTTP request/response to provide various types of common functionality.
bda21f1 @rtomayko add doc on using Rack middleware to README
rtomayko authored
347
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
348 Sinatra makes building Rack middleware pipelines a cinch via a top-level
349 +use+ method:
bda21f1 @rtomayko add doc on using Rack middleware to README
rtomayko authored
350
351 require 'sinatra'
352 require 'my_custom_middleware'
353
354 use Rack::Lint
355 use MyCustomMiddleware
356
357 get '/hello' do
358 'Hello World'
359 end
360
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
361 The semantics of +use+ are identical to those defined for the
362 Rack::Builder[http://rack.rubyforge.org/doc/classes/Rack/Builder.html] DSL
363 (most frequently used from rackup files). For example, the +use+ method
364 accepts multiple/variable args as well as blocks:
bda21f1 @rtomayko add doc on using Rack middleware to README
rtomayko authored
365
366 use Rack::Auth::Basic do |username, password|
367 username == 'admin' && password == 'secret'
368 end
369
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
370 Rack is distributed with a variety of standard middleware for logging,
371 debugging, URL routing, authentication, and session handling. Sinatra uses
372 many of of these components automatically based on configuration so you
373 typically don't have to +use+ them explicitly.
bda21f1 @rtomayko add doc on using Rack middleware to README
rtomayko authored
374
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
375 == Testing
1776a80 Added Version and Docs
Blake Mizerany authored
376
377 === Test/Unit
378
7cfe04a @jcrosby Fix for test/unit and test/spec docs
jcrosby authored
379 require 'rubygems'
380 require 'sinatra'
1776a80 Added Version and Docs
Blake Mizerany authored
381 require 'sinatra/test/unit'
7cfe04a @jcrosby Fix for test/unit and test/spec docs
jcrosby authored
382 require 'my_sinatra_app'
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
383
1776a80 Added Version and Docs
Blake Mizerany authored
384 class MyAppTest < Test::Unit::TestCase
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
385
1776a80 Added Version and Docs
Blake Mizerany authored
386 def test_my_default
387 get_it '/'
388 assert_equal 'My Default Page!', @response.body
389 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
390
1776a80 Added Version and Docs
Blake Mizerany authored
391 def test_with_agent
392 get_it '/', :agent => 'Songbird'
393 assert_equal 'You're in Songbird!', @response.body
394 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
395
1776a80 Added Version and Docs
Blake Mizerany authored
396 ...
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
397
1776a80 Added Version and Docs
Blake Mizerany authored
398 end
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
399
10c90d5 @sr document testing with rspec
sr authored
400 === Test/Spec
1776a80 Added Version and Docs
Blake Mizerany authored
401
7cfe04a @jcrosby Fix for test/unit and test/spec docs
jcrosby authored
402 require 'rubygems'
403 require 'sinatra'
1776a80 Added Version and Docs
Blake Mizerany authored
404 require 'sinatra/test/spec'
7cfe04a @jcrosby Fix for test/unit and test/spec docs
jcrosby authored
405 require 'my_sinatra_app'
1776a80 Added Version and Docs
Blake Mizerany authored
406
7cfe04a @jcrosby Fix for test/unit and test/spec docs
jcrosby authored
407 describe 'My app' do
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
408
7cfe04a @jcrosby Fix for test/unit and test/spec docs
jcrosby authored
409 it "should show a default page" do
1776a80 Added Version and Docs
Blake Mizerany authored
410 get_it '/'
411 should.be.ok
83cba9c @bmizerany updated README with helpful tidbits
bmizerany authored
412 body.should.equal 'My Default Page!'
1776a80 Added Version and Docs
Blake Mizerany authored
413 end
10c90d5 @sr document testing with rspec
sr authored
414
415 ...
416
417 end
418
419 === RSpec
420
421 require 'rubygems'
422 require 'spec'
423 require 'sinatra'
424 require 'sinatra/test/rspec'
425 require 'my_sinatra_app'
426
427 describe 'My app' do
428 it 'should show a default page' do
429 get_it '/'
430 @response.should be_ok
431 @response.body.should == 'My Default Page!'
432 end
433
1776a80 Added Version and Docs
Blake Mizerany authored
434 ...
435
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
436 end
1776a80 Added Version and Docs
Blake Mizerany authored
437
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
438 See Sinatra::Test::Methods for more information on +get_it+, +post_it+,
439 +put_it+, and friends.
1776a80 Added Version and Docs
Blake Mizerany authored
440
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
441 == Command line
1776a80 Added Version and Docs
Blake Mizerany authored
442
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
443 Sinatra applications can be run directly:
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
444
e75f4b3 @rtomayko misc README formatting tweaks
rtomayko authored
445 ruby myapp.rb [-h] [-x] [-p PORT] [-e ENVIRONMENT]
1776a80 Added Version and Docs
Blake Mizerany authored
446
447 Options are:
448
449 -h # help
450 -p # set the port (default is 4567)
451 -e # set the environment (default is development)
e7e0e55 @rtomayko Minor docfixes in README.rdoc
rtomayko authored
452 -x # turn on the mutex lock (default is off)
1776a80 Added Version and Docs
Blake Mizerany authored
453
480fbfa @rtomayko minor formatting tweaks to cypher's README updates
rtomayko authored
454 == Contributing
1776a80 Added Version and Docs
Blake Mizerany authored
455
480fbfa @rtomayko minor formatting tweaks to cypher's README updates
rtomayko authored
456 === Tools
6326809 @cypher Add a subsection about tools needed for Sinatra to the Contributing s…
cypher authored
457
480fbfa @rtomayko minor formatting tweaks to cypher's README updates
rtomayko authored
458 Besides Ruby itself, you only need a text editor, preferably one that supports
459 Ruby syntax hilighting. VIM and Emacs are a fine choice on any platform, but
460 feel free to use whatever you're familiar with.
6326809 @cypher Add a subsection about tools needed for Sinatra to the Contributing s…
cypher authored
461
480fbfa @rtomayko minor formatting tweaks to cypher's README updates
rtomayko authored
462 Sinatra uses the Git source code management system. If you're unfamiliar with
463 Git, you can find more information and tutorials on http://git.or.cz/ as well
464 as http://git-scm.com/. Scott Chacon created a great series of introductory
465 screencasts about Git, which you can find here: http://www.gitcasts.com/
6326809 @cypher Add a subsection about tools needed for Sinatra to the Contributing s…
cypher authored
466
480fbfa @rtomayko minor formatting tweaks to cypher's README updates
rtomayko authored
467 === First Time: Cloning The Sinatra Repo
4c02878 @cypher Update Contributing section to include initialization and updating th…
cypher authored
468
1776a80 Added Version and Docs
Blake Mizerany authored
469 cd where/you/keep/your/projects
470 git clone git://github.com/bmizerany/sinatra.git
4c02878 @cypher Update Contributing section to include initialization and updating th…
cypher authored
471 cd sinatra
472 cd path/to/your_project
1776a80 Added Version and Docs
Blake Mizerany authored
473 ln -s ../sinatra/
480fbfa @rtomayko minor formatting tweaks to cypher's README updates
rtomayko authored
474
475 === Updating Your Existing Sinatra Clone
476
4c02878 @cypher Update Contributing section to include initialization and updating th…
cypher authored
477 cd where/you/keep/sinatra
478 git pull
480fbfa @rtomayko minor formatting tweaks to cypher's README updates
rtomayko authored
479
480 === Using Edge Sinatra in Your App
1776a80 Added Version and Docs
Blake Mizerany authored
481
4c02878 @cypher Update Contributing section to include initialization and updating th…
cypher authored
482 at the top of your sinatra_app.rb file:
1776a80 Added Version and Docs
Blake Mizerany authored
483
484 $:.unshift File.dirname(__FILE__) + '/sinatra/lib'
485 require 'sinatra'
486
487 get '/about' do
f44fb6a @rtomayko grammar/formatting pass over README
rtomayko authored
488 "I'm running on Version " + Sinatra::VERSION
1776a80 Added Version and Docs
Blake Mizerany authored
489 end
e6c5471 @cypher Add a community section with info about the mailing list and irc channel
cypher authored
490
480fbfa @rtomayko minor formatting tweaks to cypher's README updates
rtomayko authored
491 === Contributing a Patch
d8fec16 @cypher Add subsection about contributing a patch as well as a link to the is…
cypher authored
492
480fbfa @rtomayko minor formatting tweaks to cypher's README updates
rtomayko authored
493 There are several ways to do this. Probably the easiest (and preferred) way is
494 to fork Sinatra on GitHub (http://github.com/bmizerany/sinatra), push your
495 changes to your Sinatra repo, and then send Blake Mizerany (bmizerany on
496 GitHub) a pull request.
d8fec16 @cypher Add subsection about contributing a patch as well as a link to the is…
cypher authored
497
480fbfa @rtomayko minor formatting tweaks to cypher's README updates
rtomayko authored
498 You can also create a patch file and attach it to a feature request or bug fix
499 on the issue tracker (see below) or send it to the mailing list (see Community
500 section).
d8fec16 @cypher Add subsection about contributing a patch as well as a link to the is…
cypher authored
501
480fbfa @rtomayko minor formatting tweaks to cypher's README updates
rtomayko authored
502 === Issue Tracking and Feature Requests
d8fec16 @cypher Add subsection about contributing a patch as well as a link to the is…
cypher authored
503
504 http://sinatra.lighthouseapp.com/
505
480fbfa @rtomayko minor formatting tweaks to cypher's README updates
rtomayko authored
506 == Community
e6c5471 @cypher Add a community section with info about the mailing list and irc channel
cypher authored
507
480fbfa @rtomayko minor formatting tweaks to cypher's README updates
rtomayko authored
508 === Mailing List
e6c5471 @cypher Add a community section with info about the mailing list and irc channel
cypher authored
509
510 http://groups.google.com/group/sinatrarb
511
480fbfa @rtomayko minor formatting tweaks to cypher's README updates
rtomayko authored
512 If you have a problem or question, please make sure to include all the
513 relevant information in your mail, like the Sinatra version you're using, what
514 version of Ruby you have, and so on.
e6c5471 @cypher Add a community section with info about the mailing list and irc channel
cypher authored
515
480fbfa @rtomayko minor formatting tweaks to cypher's README updates
rtomayko authored
516 === IRC Channel
e6c5471 @cypher Add a community section with info about the mailing list and irc channel
cypher authored
517
480fbfa @rtomayko minor formatting tweaks to cypher's README updates
rtomayko authored
518 You can find us on the Freenode network in the channel #sinatra
519 (irc://chat.freenode.net/#sinatra)
e6c5471 @cypher Add a community section with info about the mailing list and irc channel
cypher authored
520
480fbfa @rtomayko minor formatting tweaks to cypher's README updates
rtomayko authored
521 There's usually someone online at any given time, but we cannot pay attention
522 to the channel all the time, so please stick around for a while after asking a
523 question.
Something went wrong with that request. Please try again.