sinatra 2.0.8 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sinatra might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +105 -2
- data/Gemfile +5 -4
- data/MAINTENANCE.md +2 -15
- data/README.de.md +16 -16
- data/README.es.md +62 -33
- data/README.fr.md +182 -85
- data/README.hu.md +3 -3
- data/README.ja.md +62 -32
- data/README.ko.md +1 -1
- data/README.md +93 -60
- data/README.pt-br.md +61 -61
- data/README.pt-pt.md +3 -3
- data/README.ru.md +3 -3
- data/README.zh.md +1 -1
- data/VERSION +1 -1
- data/examples/chat.rb +2 -1
- data/examples/rainbows.conf +3 -0
- data/examples/rainbows.rb +20 -0
- data/examples/stream.ru +4 -4
- data/lib/sinatra/base.rb +109 -68
- data/lib/sinatra/indifferent_hash.rb +27 -9
- data/lib/sinatra/main.rb +5 -5
- data/lib/sinatra/show_exceptions.rb +2 -37
- data/lib/sinatra/version.rb +1 -1
- data/sinatra.gemspec +4 -10
- metadata +10 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2fb7e9fa622d8e1a7b82842d5ac454fd4c1d7b9a52c229ddf64b7dc12433b15
|
4
|
+
data.tar.gz: 6f7d140ece387704a0f18b2d7a810829b06881e4759bd48474271664ad62abf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0b7bd428c8efde08d481f3fbe8c845f526f4ab4ed58ede99bbe215c42488195c7d70ea36746d04a041d39cd771f4da9cd30afe64063ab455e14f7c525066efb
|
7
|
+
data.tar.gz: d4e3b63eaf8b9bce3cf748934404b06b8e0cfeb96da0796e925895ce84d96743d058f09781053051931b67c8ceb56f1bd6b46c8f945f255c4fc24626a9db7571
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,108 @@
|
|
1
|
+
## 2.2.0 / Unrealased
|
2
|
+
|
3
|
+
* Handle EOFError raised by Rack and return Bad Request 400 status. [#1743](https://github.com/sinatra/sinatra/pull/1743) by tamazon
|
4
|
+
|
5
|
+
* Update README.es.md with removal of Thin. [#1630](https://github.com/sinatra/sinatra/pull/1630) by Espartaco Palma
|
6
|
+
|
7
|
+
* Minor refactors in `base.rb`. [#1640](https://github.com/sinatra/sinatra/pull/1640) by ceclinux
|
8
|
+
|
9
|
+
* Fixed typos in german README.md. [#1648](https://github.com/sinatra/sinatra/pull/1648) by Juri
|
10
|
+
|
11
|
+
* Add escaping to the static 404 page. [#1645](https://github.com/sinatra/sinatra/pull/1645) by Chris Gavin
|
12
|
+
|
13
|
+
* Remove `detect_rack_handler` method. [#1652](https://github.com/sinatra/sinatra/pull/1652) by ceclinux
|
14
|
+
|
15
|
+
* Respect content type set in superclass before filter. Fixes [#1647](https://github.com/sinatra/sinatra/issues/1647) [#1649](https://github.com/sinatra/sinatra/pull/1649) by Jordan Owens
|
16
|
+
|
17
|
+
* Update README.ja.md with removal of Thin. [#1629](https://github.com/sinatra/sinatra/pull/1629) by Ryuichi KAWAMATA
|
18
|
+
|
19
|
+
* *Revert "Use prepend instead of include for helpers.* [#1662](https://github.com/sinatra/sinatra/pull/1662) by namusyaka
|
20
|
+
|
21
|
+
* Various minor fixes to README.md. [#1663](https://github.com/sinatra/sinatra/pull/1663) by Yanis Zafirópulos
|
22
|
+
|
23
|
+
* Document when `dump_errors` is enabled. Fixes [#1664](https://github.com/sinatra/sinatra/issues/1664) [#1665](https://github.com/sinatra/sinatra/pull/1665) by Patrik Ragnarsson
|
24
|
+
|
25
|
+
* Update README.pt-br.md. [#1668](https://github.com/sinatra/sinatra/pull/1668) by Vitor Oliveira
|
26
|
+
|
27
|
+
* Fix usage of inherited `Sinatra::Base` classes keyword arguments. Fixes [#1669](https://github.com/sinatra/sinatra/issues/1669) [#1670](https://github.com/sinatra/sinatra/pull/1670) by Cadu Ribeiro
|
28
|
+
|
29
|
+
* Reduce RDoc generation time by not including every README. Fixes [#1578](https://github.com/sinatra/sinatra/issues/1578) [#1671](https://github.com/sinatra/sinatra/pull/1671) by Eloy Pérez
|
30
|
+
|
31
|
+
* Add support for per form csrf tokens. Fixes [#1616](https://github.com/sinatra/sinatra/issues/1616) [#1653](https://github.com/sinatra/sinatra/pull/1653) by Jordan Owens
|
32
|
+
|
33
|
+
* Update MAINTENANCE.md with the `stable` branch status. [#1681](https://github.com/sinatra/sinatra/pull/1681) by Fredrik Rubensson
|
34
|
+
|
35
|
+
* Validate expanded path matches `public_dir` when serving static files. [#1683](https://github.com/sinatra/sinatra/pull/1683) by cji-stripe
|
36
|
+
|
37
|
+
* Fix Delegator to pass keyword arguments for Ruby 3.0. [#1684](https://github.com/sinatra/sinatra/pull/1684) by andrewtblake
|
38
|
+
|
39
|
+
* Fix use with keyword arguments for Ruby 3.0. [#1701](https://github.com/sinatra/sinatra/pull/1701) by Robin Wallin
|
40
|
+
|
41
|
+
* Fix memory leaks for proc template. Fixes [#1704](https://github.com/sinatra/sinatra/issues/1714) [#1719](https://github.com/sinatra/sinatra/pull/1719) by Slevin
|
42
|
+
|
43
|
+
* Remove unnecessary `test_files` from the gemspec. [#1712](https://github.com/sinatra/sinatra/pull/1712) by Masataka Pocke Kuwabara
|
44
|
+
|
45
|
+
* Add `#select`, `#reject` and `#compact` methods to `Sinatra::IndifferentHash`. [#1711](https://github.com/sinatra/sinatra/pull/1711) by Olivier Bellone
|
46
|
+
|
47
|
+
|
48
|
+
### CI
|
49
|
+
|
50
|
+
* Use latest JRuby 9.2.16.0 on CI. [#1682](https://github.com/sinatra/sinatra/pull/1682) by Olle Jonsson
|
51
|
+
|
52
|
+
* Switch CI from travis to Github actions. [#1691](https://github.com/sinatra/sinatra/pull/1691) by namusyaka
|
53
|
+
|
54
|
+
* Skip the Slack action if `secrets.SLACK_WEBHOOK` is not set. [#1705](https://github.com/sinatra/sinatra/pull/1705) by Robin Wallin
|
55
|
+
|
56
|
+
* Small CI improvements. [#1703](https://github.com/sinatra/sinatra/pull/1703) by Robin Wallin
|
57
|
+
|
58
|
+
* Drop auto-generated boilerplate comments from CI configuration file. [#1728](https://github.com/sinatra/sinatra/pull/1728) by Olle Jonsson
|
59
|
+
|
60
|
+
### sinatra-contrib
|
61
|
+
|
62
|
+
* Do not raise when key is an enumerable. [#1619](https://github.com/sinatra/sinatra/pull/1619) by Ulysse Buonomo
|
63
|
+
|
64
|
+
### Rack protection
|
65
|
+
|
66
|
+
* Fix broken `origin_whitelist` option. Fixes [#1641](https://github.com/sinatra/sinatra/issues/1641) [#1642](https://github.com/sinatra/sinatra/pull/1642) by Takeshi YASHIRO
|
67
|
+
|
68
|
+
## 2.1.0 / 2020-09-05
|
69
|
+
|
70
|
+
* Fix additional Ruby 2.7 keyword warnings [#1586](https://github.com/sinatra/sinatra/pull/1586) by Stefan Sundin
|
71
|
+
|
72
|
+
* Drop Ruby 2.2 support [#1455](https://github.com/sinatra/sinatra/pull/1455) by Eloy Pérez
|
73
|
+
|
74
|
+
* Add Rack::Protection::ReferrerPolicy [#1291](https://github.com/sinatra/sinatra/pull/1291) by Stefan Sundin
|
75
|
+
|
76
|
+
* Add `default_content_type` setting. Fixes [#1238](https://github.com/sinatra/sinatra/pull/1238) [#1239](https://github.com/sinatra/sinatra/pull/1239) by Mike Pastore
|
77
|
+
|
78
|
+
* Allow `set :<engine>` in sinatra-namespace [#1255](https://github.com/sinatra/sinatra/pull/1255) by Christian Höppner
|
79
|
+
|
80
|
+
* Use prepend instead of include for helpers. Fixes [#1213](https://github.com/sinatra/sinatra/pull/1213) [#1214](https://github.com/sinatra/sinatra/pull/1214) by Mike Pastore
|
81
|
+
|
82
|
+
* Fix issue with passed routes and provides Fixes [#1095](https://github.com/sinatra/sinatra/pull/1095) [#1606](https://github.com/sinatra/sinatra/pull/1606) by Mike Pastore, Jordan Owens
|
83
|
+
|
84
|
+
* Add QuietLogger that excludes pathes from Rack::CommonLogger [1250](https://github.com/sinatra/sinatra/pull/1250) by Christoph Wagner
|
85
|
+
|
86
|
+
* Sinatra::Contrib dependency updates. Fixes [#1207](https://github.com/sinatra/sinatra/pull/1207) [#1411](https://github.com/sinatra/sinatra/pull/1411) by Mike Pastore
|
87
|
+
|
88
|
+
* Allow CSP to fallback to default-src. Fixes [#1484](https://github.com/sinatra/sinatra/pull/1484) [#1490](https://github.com/sinatra/sinatra/pull/1490) by Jordan Owens
|
89
|
+
|
90
|
+
* Replace `origin_whitelist` with `permitted_origins`. Closes [#1620](https://github.com/sinatra/sinatra/issues/1620) [#1625](https://github.com/sinatra/sinatra/pull/1625) by rhymes
|
91
|
+
|
92
|
+
* Use Rainbows instead of thin for async/stream features. Closes [#1624](https://github.com/sinatra/sinatra/issues/1624) [#1627](https://github.com/sinatra/sinatra/pull/1627) by Ryuichi KAWAMATA
|
93
|
+
|
94
|
+
* Enable EscapedParams if passed via settings. Closes [#1615](https://github.com/sinatra/sinatra/issues/1615) [#1632](https://github.com/sinatra/sinatra/issues/1632) by Anders Bälter
|
95
|
+
|
96
|
+
* Support for parameters in mime types. Fixes [#1141](https://github.com/sinatra/sinatra/issues/1141) by John Hope
|
97
|
+
|
98
|
+
* Handle null byte when serving static files [#1574](https://github.com/sinatra/sinatra/issues/1574) by Kush Fanikiso
|
99
|
+
|
100
|
+
* Improve development support and documentation and source code by Olle Jonsson, Pierre-Adrien Buisson, Shota Iguchi
|
101
|
+
|
102
|
+
## 2.0.8.1 / 2020-01-02
|
103
|
+
|
104
|
+
* Allow multiple hashes to be passed in `merge` and `merge!` for `Sinatra::IndifferentHash` [#1572](https://github.com/sinatra/sinatra/pull/1572) by Shota Iguchi
|
105
|
+
|
1
106
|
## 2.0.8 / 2020-01-01
|
2
107
|
|
3
108
|
* Lookup Tilt class for template engine without loading files [#1558](https://github.com/sinatra/sinatra/pull/1558). Fixes [#1172](https://github.com/sinatra/sinatra/issues/1172) by Jordan Owens
|
@@ -6,8 +111,6 @@
|
|
6
111
|
|
7
112
|
* Add `.yaml` support in `Sinatra::Contrib::ConfigFile` [#1564](https://github.com/sinatra/sinatra/issues/1564). Fixes [#1563](https://github.com/sinatra/sinatra/issues/1563) by Emerson Manabu Araki
|
8
113
|
|
9
|
-
* Allow multiple hashes to be passed in `merge` and `merge!` for `Sinatra::IndifferentHash` [#1572](https://github.com/sinatra/sinatra/pull/1572) by Shota Iguchi
|
10
|
-
|
11
114
|
* Remove only routing parameters from @params hash [#1569](https://github.com/sinatra/sinatra/pull/1569). Fixes [#1567](https://github.com/sinatra/sinatra/issues/1567) by Jordan Owens, Horacio
|
12
115
|
|
13
116
|
* Support `capture` and `content_for` with Hamlit [#1580](https://github.com/sinatra/sinatra/pull/1580) by Takashi Kokubun
|
data/Gemfile
CHANGED
@@ -11,7 +11,7 @@ source 'https://rubygems.org' unless ENV['QUICK']
|
|
11
11
|
gemspec
|
12
12
|
|
13
13
|
gem 'rake'
|
14
|
-
gem 'rack',
|
14
|
+
gem 'rack', '~> 2.0'
|
15
15
|
gem 'rack-test', '>= 0.6.2'
|
16
16
|
gem "minitest", "~> 5.0"
|
17
17
|
gem 'yard'
|
@@ -23,7 +23,7 @@ gem "twitter-text", "1.14.7"
|
|
23
23
|
|
24
24
|
if RUBY_ENGINE == 'jruby'
|
25
25
|
gem 'nokogiri', '!= 1.5.0'
|
26
|
-
gem '
|
26
|
+
gem 'puma'
|
27
27
|
end
|
28
28
|
|
29
29
|
if RUBY_ENGINE == 'jruby' || RUBY_ENGINE == 'ruby'
|
@@ -34,14 +34,15 @@ if RUBY_ENGINE == "ruby"
|
|
34
34
|
gem 'less', '~> 2.0'
|
35
35
|
gem 'therubyracer'
|
36
36
|
gem 'redcarpet'
|
37
|
-
gem 'wlang', '>=
|
37
|
+
gem 'wlang', '>= 3.0.1'
|
38
38
|
gem 'bluecloth'
|
39
39
|
gem 'rdiscount'
|
40
40
|
gem 'RedCloth'
|
41
41
|
gem 'puma'
|
42
42
|
gem 'yajl-ruby'
|
43
43
|
gem 'nokogiri'
|
44
|
-
gem '
|
44
|
+
gem 'rainbows'
|
45
|
+
gem 'eventmachine'
|
45
46
|
gem 'slim', '~> 2.0'
|
46
47
|
gem 'coffee-script', '>= 2.0'
|
47
48
|
gem 'rdoc'
|
data/MAINTENANCE.md
CHANGED
@@ -2,15 +2,9 @@
|
|
2
2
|
|
3
3
|
## Versions
|
4
4
|
|
5
|
-
###
|
5
|
+
### Releases
|
6
6
|
|
7
|
-
The next major version of Sinatra will be released from the master branch.
|
8
|
-
|
9
|
-
* Current proposed major release: 2.0.0
|
10
|
-
|
11
|
-
### Stable release
|
12
|
-
|
13
|
-
The current stable version of Sinatra is 1.4 series, and released from the stable branch.
|
7
|
+
The next major version of Sinatra will be released from the master branch. Each version will be tagged so it will be possible to branch of should there be a need for bug fixes and other updates.
|
14
8
|
|
15
9
|
## Issues
|
16
10
|
|
@@ -22,21 +16,14 @@ New features will only be added to the master branch and will not be made availa
|
|
22
16
|
|
23
17
|
Only the latest release series will receive bug fixes. When enough bugs are fixed and its deemed worthy to release a new gem, this is the branch it happens from.
|
24
18
|
|
25
|
-
* Current release series: 1.4.x
|
26
|
-
|
27
19
|
### Security issues
|
28
20
|
|
29
21
|
The current release series will receive patches and new versions in case of a security issue.
|
30
22
|
|
31
|
-
* Current release series: 1.4.x
|
32
|
-
|
33
23
|
### Severe security issues
|
34
24
|
|
35
25
|
For severe security issues we will provide new versions as above, and also the last major release series will receive patches and new versions. The classification of the security issue is judged by the core team.
|
36
26
|
|
37
|
-
* Current release series: 1.4.x
|
38
|
-
* Next most recent release series: 1.3.x
|
39
|
-
|
40
27
|
### Unsupported Release Series
|
41
28
|
|
42
29
|
When a release series is no longer supported, it’s your own responsibility to deal with bugs and security issues. We may provide back-ports of the fixes and publish them to git, however there will be no new versions released. If you are not comfortable maintaining your own versions, you should upgrade to a supported version.
|
data/README.de.md
CHANGED
@@ -35,7 +35,7 @@ ruby myapp.rb
|
|
35
35
|
Die Seite kann nun unter [http://localhost:4567](http://localhost:4567)
|
36
36
|
aufgerufen werden.
|
37
37
|
|
38
|
-
Es wird empfohlen `gem
|
38
|
+
Es wird empfohlen `gem install thin` auszuführen, Sinatra wird dann
|
39
39
|
diesen Server verwenden.
|
40
40
|
|
41
41
|
## Inhalt
|
@@ -362,7 +362,7 @@ einen Rack-Rückgabewert, einen Rack-Body oder einen HTTP-Status-Code handelt:
|
|
362
362
|
* Ein Array mit zwei Elementen: `[Status (Integer), Response-Body (antwortet
|
363
363
|
auf #each)]`.
|
364
364
|
* Ein Objekt, das auf `#each` antwortet und den an diese Methode übergebenen
|
365
|
-
Block nur mit Strings als
|
365
|
+
Block nur mit Strings als Übergabewerten aufruft.
|
366
366
|
* Ein Integer, das den Status-Code festlegt.
|
367
367
|
|
368
368
|
Damit lässt sich relativ einfach Streaming implementieren:
|
@@ -434,7 +434,7 @@ Statische Dateien werden im `./public`-Ordner erwartet. Es ist möglich,
|
|
434
434
|
einen anderen Ort zu definieren, indem man die `:public_folder`-Option setzt:
|
435
435
|
|
436
436
|
```ruby
|
437
|
-
set :public_folder,
|
437
|
+
set :public_folder, __dir__ + '/static'
|
438
438
|
```
|
439
439
|
|
440
440
|
Zu beachten ist, dass der Ordnername `public` nicht Teil der URL ist.
|
@@ -467,7 +467,7 @@ get '/' do
|
|
467
467
|
end
|
468
468
|
```
|
469
469
|
|
470
|
-
Templates nehmen ein
|
470
|
+
Templates nehmen ein zweites Argument an, den Options-Hash:
|
471
471
|
|
472
472
|
```ruby
|
473
473
|
get '/' do
|
@@ -1114,7 +1114,7 @@ end
|
|
1114
1114
|
</table>
|
1115
1115
|
|
1116
1116
|
Die Template-Quelle wird als Ruby-String evaluiert. Die daraus resultierende
|
1117
|
-
|
1117
|
+
Json-Variable wird mit Hilfe von `#to_json` umgewandelt:
|
1118
1118
|
|
1119
1119
|
```ruby
|
1120
1120
|
json = { :foo => 'bar' }
|
@@ -1438,16 +1438,16 @@ keinen Schlüssel zu verwenden, dessen Zufälligkeit weniger als 32 Bytes
|
|
1438
1438
|
entspricht (also 256 Bits, 64 Hex-Zeichen). Es ist deshalb **wirklich
|
1439
1439
|
wichtig**, dass nicht einfach irgendetwas als Schlüssel verwendet wird,
|
1440
1440
|
sondern ein sicherer Zufallsgenerator die Zeichenkette erstellt. Menschen sind
|
1441
|
-
nicht besonders gut, zufällige Zeichenfolgen zu erstellen.
|
1441
|
+
nicht besonders gut darin, zufällige Zeichenfolgen zu erstellen.
|
1442
1442
|
|
1443
|
-
Sinatra generiert automatisch einen zufälligen 32 Byte langen
|
1443
|
+
Sinatra generiert automatisch einen zufälligen, 32 Byte langen
|
1444
1444
|
Schlüssel. Da jedoch bei jedem Neustart der Schlüssel ebenfalls neu generiert
|
1445
1445
|
wird, ist es sinnvoll einen eigenen Schlüssel festzulegen, damit er über alle
|
1446
1446
|
Anwendungsinstanzen hinweg geteilt werden kann.
|
1447
1447
|
|
1448
1448
|
Aus praktikablen und Sicherheitsgründen wird
|
1449
1449
|
[empfohlen](https://12factor.net/config), dass ein sicherer Zufallswert
|
1450
|
-
erzeugt und in einer Umgebungsvariable
|
1450
|
+
erzeugt und in einer Umgebungsvariable abgelegt wird, damit alle
|
1451
1451
|
Anwendungsinstanzen darauf zugreifen können. Dieser Sitzungsschlüssel
|
1452
1452
|
sollte in regelmäßigen Abständen erneuert werden. Zum Erzeugen von 64
|
1453
1453
|
Byte starken Schlüsseln sind hier ein paar Beispiele vorgestellt:
|
@@ -1850,7 +1850,7 @@ get '/bar' do
|
|
1850
1850
|
end
|
1851
1851
|
```
|
1852
1852
|
|
1853
|
-
Um Argumente an
|
1853
|
+
Um Argumente an einen Redirect weiterzugeben, können sie entweder dem Query
|
1854
1854
|
übergeben:
|
1855
1855
|
|
1856
1856
|
```ruby
|
@@ -2083,7 +2083,7 @@ get '/' do
|
|
2083
2083
|
end
|
2084
2084
|
```
|
2085
2085
|
|
2086
|
-
Ebenso kann
|
2086
|
+
Ebenso kann ein Dateiname als Parameter hinzugefügt werden:
|
2087
2087
|
|
2088
2088
|
```ruby
|
2089
2089
|
get '/' do
|
@@ -2153,7 +2153,7 @@ helpers do
|
|
2153
2153
|
end
|
2154
2154
|
```
|
2155
2155
|
|
2156
|
-
Ein anderes Beispiel wäre, verschiedene
|
2156
|
+
Ein anderes Beispiel wäre, verschiedene Verzeichnisse für verschiedene Engines
|
2157
2157
|
zu verwenden:
|
2158
2158
|
|
2159
2159
|
```ruby
|
@@ -2175,7 +2175,7 @@ Beachte, dass `find_template` nicht prüft, ob eine Datei tatsächlich
|
|
2175
2175
|
existiert. Es wird lediglich der angegebene Block aufgerufen und nach allen
|
2176
2176
|
möglichen Pfaden gesucht. Das ergibt kein Performance-Problem, da `render`
|
2177
2177
|
`block` verwendet, sobald eine Datei gefunden wurde. Ebenso werden
|
2178
|
-
Template-Pfade samt
|
2178
|
+
Template-Pfade samt Inhalten gecached, solange nicht im Entwicklungsmodus
|
2179
2179
|
gearbeitet wird. Das sollte im Hinterkopf behalten werden, wenn irgendwelche
|
2180
2180
|
verrückten Methoden zusammengebastelt werden.
|
2181
2181
|
|
@@ -2306,7 +2306,7 @@ set :protection, session => true
|
|
2306
2306
|
|
2307
2307
|
<dt>bind</dt>
|
2308
2308
|
<dd>
|
2309
|
-
IP-
|
2309
|
+
IP-Adresse, an die gebunden wird (Standardwert: <tt>0.0.0.0</tt>
|
2310
2310
|
<em>oder</em> <tt>localhost</tt>). Wird nur für den eingebauten Server
|
2311
2311
|
verwendet.
|
2312
2312
|
</dd>
|
@@ -2439,7 +2439,7 @@ set :protection, session => true
|
|
2439
2439
|
|
2440
2440
|
<dt>show_exceptions</dt>
|
2441
2441
|
<dd>
|
2442
|
-
Bei Fehlern einen Stacktrace im
|
2442
|
+
Bei Fehlern einen Stacktrace im Browser anzeigen. Ist automatisch
|
2443
2443
|
aktiviert, wenn die Umgebung auf <tt>"development"</tt>
|
2444
2444
|
eingestellt ist. Ansonsten ist diese Option deaktiviert.
|
2445
2445
|
</dd>
|
@@ -3120,9 +3120,9 @@ thin --threaded start
|
|
3120
3120
|
Die folgenden Versionen werden offiziell unterstützt:
|
3121
3121
|
|
3122
3122
|
<dl>
|
3123
|
-
<dt>Ruby 2.
|
3123
|
+
<dt>Ruby 2.3</dt>
|
3124
3124
|
<dd>
|
3125
|
-
2.
|
3125
|
+
2.3 wird vollständig unterstützt. Es gibt derzeit keine Pläne die
|
3126
3126
|
offizielle Unterstützung zu beenden
|
3127
3127
|
</dd>
|
3128
3128
|
|
data/README.es.md
CHANGED
@@ -33,7 +33,7 @@ Ver en [http://localhost:4567](http://localhost:4567).
|
|
33
33
|
El código que cambiaste no tendra efecto hasta que reinicies el servidor.
|
34
34
|
Por favor reinicia el servidor cada vez que cambies tu código o usa [sinatra/reloader](http://www.sinatrarb.com/contrib/reloader).
|
35
35
|
|
36
|
-
Se recomienda ejecutar `gem install
|
36
|
+
Se recomienda ejecutar `gem install puma`, porque Sinatra lo utilizará si está disponible.
|
37
37
|
|
38
38
|
|
39
39
|
## Tabla de Contenidos
|
@@ -430,7 +430,7 @@ Los archivos estáticos son servidos desde el directorio público
|
|
430
430
|
opción `:public_folder`:
|
431
431
|
|
432
432
|
```ruby
|
433
|
-
set :public_folder,
|
433
|
+
set :public_folder, __dir__ + '/static'
|
434
434
|
```
|
435
435
|
|
436
436
|
Note que el nombre del directorio público no está incluido en la URL. Por
|
@@ -1692,38 +1692,57 @@ Shotgun, el streaming no va a funcionar.
|
|
1692
1692
|
Cuando se pasa `keep_open` como parámetro, no se va a enviar el mensaje
|
1693
1693
|
`close` al objeto de stream. Permite que tu lo cierres en el punto de ejecución
|
1694
1694
|
que quieras. Nuevamente, hay que tener en cuenta que este comportamiento es
|
1695
|
-
posible
|
1695
|
+
posible sólo en servidores que soporten eventos, como Rainbows. El
|
1696
1696
|
resto de los servidores van a cerrar el stream de todos modos:
|
1697
1697
|
|
1698
1698
|
```ruby
|
1699
|
-
# long polling
|
1700
1699
|
|
1701
|
-
|
1702
|
-
|
1700
|
+
# config.ru
|
1701
|
+
require 'sinatra/base'
|
1703
1702
|
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
#
|
1709
|
-
|
1703
|
+
class App < Sinatra::Base
|
1704
|
+
connections = []
|
1705
|
+
|
1706
|
+
get '/subscribe' do
|
1707
|
+
# registrar a un cliente interesado en los eventos del servidor
|
1708
|
+
stream(:keep_open) do |out|
|
1709
|
+
connections << out
|
1710
|
+
# purgar conexiones muertas
|
1711
|
+
connections.reject!(&:closed?)
|
1712
|
+
end
|
1710
1713
|
end
|
1711
|
-
end
|
1712
1714
|
|
1713
|
-
post '/:message' do
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1715
|
+
post '/:message' do
|
1716
|
+
connections.each do |out|
|
1717
|
+
# notificar al cliente que ha llegado un nuevo mensaje
|
1718
|
+
out << params['message'] << "\n"
|
1719
|
+
|
1720
|
+
# indicar al cliente para conectarse de nuevo
|
1721
|
+
out.close
|
1722
|
+
end
|
1717
1723
|
|
1718
|
-
#
|
1719
|
-
|
1724
|
+
# reconocer
|
1725
|
+
"message received"
|
1720
1726
|
end
|
1727
|
+
end
|
1728
|
+
|
1729
|
+
run App
|
1730
|
+
```
|
1731
|
+
|
1732
|
+
```ruby
|
1733
|
+
# rainbows.conf
|
1721
1734
|
|
1722
|
-
|
1723
|
-
|
1735
|
+
Rainbows! do
|
1736
|
+
use :EventMachine
|
1724
1737
|
end
|
1725
1738
|
```
|
1726
1739
|
|
1740
|
+
Ejecute:
|
1741
|
+
|
1742
|
+
```shell
|
1743
|
+
rainbows -c rainbows.conf
|
1744
|
+
```
|
1745
|
+
|
1727
1746
|
También es posible que el cliente cierre la conexión cuando intenta
|
1728
1747
|
escribir en el socket. Debido a esto, se recomienda verificar con
|
1729
1748
|
`out.closed?` antes de intentar escribir.
|
@@ -2394,13 +2413,13 @@ set :protection, :except => [:path_traversal, :session_hijacking]
|
|
2394
2413
|
<dt>server</dt>
|
2395
2414
|
<dd>
|
2396
2415
|
Servidor, o lista de servidores, para usar como servidor
|
2397
|
-
integrado.
|
2398
|
-
|
2416
|
+
integrado. El orden indica su prioridad, por defecto depende
|
2417
|
+
de la implementación de Ruby.
|
2399
2418
|
</dd>
|
2400
2419
|
|
2401
2420
|
<dt>server_settings</dt>
|
2402
2421
|
<dd>
|
2403
|
-
Si está utilizando un servidor web WEBrick, presumiblemente para su entorno de desarrollo, puede pasar un hash de opciones a <tt> server_settings </tt>, como <tt> SSLEnable </tt> o <tt> SSLVerifyClient </tt>. Sin embargo, los servidores web como Puma
|
2422
|
+
Si está utilizando un servidor web WEBrick, presumiblemente para su entorno de desarrollo, puede pasar un hash de opciones a <tt> server_settings </tt>, como <tt> SSLEnable </tt> o <tt> SSLVerifyClient </tt>. Sin embargo, los servidores web como Puma no son compatibles, por lo que puede establecer <tt> server_settings </tt> definiéndolo como un método cuando llame a <tt> configure </tt>.
|
2404
2423
|
</dd>
|
2405
2424
|
|
2406
2425
|
<dt>sessions</dt>
|
@@ -2452,7 +2471,7 @@ información.
|
|
2452
2471
|
|
2453
2472
|
<dt>threaded</dt>
|
2454
2473
|
<dd>
|
2455
|
-
Si se establece en <tt> true </tt>, le dirá
|
2474
|
+
Si se establece en <tt> true </tt>, le dirá al servidor que use
|
2456
2475
|
<tt> EventMachine.defer </tt> para procesar la solicitud.
|
2457
2476
|
</dd>
|
2458
2477
|
|
@@ -3040,7 +3059,7 @@ Las opciones son:
|
|
3040
3059
|
-p # asigna el puerto (4567 es usado por defecto)
|
3041
3060
|
-o # asigna el host (0.0.0.0 es usado por defecto)
|
3042
3061
|
-e # asigna el entorno (development es usado por defecto)
|
3043
|
-
-s # especifica el servidor/manejador rack (
|
3062
|
+
-s # especifica el servidor/manejador rack (puma es usado por defecto)
|
3044
3063
|
-q # activar el modo silecioso para el servidor (está desactivado por defecto)
|
3045
3064
|
-x # activa el mutex lock (está desactivado por defecto)
|
3046
3065
|
```
|
@@ -3050,16 +3069,16 @@ Las opciones son:
|
|
3050
3069
|
_Basado en [esta respuesta en StackOverflow](http://stackoverflow.com/questions/6278817/is-sinatra-multi-threaded/6282999#6282999) escrita por Konstantin_
|
3051
3070
|
|
3052
3071
|
Sinatra no impone ningún modelo de concurrencia, sino que lo deja en manos del
|
3053
|
-
handler Rack que se esté usando (
|
3072
|
+
handler Rack que se esté usando (Puma o WEBrick). Sinatra en sí mismo es
|
3054
3073
|
thread-safe, así que no hay problema en que el Rack handler use un modelo de
|
3055
3074
|
concurrencia basado en hilos.
|
3056
3075
|
|
3057
3076
|
Esto significa que, cuando estemos arrancando el servidor, tendríamos que
|
3058
3077
|
especificar la opción adecuada para el handler Rack específico. En este ejemplo
|
3059
|
-
vemos cómo arrancar un servidor
|
3078
|
+
vemos cómo arrancar un servidor Rainbows multihilo:
|
3060
3079
|
|
3061
3080
|
```ruby
|
3062
|
-
#
|
3081
|
+
# config.ru
|
3063
3082
|
|
3064
3083
|
require 'sinatra/base'
|
3065
3084
|
|
@@ -3069,13 +3088,23 @@ class App < Sinatra::Base
|
|
3069
3088
|
end
|
3070
3089
|
end
|
3071
3090
|
|
3072
|
-
App
|
3091
|
+
run App
|
3092
|
+
```
|
3093
|
+
|
3094
|
+
```ruby
|
3095
|
+
# rainbows.conf
|
3096
|
+
|
3097
|
+
# El configurador de Rainbows está basado en Unicorn.
|
3098
|
+
|
3099
|
+
Rainbows! do
|
3100
|
+
use :ThreadSpawn
|
3101
|
+
end
|
3073
3102
|
```
|
3074
3103
|
|
3075
3104
|
Para arrancar el servidor, el comando sería:
|
3076
3105
|
|
3077
3106
|
```shell
|
3078
|
-
|
3107
|
+
rainbows -c rainbows.conf
|
3079
3108
|
```
|
3080
3109
|
|
3081
3110
|
## Requerimientos
|
@@ -3083,9 +3112,9 @@ thin --threaded start
|
|
3083
3112
|
Las siguientes versiones de Ruby son soportadas oficialmente:
|
3084
3113
|
|
3085
3114
|
<dl>
|
3086
|
-
<dt>Ruby 2.
|
3115
|
+
<dt>Ruby 2.3</dt>
|
3087
3116
|
<dd>
|
3088
|
-
2.
|
3117
|
+
2.3 Es totalmente compatible y recomendado. Actualmente no hay planes
|
3089
3118
|
soltar el apoyo oficial para ello.
|
3090
3119
|
</dd>
|
3091
3120
|
|