sinatra 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Sinatra
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/sinatra/sinatra.svg)](http://travis-ci.org/sinatra/sinatra)
3
+ [![Build Status](https://secure.travis-ci.org/sinatra/sinatra.svg)](https://travis-ci.org/sinatra/sinatra)
4
4
 
5
5
  Sinatra is a [DSL](https://en.wikipedia.org/wiki/Domain-specific_language) for
6
6
  quickly creating web applications in Ruby with minimal effort:
@@ -28,6 +28,10 @@ ruby myapp.rb
28
28
 
29
29
  View at: [http://localhost:4567](http://localhost:4567)
30
30
 
31
+ The code you changed will not take effect until you restart the server.
32
+ Please restart the server every time you change or use
33
+ [sinatra/reloader](http://www.sinatrarb.com/contrib/reloader).
34
+
31
35
  It is recommended to also run `gem install thin`, which Sinatra will
32
36
  pick up if available.
33
37
 
@@ -75,9 +79,9 @@ pick up if available.
75
79
  * [Filters](#filters)
76
80
  * [Helpers](#helpers)
77
81
  * [Using Sessions](#using-sessions)
78
- * [Session Secret Security](#session-secret-security)
79
- * [Session Config](#session-config)
80
- * [Choosing Your Own Session Middleware](#choosing-your-own-session-middleware)
82
+ * [Session Secret Security](#session-secret-security)
83
+ * [Session Config](#session-config)
84
+ * [Choosing Your Own Session Middleware](#choosing-your-own-session-middleware)
81
85
  * [Halting](#halting)
82
86
  * [Passing](#passing)
83
87
  * [Triggering Another Route](#triggering-another-route)
@@ -253,11 +257,11 @@ end
253
257
  ```
254
258
 
255
259
  By the way, unless you disable the path traversal attack protection (see
256
- below), the request path might be modified before matching against your
257
- routes.
260
+ [below](#configuring-attack-protection)), the request path might be modified before
261
+ matching against your routes.
258
262
 
259
- You may customize the Mustermann options used for a given route by passing in a
260
- `:mustermann_opts` hash:
263
+ You may customize the [Mustermann](https://github.com/sinatra/mustermann#readme)
264
+ options used for a given route by passing in a `:mustermann_opts` hash:
261
265
 
262
266
  ```ruby
263
267
  get '\A/posts\z', :mustermann_opts => { :type => :regexp, :check_anchors => false } do
@@ -365,7 +369,7 @@ end
365
369
  get('/') { Stream.new }
366
370
  ```
367
371
 
368
- You can also use the `stream` helper method (described below) to reduce
372
+ You can also use the `stream` helper method ([described below](#streaming-responses)) to reduce
369
373
  boiler plate and embed the streaming logic in the route.
370
374
 
371
375
  ## Custom Route Matchers
@@ -428,7 +432,7 @@ Note that the public directory name is not included in the URL. A file
428
432
  `./public/css/style.css` is made available as
429
433
  `http://example.com/css/style.css`.
430
434
 
431
- Use the `:static_cache_control` setting (see below) to add
435
+ Use the `:static_cache_control` setting (see [below](#cache-control)) to add
432
436
  `Cache-Control` header info.
433
437
 
434
438
  ## Views / Templates
@@ -638,7 +642,7 @@ get('/') { markdown :index }
638
642
  </tr>
639
643
  </table>
640
644
 
641
- It also takes a block for inline templates (see example).
645
+ It also takes a block for inline templates (see [example](#inline-templates)).
642
646
 
643
647
  #### Nokogiri Templates
644
648
 
@@ -657,14 +661,14 @@ It also takes a block for inline templates (see example).
657
661
  </tr>
658
662
  </table>
659
663
 
660
- It also takes a block for inline templates (see example).
664
+ It also takes a block for inline templates (see [example](#inline-templates)).
661
665
 
662
666
  #### Sass Templates
663
667
 
664
668
  <table>
665
669
  <tr>
666
670
  <td>Dependency</td>
667
- <td><a href="http://sass-lang.com/" title="sass">sass</a></td>
671
+ <td><a href="https://sass-lang.com/" title="sass">sass</a></td>
668
672
  </tr>
669
673
  <tr>
670
674
  <td>File Extension</td>
@@ -681,7 +685,7 @@ It also takes a block for inline templates (see example).
681
685
  <table>
682
686
  <tr>
683
687
  <td>Dependency</td>
684
- <td><a href="http://sass-lang.com/" title="sass">sass</a></td>
688
+ <td><a href="https://sass-lang.com/" title="sass">sass</a></td>
685
689
  </tr>
686
690
  <tr>
687
691
  <td>File Extension</td>
@@ -739,8 +743,8 @@ template, you almost always want to pass locals to it.
739
743
  Anyone of:
740
744
  <a href="https://github.com/davidfstr/rdiscount" title="RDiscount">RDiscount</a>,
741
745
  <a href="https://github.com/vmg/redcarpet" title="RedCarpet">RedCarpet</a>,
742
- <a href="http://deveiate.org/projects/BlueCloth" title="BlueCloth">BlueCloth</a>,
743
- <a href="http://kramdown.gettalong.org/" title="kramdown">kramdown</a>,
746
+ <a href="https://github.com/ged/bluecloth" title="BlueCloth">BlueCloth</a>,
747
+ <a href="https://kramdown.gettalong.org/" title="kramdown">kramdown</a>,
744
748
  <a href="https://github.com/bhollis/maruku" title="maruku">maruku</a>
745
749
  </td>
746
750
  </tr>
@@ -890,7 +894,7 @@ almost always want to pass locals to it.
890
894
  <table>
891
895
  <tr>
892
896
  <td>Dependency</td>
893
- <td><a href="http://markaby.github.io/" title="Markaby">Markaby</a></td>
897
+ <td><a href="https://markaby.github.io/" title="Markaby">Markaby</a></td>
894
898
  </tr>
895
899
  <tr>
896
900
  <td>File Extension</td>
@@ -902,7 +906,7 @@ almost always want to pass locals to it.
902
906
  </tr>
903
907
  </table>
904
908
 
905
- It also takes a block for inline templates (see example).
909
+ It also takes a block for inline templates (see [example](#inline-templates)).
906
910
 
907
911
  #### RABL Templates
908
912
 
@@ -1019,7 +1023,7 @@ template than for the layout by passing the `:layout_engine` option.
1019
1023
  <a href="https://github.com/josh/ruby-coffee-script" title="Ruby CoffeeScript">
1020
1024
  CoffeeScript
1021
1025
  </a> and a
1022
- <a href="https://github.com/sstephenson/execjs/blob/master/README.md#readme" title="ExecJS">
1026
+ <a href="https://github.com/sstephenson/execjs" title="ExecJS">
1023
1027
  way to execute javascript
1024
1028
  </a>
1025
1029
  </td>
@@ -1043,7 +1047,7 @@ template than for the layout by passing the `:layout_engine` option.
1043
1047
  <a href="https://github.com/forgecrafted/ruby-stylus" title="Ruby Stylus">
1044
1048
  Stylus
1045
1049
  </a> and a
1046
- <a href="https://github.com/sstephenson/execjs/blob/master/README.md#readme" title="ExecJS">
1050
+ <a href="https://github.com/sstephenson/execjs" title="ExecJS">
1047
1051
  way to execute javascript
1048
1052
  </a>
1049
1053
  </td>
@@ -1117,7 +1121,7 @@ present(resource);
1117
1121
  <table>
1118
1122
  <tr>
1119
1123
  <td>Dependency</td>
1120
- <td><a href="https://github.com/blambeau/wlang/" title="WLang">WLang</a></td>
1124
+ <td><a href="https://github.com/blambeau/wlang" title="WLang">WLang</a></td>
1121
1125
  </tr>
1122
1126
  <tr>
1123
1127
  <td>File Extension</td>
@@ -1273,8 +1277,8 @@ get '/' do
1273
1277
  end
1274
1278
  ```
1275
1279
 
1276
- Renders `./views/index.myat`. See https://github.com/rtomayko/tilt to
1277
- learn more about Tilt.
1280
+ Renders `./views/index.myat`. Learn more about
1281
+ [Tilt](https://github.com/rtomayko/tilt#readme).
1278
1282
 
1279
1283
  ### Using Custom Logic for Template Lookup
1280
1284
 
@@ -1435,8 +1439,8 @@ $ ruby -e "require 'securerandom'; puts SecureRandom.hex(64)"
1435
1439
 
1436
1440
  **Session Secret Generation (Bonus Points)**
1437
1441
 
1438
- Use the [sysrandom gem](https://github.com/cryptosphere/sysrandom) to prefer
1439
- use of system RNG facilities to generate random values instead of
1442
+ Use the [sysrandom gem](https://github.com/cryptosphere/sysrandom#readme) to
1443
+ prefer use of system RNG facilities to generate random values instead of
1440
1444
  userspace `OpenSSL` which MRI Ruby currently defaults to:
1441
1445
 
1442
1446
  ```text
@@ -1466,7 +1470,7 @@ Setup your app config to fail-safe to a secure random secret
1466
1470
  if the `SESSION_SECRET` environment variable is not available.
1467
1471
 
1468
1472
  For bonus points use the [sysrandom
1469
- gem](https://github.com/cryptosphere/sysrandom) here as well:
1473
+ gem](https://github.com/cryptosphere/sysrandom#readme) here as well:
1470
1474
 
1471
1475
  ```ruby
1472
1476
  require 'securerandom'
@@ -1523,7 +1527,7 @@ use Rack::Protection::RemoteToken
1523
1527
  use Rack::Protection::SessionHijacking
1524
1528
  ```
1525
1529
 
1526
- See 'Configuring attack protection' for more information.
1530
+ See '[Configuring attack protection](#configuring-attack-protection)' for more information.
1527
1531
 
1528
1532
  ### Halting
1529
1533
 
@@ -1625,7 +1629,7 @@ end
1625
1629
  ```
1626
1630
 
1627
1631
  It is also possible to pass a block to `body`, which will be executed by the
1628
- Rack handler (this can be used to implement streaming, see "Return Values").
1632
+ Rack handler (this can be used to implement streaming, [see "Return Values"](#return-values)).
1629
1633
 
1630
1634
  Similar to the body, you can also set the status code and headers:
1631
1635
 
@@ -1634,7 +1638,7 @@ get '/foo' do
1634
1638
  status 418
1635
1639
  headers \
1636
1640
  "Allow" => "BREW, POST, GET, PROPFIND, WHEN",
1637
- "Refresh" => "Refresh: 20; http://www.ietf.org/rfc/rfc2324.txt"
1641
+ "Refresh" => "Refresh: 20; https://ietf.org/rfc/rfc2324.txt"
1638
1642
  body "I'm a tea pot!"
1639
1643
  end
1640
1644
  ```
@@ -1773,7 +1777,7 @@ Haml:
1773
1777
 
1774
1778
  It takes reverse proxies and Rack routers into account, if present.
1775
1779
 
1776
- This method is also aliased to `to` (see below for an example).
1780
+ This method is also aliased to `to` (see [below](#browser-redirect) for an example).
1777
1781
 
1778
1782
  ### Browser Redirect
1779
1783
 
@@ -1881,7 +1885,7 @@ etag @article.sha1, :weak
1881
1885
  These helpers will not do any caching for you, but rather feed the necessary
1882
1886
  information to your cache. If you are looking for a quick
1883
1887
  reverse-proxy caching solution, try
1884
- [rack-cache](https://github.com/rtomayko/rack-cache):
1888
+ [rack-cache](https://github.com/rtomayko/rack-cache#readme):
1885
1889
 
1886
1890
  ```ruby
1887
1891
  require "rack/cache"
@@ -1896,7 +1900,7 @@ get '/' do
1896
1900
  end
1897
1901
  ```
1898
1902
 
1899
- Use the `:static_cache_control` setting (see below) to add
1903
+ Use the `:static_cache_control` setting (see [below](#cache-control)) to add
1900
1904
  `Cache-Control` header info to static files.
1901
1905
 
1902
1906
  According to RFC 2616, your application should behave differently if the
@@ -2208,7 +2212,7 @@ set :protection, :except => [:path_traversal, :session_hijacking]
2208
2212
  ```
2209
2213
 
2210
2214
  By default, Sinatra will only set up session based protection if `:sessions`
2211
- have been enabled. See 'Using Sessions'. Sometimes you may want to set up
2215
+ have been enabled. See '[Using Sessions](#using-sessions)'. Sometimes you may want to set up
2212
2216
  sessions "outside" of the Sinatra app, such as in the config.ru or with a
2213
2217
  separate `Rack::Builder` instance. In that case you can still set up session
2214
2218
  based protection by passing the `:session` option:
@@ -2353,6 +2357,16 @@ set :protection, :session => true
2353
2357
  priority, default depends on Ruby implementation.
2354
2358
  </dd>
2355
2359
 
2360
+ <dt>server_settings</dt>
2361
+ <dd>
2362
+ If you are using a WEBrick web server, presumably for your development
2363
+ environment, you can pass a hash of options to <tt>server_settings</tt>,
2364
+ such as <tt>SSLEnable</tt> or <tt>SSLVerifyClient</tt>. However, web
2365
+ servers such as Puma and Thin do not support this, so you can set
2366
+ <tt>server_settings</tt> by defining it as a method when you call
2367
+ <tt>configure</tt>.
2368
+ </dd>
2369
+
2356
2370
  <dt>sessions</dt>
2357
2371
  <dd>
2358
2372
  Enable cookie-based sessions support using
@@ -2531,7 +2545,7 @@ and additional debugging information in your browser.
2531
2545
 
2532
2546
  ## Rack Middleware
2533
2547
 
2534
- Sinatra rides on [Rack](http://rack.github.io/), a minimal standard
2548
+ Sinatra rides on [Rack](https://rack.github.io/), a minimal standard
2535
2549
  interface for Ruby web frameworks. One of Rack's most interesting
2536
2550
  capabilities for application developers is support for "middleware" --
2537
2551
  components that sit between the server and your application monitoring
@@ -2571,7 +2585,7 @@ typically don't have to `use` them explicitly.
2571
2585
 
2572
2586
  You can find useful middleware in
2573
2587
  [rack](https://github.com/rack/rack/tree/master/lib/rack),
2574
- [rack-contrib](https://github.com/rack/rack-contrib#readm),
2588
+ [rack-contrib](https://github.com/rack/rack-contrib#readme),
2575
2589
  or in the [Rack wiki](https://github.com/rack/rack/wiki/List-of-Middleware).
2576
2590
 
2577
2591
  ## Testing
@@ -2995,7 +3009,9 @@ Options are:
2995
3009
 
2996
3010
  ### Multi-threading
2997
3011
 
2998
- _Paraphrasing from [this StackOverflow answer][so-answer] by Konstantin_
3012
+ _Paraphrasing from
3013
+ [this StackOverflow answer](https://stackoverflow.com/a/6282999/5245129)
3014
+ by Konstantin_
2999
3015
 
3000
3016
  Sinatra doesn't impose any concurrency model, but leaves that to the
3001
3017
  underlying Rack handler (server) like Thin, Puma or WEBrick. Sinatra
@@ -3026,9 +3042,6 @@ To start the server, the command would be:
3026
3042
  thin --threaded start
3027
3043
  ```
3028
3044
 
3029
-
3030
- [so-answer]: http://stackoverflow.com/questions/6278817/is-sinatra-multi-threaded/6282999#6282999)
3031
-
3032
3045
  ## Requirement
3033
3046
 
3034
3047
  The following Ruby versions are officially supported:
@@ -3097,7 +3110,7 @@ to get some of the latest features.
3097
3110
  ### With Bundler
3098
3111
 
3099
3112
  If you want to run your application with the latest Sinatra, using
3100
- [Bundler](http://bundler.io) is the recommended way.
3113
+ [Bundler](https://bundler.io) is the recommended way.
3101
3114
 
3102
3115
  First, install bundler, if you haven't:
3103
3116
 
@@ -3127,7 +3140,7 @@ bundle exec ruby myapp.rb
3127
3140
 
3128
3141
  ## Versioning
3129
3142
 
3130
- Sinatra follows [Semantic Versioning](http://semver.org/), both SemVer and
3143
+ Sinatra follows [Semantic Versioning](https://semver.org/), both SemVer and
3131
3144
  SemVerTag.
3132
3145
 
3133
3146
  ## Further Reading
@@ -3138,14 +3151,14 @@ SemVerTag.
3138
3151
  help? Have a patch?
3139
3152
  * [Issue tracker](https://github.com/sinatra/sinatra/issues)
3140
3153
  * [Twitter](https://twitter.com/sinatra)
3141
- * [Mailing List](http://groups.google.com/group/sinatrarb/topics)
3142
- * IRC: [#sinatra](irc://chat.freenode.net/#sinatra) on http://freenode.net
3143
- * [Sinatra & Friends](https://sinatrarb.slack.com) on Slack and see
3144
- [here](https://sinatra-slack.herokuapp.com/) for an invite.
3145
- * [Sinatra Book](https://github.com/sinatra/sinatra-book/) Cookbook Tutorial
3146
- * [Sinatra Recipes](http://recipes.sinatrarb.com/) Community
3147
- contributed recipes
3154
+ * [Mailing List](https://groups.google.com/forum/#!forum/sinatrarb)
3155
+ * IRC: [#sinatra](irc://chat.freenode.net/#sinatra) on [Freenode](https://freenode.net)
3156
+ * [Sinatra & Friends](https://sinatrarb.slack.com) on Slack
3157
+ ([get an invite](https://sinatra-slack.herokuapp.com/))
3158
+ * [Sinatra Book](https://github.com/sinatra/sinatra-book) - Cookbook Tutorial
3159
+ * [Sinatra Recipes](http://recipes.sinatrarb.com/) - Community contributed
3160
+ recipes
3148
3161
  * API documentation for the [latest release](http://www.rubydoc.info/gems/sinatra)
3149
3162
  or the [current HEAD](http://www.rubydoc.info/github/sinatra/sinatra) on
3150
- http://www.rubydoc.info/
3163
+ [RubyDoc](http://www.rubydoc.info/)
3151
3164
  * [CI server](https://travis-ci.org/sinatra/sinatra)