sinatra 1.4.0.d → 1.4.0
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.
Potentially problematic release.
This version of sinatra might be problematic. Click here for more details.
- data/CHANGES +36 -5
- data/Gemfile +5 -5
- data/README.de.md +982 -706
- data/README.fr.md +2 -2
- data/README.ko.md +12 -6
- data/README.md +52 -55
- data/README.ru.md +21 -21
- data/README.zh.md +128 -125
- data/lib/sinatra/base.rb +25 -11
- data/lib/sinatra/version.rb +1 -1
- data/test/base_test.rb +1 -1
- data/test/contest.rb +3 -1
- data/test/erb_test.rb +1 -1
- data/test/filter_test.rb +51 -1
- data/test/haml_test.rb +1 -1
- data/test/helpers_test.rb +10 -4
- data/test/integration_helper.rb +9 -4
- data/test/integration_test.rb +9 -2
- data/test/request_test.rb +13 -1
- data/test/response_test.rb +1 -2
- data/test/routing_test.rb +123 -0
- data/test/slim_test.rb +1 -1
- data/test/streaming_test.rb +7 -7
- data/test/templates_test.rb +6 -9
- data/test/wlang_test.rb +1 -1
- metadata +9 -6
data/README.fr.md
CHANGED
@@ -479,7 +479,7 @@ exemple).
|
|
479
479
|
</tr>
|
480
480
|
<tr>
|
481
481
|
<td>Exemple</td>
|
482
|
-
<td><tt>nokogiri { |xml| xml.em "salut" }</
|
482
|
+
<td><tt>nokogiri { |xml| xml.em "salut" }</tt>
|
483
483
|
</td>
|
484
484
|
</tr>
|
485
485
|
</table>
|
@@ -2627,4 +2627,4 @@ SemVer que SemVerTag.
|
|
2627
2627
|
* Documentation API de la [dernière version](http://rubydoc.info/gems/sinatra)
|
2628
2628
|
ou du [HEAD courant](http://rubydoc.info/github/sinatra/sinatra) sur
|
2629
2629
|
http://rubydoc.info
|
2630
|
-
* [CI server](http://travis-ci.org/sinatra/sinatra)
|
2630
|
+
* [CI server](http://travis-ci.org/sinatra/sinatra)
|
data/README.ko.md
CHANGED
@@ -1705,20 +1705,25 @@ set :protection, :except => [:path_traversal, :session_hijacking]
|
|
1705
1705
|
<tt>settings.add_charsets << "application/foobar"</tt>
|
1706
1706
|
</dd>
|
1707
1707
|
|
1708
|
-
<dt>app_file
|
1708
|
+
<dt>app_file</dt>
|
1709
1709
|
<dd>메인 애플리케이션 파일의 경로. 프로젝트 루트와 뷰, 그리고 public 폴더, 인라인 템플릿을
|
1710
|
-
파악할 때
|
1710
|
+
파악할 때 사용됨.
|
1711
|
+
</dd>
|
1711
1712
|
|
1712
|
-
<dt>bind
|
1713
|
+
<dt>bind</dt>
|
1713
1714
|
<dd>바인드할 IP 주소(기본값: 0.0.0.0).
|
1714
|
-
오직 빌트인(built-in) 서버에서만
|
1715
|
+
오직 빌트인(built-in) 서버에서만 사용됨.
|
1716
|
+
</dd>
|
1715
1717
|
|
1716
1718
|
<dt>default_encoding</dt>
|
1717
1719
|
<dd>모를 때 가정할 인코딩
|
1718
|
-
(기본값은 <tt>"utf-8"</tt>)
|
1720
|
+
(기본값은 <tt>"utf-8"</tt>).
|
1721
|
+
</dd>
|
1719
1722
|
|
1720
1723
|
<dt>dump_errors</dt>
|
1721
|
-
<dd
|
1724
|
+
<dd>
|
1725
|
+
로그로 에러 출력.
|
1726
|
+
</dd>
|
1722
1727
|
|
1723
1728
|
<dt>environment</dt>
|
1724
1729
|
<dd>현재 환경, 기본값은 <tt>ENV['RACK_ENV']</tt> 또는 알 수 없을 경우 "development".</dd>
|
@@ -1807,6 +1812,7 @@ set :protection, :except => [:path_traversal, :session_hijacking]
|
|
1807
1812
|
<dd>뷰 폴더 경로. 설정하지 않은 경우 <tt>app_file</tt>로부터 유추됨.</dd>
|
1808
1813
|
</dl>
|
1809
1814
|
|
1815
|
+
|
1810
1816
|
## 환경(Environments)
|
1811
1817
|
|
1812
1818
|
환경은 `RACK_ENV` 환경 변수를 통해서도 설정할 수 있다. 기본값은 "development"다.
|
data/README.md
CHANGED
@@ -30,11 +30,11 @@ pick up if available.
|
|
30
30
|
* [Table of Contents](#table-of-contents)
|
31
31
|
* [Routes](#routes)
|
32
32
|
* [Conditions](#conditions)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
* [Return Values](#return-values)
|
34
|
+
* [Custom Route Matchers](#custom-route-matchers)
|
35
|
+
* [Static Files](#static-files)
|
36
|
+
* [Views / Templates](#views--templates)
|
37
|
+
* [Literal Templates](#literal-templates)
|
38
38
|
* [Available Template Languages](#available-template-languages)
|
39
39
|
* [Haml Templates](#haml-templates)
|
40
40
|
* [Erb Templates](#erb-templates)
|
@@ -284,7 +284,7 @@ get "/only/admin/", :auth => :admin do
|
|
284
284
|
end
|
285
285
|
```
|
286
286
|
|
287
|
-
|
287
|
+
## Return Values
|
288
288
|
|
289
289
|
The return value of a route block determines at least the response body passed
|
290
290
|
on to the HTTP client, or at least the next middleware in the Rack stack.
|
@@ -317,7 +317,7 @@ get('/') { Stream.new }
|
|
317
317
|
You can also use the `stream` helper method (described below) to reduce boiler
|
318
318
|
plate and embed the streaming logic in the route.
|
319
319
|
|
320
|
-
|
320
|
+
## Custom Route Matchers
|
321
321
|
|
322
322
|
As shown above, Sinatra ships with built-in support for using String patterns
|
323
323
|
and regular expressions as route matches. However, it does not stop there. You
|
@@ -364,7 +364,7 @@ get %r{^(?!/index$)} do
|
|
364
364
|
end
|
365
365
|
```
|
366
366
|
|
367
|
-
|
367
|
+
## Static Files
|
368
368
|
|
369
369
|
Static files are served from the `./public` directory. You can specify
|
370
370
|
a different location by setting the `:public_folder` option:
|
@@ -380,7 +380,7 @@ Note that the public directory name is not included in the URL. A file
|
|
380
380
|
Use the `:static_cache_control` setting (see below) to add
|
381
381
|
`Cache-Control` header info.
|
382
382
|
|
383
|
-
|
383
|
+
## Views / Templates
|
384
384
|
|
385
385
|
Each template language is exposed via its own rendering method. These
|
386
386
|
methods simply return a string:
|
@@ -484,23 +484,18 @@ Available Options:
|
|
484
484
|
Special options only used for rendering the layout. Example:
|
485
485
|
<tt>set :rdoc, :layout_options => { :views => 'views/layouts' }</tt>
|
486
486
|
</dd>
|
487
|
-
|
488
|
-
<dd>
|
489
|
-
Templates are assumed to be located directly under the `./views`
|
490
|
-
directory. To use a different views directory:
|
491
|
-
<tt>set :views, settings.root + '/templates'</tt>
|
492
|
-
</dd>
|
493
|
-
|
494
|
-
<dd>
|
495
|
-
One important thing to remember is that you always have to reference
|
496
|
-
templates with symbols, even if they're in a subdirectory (in this
|
497
|
-
case, use: <tt>'subdir/template'</tt>). You must use a symbol because
|
498
|
-
otherwise rendering methods will render any strings passed to them
|
499
|
-
directly.
|
500
|
-
</dd>
|
501
487
|
</dl>
|
488
|
+
|
489
|
+
Templates are assumed to be located directly under the `./views` directory. To
|
490
|
+
use a different views directory:
|
491
|
+
<tt>set :views, settings.root + '/templates'</tt>
|
502
492
|
|
503
|
-
|
493
|
+
One important thing to remember is that you always have to reference templates
|
494
|
+
with symbols, even if they're in a subdirectory (in this case, use:
|
495
|
+
<tt>'subdir/template'</tt>). You must use a symbol because otherwise rendering
|
496
|
+
methods will render any strings passed to them directly.
|
497
|
+
|
498
|
+
### Literal Templates
|
504
499
|
|
505
500
|
``` ruby
|
506
501
|
get '/' do
|
@@ -977,14 +972,15 @@ end
|
|
977
972
|
|
978
973
|
|
979
974
|
The template source is evaluated as a Ruby string, and the
|
980
|
-
resulting json variable is converted using `#to_json
|
975
|
+
resulting json variable is converted using `#to_json`:
|
981
976
|
|
982
977
|
``` ruby
|
983
978
|
json = { :foo => 'bar' }
|
984
979
|
json[:baz] = key
|
985
980
|
```
|
986
981
|
|
987
|
-
The `:callback` and `:variable` options can be used to decorate the rendered
|
982
|
+
The `:callback` and `:variable` options can be used to decorate the rendered
|
983
|
+
object:
|
988
984
|
|
989
985
|
``` ruby
|
990
986
|
var resource = {"foo":"bar","baz":"qux"}; present(resource);
|
@@ -2013,7 +2009,7 @@ set :protection, :session => true
|
|
2013
2009
|
</dd>
|
2014
2010
|
|
2015
2011
|
<dt>bind</dt>
|
2016
|
-
<dd>IP address to bind to (default: 0.0.0.0). Only used for built-in server.</dd>
|
2012
|
+
<dd>IP address to bind to (default: <tt>0.0.0.0</tt>). Only used for built-in server.</dd>
|
2017
2013
|
|
2018
2014
|
<dt>default_encoding</dt>
|
2019
2015
|
<dd>encoding to assume if unknown (defaults to <tt>"utf-8"</tt>).</dd>
|
@@ -2093,8 +2089,8 @@ set :protection, :session => true
|
|
2093
2089
|
|
2094
2090
|
<dt>server</dt>
|
2095
2091
|
<dd>
|
2096
|
-
|
2097
|
-
|
2092
|
+
Server or list of servers to use for built-in server. order indicates priority,
|
2093
|
+
default depends on Ruby implementation.
|
2098
2094
|
</dd>
|
2099
2095
|
|
2100
2096
|
<dt>sessions</dt>
|
@@ -2150,7 +2146,7 @@ set :protection, :session => true
|
|
2150
2146
|
<dt>x_cascade</dt>
|
2151
2147
|
<dd>
|
2152
2148
|
Whether or not to set the X-Cascade header if no route matches.
|
2153
|
-
Defaults to
|
2149
|
+
Defaults to <tt>true</tt>.
|
2154
2150
|
</dd>
|
2155
2151
|
</dl>
|
2156
2152
|
|
@@ -2658,8 +2654,8 @@ end
|
|
2658
2654
|
|
2659
2655
|
You have the request scope binding inside:
|
2660
2656
|
|
2661
|
-
* get
|
2662
|
-
* before
|
2657
|
+
* get, head, post, put, delete, options, patch, link, and unlink blocks
|
2658
|
+
* before and after filters
|
2663
2659
|
* helper methods
|
2664
2660
|
* templates/views
|
2665
2661
|
|
@@ -2707,45 +2703,44 @@ The following Ruby versions are officially supported:
|
|
2707
2703
|
<dt>Ruby 1.8.7</dt>
|
2708
2704
|
<dd>
|
2709
2705
|
1.8.7 is fully supported, however, if nothing is keeping you from it, we
|
2710
|
-
recommend upgrading
|
2711
|
-
|
2712
|
-
the unlikely event of 1.8.8 being released. Even then, we might continue
|
2713
|
-
supporting it. <b>Ruby 1.8.6 is no longer supported.</b> If you want to run
|
2714
|
-
with 1.8.6, downgrade to Sinatra 1.2, which will receive bug fixes until
|
2715
|
-
Sinatra 1.4.0 is released.
|
2706
|
+
recommend upgrading or switching to JRuby or Rubinius. Support for 1.8.7
|
2707
|
+
will not be dropped before Sinatra 2.0. Ruby 1.8.6 is no longer supported.
|
2716
2708
|
</dd>
|
2717
2709
|
|
2718
2710
|
<dt>Ruby 1.9.2</dt>
|
2719
2711
|
<dd>
|
2720
|
-
1.9.2 is fully supported
|
2721
|
-
|
2722
|
-
until the release of
|
2723
|
-
will continue as long as it is still supported by the Ruby core team.
|
2712
|
+
1.9.2 is fully supported. Do not use 1.9.2p0, as it is known to cause
|
2713
|
+
segmentation faults when running Sinatra. Official support will continue
|
2714
|
+
at least until the release of Sinatra 1.5.
|
2724
2715
|
</dd>
|
2725
2716
|
|
2726
2717
|
<dt>Ruby 1.9.3</dt>
|
2727
2718
|
<dd>
|
2728
2719
|
1.9.3 is fully supported and recommended. Please note that switching to 1.9.3
|
2729
|
-
from an earlier version will invalidate all sessions.
|
2720
|
+
from an earlier version will invalidate all sessions. 1.9.3 will be supported
|
2721
|
+
until the release of Sinatra 2.0.
|
2722
|
+
</dd>
|
2723
|
+
|
2724
|
+
<dt>Ruby 2.0.0</dt>
|
2725
|
+
<dd>
|
2726
|
+
2.0.0 is fully supported and recommended. There are currently no plans to drop
|
2727
|
+
official support for it.
|
2730
2728
|
</dd>
|
2731
2729
|
|
2732
2730
|
<dt>Rubinius</dt>
|
2733
2731
|
<dd>
|
2734
|
-
Rubinius is officially supported (Rubinius >=
|
2735
|
-
|
2736
|
-
well, including 1.9 mode.
|
2732
|
+
Rubinius is officially supported (Rubinius >= 2.x). It is recommendended to
|
2733
|
+
`gem install puma`.
|
2737
2734
|
</dd>
|
2738
2735
|
|
2739
2736
|
<dt>JRuby</dt>
|
2740
2737
|
<dd>
|
2741
|
-
JRuby is officially supported
|
2742
|
-
|
2743
|
-
|
2744
|
-
on JRuby. JRuby's support for C extensions is still experimental, which only
|
2745
|
-
affects RDiscount, Redcarpet, RedCloth and Yajl templates as well as Thin
|
2746
|
-
and Mongrel at the moment.
|
2738
|
+
The latest stable release of JRuby is officially supported. It is not
|
2739
|
+
recommended to use C extensions with JRuby. It is recommended to
|
2740
|
+
`gem install trinidad`.
|
2747
2741
|
</dd>
|
2748
2742
|
</dl>
|
2743
|
+
|
2749
2744
|
We also keep an eye on upcoming Ruby versions.
|
2750
2745
|
|
2751
2746
|
The following Ruby implementations are not officially supported but still are
|
@@ -2759,13 +2754,15 @@ known to run Sinatra:
|
|
2759
2754
|
Not being officially supported means if things only break there and not on a
|
2760
2755
|
supported platform, we assume it's not our issue but theirs.
|
2761
2756
|
|
2762
|
-
We also run our CI against ruby-head (the upcoming 2.
|
2763
|
-
|
2764
|
-
|
2757
|
+
We also run our CI against ruby-head (the upcoming 2.1.0), but we can't
|
2758
|
+
guarantee anything, since it is constantly moving. Expect 2.1.0 to be fully
|
2759
|
+
supported.
|
2765
2760
|
|
2766
2761
|
Sinatra should work on any operating system supported by the chosen Ruby
|
2767
2762
|
implementation.
|
2768
2763
|
|
2764
|
+
If you run MacRuby, you should `gem install control_tower`.
|
2765
|
+
|
2769
2766
|
Sinatra currently doesn't run on Cardinal, SmallRuby, BlueRuby or any
|
2770
2767
|
Ruby version prior to 1.8.7.
|
2771
2768
|
|
data/README.ru.md
CHANGED
@@ -85,7 +85,7 @@ end
|
|
85
85
|
get '/hello/:name' do |n|
|
86
86
|
"Hello #{n}!"
|
87
87
|
end
|
88
|
-
|
88
|
+
```
|
89
89
|
|
90
90
|
Шаблоны маршрутов также могут включать в себя splat (или '*' маску,
|
91
91
|
обозначающую любой символ) параметры, доступные в массиве `params[:splat]`:
|
@@ -416,7 +416,7 @@ set :views, settings.root + '/templates'
|
|
416
416
|
`:'subdir/template'`). Вы должны использовать символы, потому что иначе
|
417
417
|
шаблонизаторы попросту отображают любые строки, переданные им.
|
418
418
|
|
419
|
-
|
419
|
+
### Буквальные шаблоны
|
420
420
|
|
421
421
|
```ruby
|
422
422
|
get '/' do
|
@@ -436,7 +436,7 @@ require 'rdiscount' # или require 'bluecloth'
|
|
436
436
|
get('/') { markdown :index }
|
437
437
|
```
|
438
438
|
|
439
|
-
|
439
|
+
#### Haml шаблоны
|
440
440
|
|
441
441
|
<table>
|
442
442
|
<tr>
|
@@ -453,7 +453,7 @@ get('/') { markdown :index }
|
|
453
453
|
</tr>
|
454
454
|
</table>
|
455
455
|
|
456
|
-
|
456
|
+
#### Erb шаблоны
|
457
457
|
|
458
458
|
<table>
|
459
459
|
<tr>
|
@@ -473,7 +473,7 @@ get('/') { markdown :index }
|
|
473
473
|
</tr>
|
474
474
|
</table>
|
475
475
|
|
476
|
-
|
476
|
+
#### Builder шаблоны
|
477
477
|
|
478
478
|
<table>
|
479
479
|
<tr>
|
@@ -494,7 +494,7 @@ get('/') { markdown :index }
|
|
494
494
|
|
495
495
|
Блок также используется и для встроенных шаблонов (см. пример).
|
496
496
|
|
497
|
-
|
497
|
+
#### Nokogiri шаблоны
|
498
498
|
|
499
499
|
<table>
|
500
500
|
<tr>
|
@@ -513,7 +513,7 @@ get('/') { markdown :index }
|
|
513
513
|
|
514
514
|
Блок также используется и для встроенных шаблонов (см. пример).
|
515
515
|
|
516
|
-
|
516
|
+
#### Sass шаблоны
|
517
517
|
|
518
518
|
<table>
|
519
519
|
<tr>
|
@@ -530,7 +530,7 @@ get('/') { markdown :index }
|
|
530
530
|
</tr>
|
531
531
|
</table>
|
532
532
|
|
533
|
-
|
533
|
+
#### SCSS шаблоны
|
534
534
|
|
535
535
|
<table>
|
536
536
|
<tr>
|
@@ -547,7 +547,7 @@ get('/') { markdown :index }
|
|
547
547
|
</tr>
|
548
548
|
</table>
|
549
549
|
|
550
|
-
|
550
|
+
#### Less шаблоны
|
551
551
|
|
552
552
|
<table>
|
553
553
|
<tr>
|
@@ -564,7 +564,7 @@ get('/') { markdown :index }
|
|
564
564
|
</tr>
|
565
565
|
</table>
|
566
566
|
|
567
|
-
|
567
|
+
#### Liquid шаблоны
|
568
568
|
|
569
569
|
<table>
|
570
570
|
<tr>
|
@@ -584,7 +584,7 @@ get('/') { markdown :index }
|
|
584
584
|
Так как в Liquid шаблонах невозможно вызывать методы из Ruby (кроме `yield`), то
|
585
585
|
вы почти всегда будете передавать в шаблон локальные переменные.
|
586
586
|
|
587
|
-
|
587
|
+
#### Markdown шаблоны
|
588
588
|
|
589
589
|
<table>
|
590
590
|
<tr>
|
@@ -628,7 +628,7 @@ erb :overview, :locals => { :text => markdown(:introduction) }
|
|
628
628
|
один шаблонизатор для отображения шаблона, а другой для лэйаута с помощью
|
629
629
|
опции `:layout_engine`.
|
630
630
|
|
631
|
-
|
631
|
+
#### Textile шаблоны
|
632
632
|
|
633
633
|
<table>
|
634
634
|
<tr>
|
@@ -665,7 +665,7 @@ erb :overview, :locals => { :text => textile(:introduction) }
|
|
665
665
|
один шаблонизатор для отображения шаблона, а другой для лэйаута с помощью
|
666
666
|
опции `:layout_engine`.
|
667
667
|
|
668
|
-
|
668
|
+
#### RDoc шаблоны
|
669
669
|
|
670
670
|
<table>
|
671
671
|
<tr>
|
@@ -702,7 +702,7 @@ erb :overview, :locals => { :text => rdoc(:introduction) }
|
|
702
702
|
для отображения шаблона, а другой для лэйаута с помощью опции
|
703
703
|
`:layout_engine`.
|
704
704
|
|
705
|
-
|
705
|
+
#### Radius шаблоны
|
706
706
|
|
707
707
|
<table>
|
708
708
|
<tr>
|
@@ -722,7 +722,7 @@ erb :overview, :locals => { :text => rdoc(:introduction) }
|
|
722
722
|
Так как в Radius шаблонах невозможно вызывать методы из Ruby напрямую, то вы
|
723
723
|
почти всегда будете передавать в шаблон локальные переменные.
|
724
724
|
|
725
|
-
|
725
|
+
#### Markaby шаблоны
|
726
726
|
|
727
727
|
<table>
|
728
728
|
<tr>
|
@@ -741,7 +741,7 @@ erb :overview, :locals => { :text => rdoc(:introduction) }
|
|
741
741
|
|
742
742
|
Блок также используется и для встроенных шаблонов (см. пример).
|
743
743
|
|
744
|
-
|
744
|
+
#### RABL шаблоны
|
745
745
|
|
746
746
|
<table>
|
747
747
|
<tr>
|
@@ -758,7 +758,7 @@ erb :overview, :locals => { :text => rdoc(:introduction) }
|
|
758
758
|
</tr>
|
759
759
|
</table>
|
760
760
|
|
761
|
-
|
761
|
+
#### Slim шаблоны
|
762
762
|
|
763
763
|
<table>
|
764
764
|
<tr>
|
@@ -775,7 +775,7 @@ erb :overview, :locals => { :text => rdoc(:introduction) }
|
|
775
775
|
</tr>
|
776
776
|
</table>
|
777
777
|
|
778
|
-
|
778
|
+
#### Creole шаблоны
|
779
779
|
|
780
780
|
<table>
|
781
781
|
<tr>
|
@@ -812,7 +812,7 @@ erb :overview, :locals => { :text => creole(:introduction) }
|
|
812
812
|
один шаблонизатор для отображения шаблона, а другой для лэйаута с помощью
|
813
813
|
опции `:layout_engine`.
|
814
814
|
|
815
|
-
|
815
|
+
#### CoffeeScript шаблоны
|
816
816
|
|
817
817
|
<table>
|
818
818
|
<tr>
|
@@ -836,7 +836,7 @@ erb :overview, :locals => { :text => creole(:introduction) }
|
|
836
836
|
</tr>
|
837
837
|
</table>
|
838
838
|
|
839
|
-
|
839
|
+
#### Yajl шаблоны
|
840
840
|
|
841
841
|
<table>
|
842
842
|
<tr>
|
@@ -875,7 +875,7 @@ json[:baz] = key
|
|
875
875
|
var resource = {"foo":"bar","baz":"qux"}; present(resource);
|
876
876
|
```
|
877
877
|
|
878
|
-
|
878
|
+
#### WLang шаблоны
|
879
879
|
|
880
880
|
<table>
|
881
881
|
<tr>
|