sinatra 2.1.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a13ef28ef13aa508887d370e6e666ec7af2aa27d464c2c3907fe72f3f3091fcb
4
- data.tar.gz: 0aef31461f40ec12007e04dcfc8df077ce389a8710ef79c74466ba08eedd8085
3
+ metadata.gz: d2fb7e9fa622d8e1a7b82842d5ac454fd4c1d7b9a52c229ddf64b7dc12433b15
4
+ data.tar.gz: 6f7d140ece387704a0f18b2d7a810829b06881e4759bd48474271664ad62abf2
5
5
  SHA512:
6
- metadata.gz: b93f4761e873891715668e34a695e35bb0f57983f7bf260440a7d06ead5e4b88cdeb173f4f093e74aada601b54773df47211d882ea30880fe98c0f4225cd4846
7
- data.tar.gz: 2aaa6acfcbcb7f2e875820ba61b243916de46c0c689182afbb13f59a168a74f0bff6a0c546e47f29a60804311d960bc26cc5c897c15b05f9f26e677c60e939e3
6
+ metadata.gz: a0b7bd428c8efde08d481f3fbe8c845f526f4ab4ed58ede99bbe215c42488195c7d70ea36746d04a041d39cd771f4da9cd30afe64063ab455e14f7c525066efb
7
+ data.tar.gz: d4e3b63eaf8b9bce3cf748934404b06b8e0cfeb96da0796e925895ce84d96743d058f09781053051931b67c8ceb56f1bd6b46c8f945f255c4fc24626a9db7571
data/CHANGELOG.md CHANGED
@@ -1,3 +1,70 @@
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
+
1
68
  ## 2.1.0 / 2020-09-05
2
69
 
3
70
  * Fix additional Ruby 2.7 keyword warnings [#1586](https://github.com/sinatra/sinatra/pull/1586) by Stefan Sundin
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', git: 'https://github.com/rack/rack.git'
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 'trinidad'
26
+ gem 'puma'
27
27
  end
28
28
 
29
29
  if RUBY_ENGINE == 'jruby' || RUBY_ENGINE == 'ruby'
@@ -34,7 +34,7 @@ if RUBY_ENGINE == "ruby"
34
34
  gem 'less', '~> 2.0'
35
35
  gem 'therubyracer'
36
36
  gem 'redcarpet'
37
- gem 'wlang', '>= 2.0.1'
37
+ gem 'wlang', '>= 3.0.1'
38
38
  gem 'bluecloth'
39
39
  gem 'rdiscount'
40
40
  gem 'RedCloth'
data/MAINTENANCE.md CHANGED
@@ -2,15 +2,9 @@
2
2
 
3
3
  ## Versions
4
4
 
5
- ### Unstable release
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 installl thin` auszuführen, Sinatra wird dann
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 Übergabewerte aufruft.
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:
@@ -467,7 +467,7 @@ get '/' do
467
467
  end
468
468
  ```
469
469
 
470
- Templates nehmen ein zweite Argument an, den Options-Hash:
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
- json Variable wird mit Hilfe von `#to_json` umgewandelt:
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 zufälligen
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 abgelgegt wird, damit alle
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 ein Redirect weiterzugeben, können sie entweder dem Query
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 eine Dateiname als Parameter hinzugefügt werden:
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 Vereichnisse für verschiedene Engines
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 Inhalt gecached, solange nicht im Entwicklungsmodus
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-Address, an die gebunden wird (Standardwert: <tt>0.0.0.0</tt>
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 Browseranzeigen. Ist automatisch
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>
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 thin`, porque Sinatra lo utilizará si está disponible.
36
+ Se recomienda ejecutar `gem install puma`, porque Sinatra lo utilizará si está disponible.
37
37
 
38
38
 
39
39
  ## Tabla de Contenidos
@@ -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 solo en servidores que soporten eventos, como Thin o Rainbows. El
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
- set :server, :thin
1702
- connections = []
1700
+ # config.ru
1701
+ require 'sinatra/base'
1703
1702
 
1704
- get '/subscribe' do
1705
- # registrar a un cliente interesado en los eventos del servidor
1706
- stream(:keep_open) do |out|
1707
- connections << out
1708
- # purgar conexiones muertas
1709
- connections.reject!(&:closed?)
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
- connections.each do |out|
1715
- # notificar al cliente que ha llegado un nuevo mensaje
1716
- out << params['message'] << "\n"
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
- # indicar al cliente para conectarse de nuevo
1719
- out.close
1724
+ # reconocer
1725
+ "message received"
1720
1726
  end
1727
+ end
1728
+
1729
+ run App
1730
+ ```
1731
+
1732
+ ```ruby
1733
+ # rainbows.conf
1721
1734
 
1722
- # reconocer
1723
- "message received"
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. Por defecto: <tt>['thin', 'mongrel', 'webrick']</tt>,
2398
- el orden establece la prioridad.
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 y Thin no son compatibles, por lo que puede establecer <tt> server_settings </tt> definiéndolo como un método cuando llame a <tt> configure </tt>.
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á a Thin que use
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 (thin es usado por defecto)
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 (Thin, Puma, WEBrick). Sinatra en sí mismo es
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 Thin multihilo:
3078
+ vemos cómo arrancar un servidor Rainbows multihilo:
3060
3079
 
3061
3080
  ```ruby
3062
- # app.rb
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.run!
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
- thin --threaded start
3107
+ rainbows -c rainbows.conf
3079
3108
  ```
3080
3109
 
3081
3110
  ## Requerimientos
data/README.ja.md CHANGED
@@ -28,7 +28,10 @@ ruby myapp.rb
28
28
 
29
29
  [http://localhost:4567](http://localhost:4567) を開きます。
30
30
 
31
- ThinがあればSinatraはこれを利用するので、`gem install thin`することをお薦めします。
31
+ コードを変更しても、サーバを再起動しないと変更が有効になりません。
32
+ コードを変更するたびにサーバを再起動するか、[sinatra/reloader](http://www.sinatrarb.com/contrib/reloader)を使ってください。
33
+
34
+ PumaがあればSinatraはこれを利用するので、`gem install puma`することをお薦めします。
32
35
 
33
36
  ## 目次
34
37
 
@@ -747,7 +750,7 @@ erb :overview, :locals => { :text => textile(:introduction) }
747
750
  %p= textile(:greetings)
748
751
  ```
749
752
 
750
- TexttileからはRubyを呼ぶことができないので、Textileで書かれたレイアウトを使うことはできません。しかしながら、`:layout_engine`オプションを渡すことでテンプレートのものとは異なるレンダリングエンジンをレイアウトのために使うことができます。
753
+ TextileからはRubyを呼ぶことができないので、Textileで書かれたレイアウトを使うことはできません。しかしながら、`:layout_engine`オプションを渡すことでテンプレートのものとは異なるレンダリングエンジンをレイアウトのために使うことができます。
751
754
 
752
755
  #### RDoc テンプレート
753
756
 
@@ -1482,37 +1485,55 @@ end
1482
1485
 
1483
1486
  これはストリーミングAPI、[Server Sent Events](https://w3c.github.io/eventsource/)の実装を可能にし、[WebSockets](https://en.wikipedia.org/wiki/WebSocket)の土台に使うことができます。また、一部のコンテンツが遅いリソースに依存しているときに、スループットを上げるために使うこともできます。
1484
1487
 
1485
- ノート: ストリーミングの挙動、特に並行リクエスト(cuncurrent requests)の数は、アプリケーションを提供するのに使われるWebサーバに強く依存します。いくつかのサーバは、ストリーミングを全くサポートしません。サーバがストリーミングをサポートしない場合、ボディは`stream`に渡されたブロックの実行が終了した後、一度に全部送られることになります。ストリーミングは、Shotgunを使った場合は全く動作しません。
1488
+ ノート: ストリーミングの挙動、特に並行リクエスト(concurrent requests)の数は、アプリケーションを提供するのに使われるWebサーバに強く依存します。いくつかのサーバは、ストリーミングを全くサポートしません。サーバがストリーミングをサポートしない場合、ボディは`stream`に渡されたブロックの実行が終了した後、一度に全部送られることになります。ストリーミングは、Shotgunを使った場合は全く動作しません。
1486
1489
 
1487
- オプション引数が`keep_open`にセットされている場合、ストリームオブジェクト上で`close`は呼ばれず、実行フローの任意の遅れたタイミングでユーザがこれを閉じることを可能にします。これはThinやRainbowsのようなイベント型サーバ上でしか機能しません。他のサーバでは依然ストリームは閉じられます。
1490
+ オプション引数が`keep_open`にセットされている場合、ストリームオブジェクト上で`close`は呼ばれず、実行フローの任意の遅れたタイミングでユーザがこれを閉じることを可能にします。これはRainbowsのようなイベント型サーバ上でしか機能しません。他のサーバでは依然ストリームは閉じられます。
1488
1491
 
1489
1492
  ```ruby
1490
- # ロングポーリング
1491
-
1492
- set :server, :thin
1493
- connections = []
1493
+ # config.ru
1494
+ require 'sinatra/base'
1494
1495
 
1495
- get '/subscribe' do
1496
- # サーバイベントにおけるクライアントの関心を登録
1497
- stream(:keep_open) do |out|
1498
- connections << out
1499
- # 死んでいるコネクションを排除
1500
- connections.reject!(&:closed?)
1496
+ class App < Sinatra::Base
1497
+ connections = []
1498
+
1499
+ get '/subscribe' do
1500
+ # register a client's interest in server events
1501
+ # サーバイベントにおけるクライアントの関心を登録
1502
+ stream(:keep_open) do |out|
1503
+ connections << out
1504
+ # 死んでいるコネクションを排除
1505
+ connections.reject!(&:closed?)
1506
+ end
1501
1507
  end
1502
- end
1503
1508
 
1504
- post '/message' do
1505
- connections.each do |out|
1506
- # クライアントへ新規メッセージ到着の通知
1507
- out << params['message'] << "\n"
1509
+ post '/:message' do
1510
+ connections.each do |out|
1511
+ # クライアントへ新規メッセージ到着の通知
1512
+ out << params['message'] << "\n"
1508
1513
 
1509
- # クライアントへの再接続の指示
1510
- out.close
1514
+ # クライアントへの再接続の指示
1515
+ out.close
1516
+ end
1517
+
1518
+ # 肯定応答
1519
+ "message received"
1511
1520
  end
1521
+ end
1522
+
1523
+ run App
1524
+ ```
1512
1525
 
1513
- # 肯定応答
1514
- "message received"
1526
+ ```ruby
1527
+ # rainbows.conf
1528
+ Rainbows! do
1529
+ use :EventMachine
1515
1530
  end
1531
+ ````
1532
+
1533
+ 次のように起動します。
1534
+
1535
+ ```shell
1536
+ rainbows -c rainbows.conf
1516
1537
  ```
1517
1538
 
1518
1539
  クライアントはソケットに書き込もうとしている接続を閉じることも可能です。そのため、記述しようとする前に`out.closed?`をチェックすることを勧めます。
@@ -2107,7 +2128,7 @@ set :protection, :session => true
2107
2128
 
2108
2129
  <dt>threaded</dt>
2109
2130
  <dd>
2110
- <tt>true</tt>に設定されているときは、Thinにリクエストを処理するために<tt>EventMachine.defer</tt>を使うことを通知する。
2131
+ <tt>true</tt>に設定されているときは、サーバにリクエストを処理するために<tt>EventMachine.defer</tt>を使うことを通知する。
2111
2132
  </dd>
2112
2133
 
2113
2134
  <dt>views</dt>
@@ -2631,7 +2652,7 @@ ruby myapp.rb [-h] [-x] [-e ENVIRONMENT] [-p PORT] [-o HOST] [-s HANDLER]
2631
2652
  -p # ポート指定(デフォルトは4567)
2632
2653
  -o # ホスト指定(デフォルトは0.0.0.0)
2633
2654
  -e # 環境を指定 (デフォルトはdevelopment)
2634
- -s # rackserver/handlerを指定 (デフォルトはthin)
2655
+ -s # rackserver/handlerを指定 (デフォルトはpuma)
2635
2656
  -x # mutex lockを付ける (デフォルトはoff)
2636
2657
  ```
2637
2658
 
@@ -2640,13 +2661,13 @@ ruby myapp.rb [-h] [-x] [-e ENVIRONMENT] [-p PORT] [-o HOST] [-s HANDLER]
2640
2661
  _この[StackOverflow](https://stackoverflow.com/a/6282999/5245129)
2641
2662
  のKonstantinによる回答を言い換えています。_
2642
2663
 
2643
- Sinatraでは同時実行モデルを負わせることはできませんが、根本的な部分であるThinやPuma、WebrickのようなRackハンドラ(サーバー)部分に委ねることができます。
2664
+ Sinatraでは同時実行モデルを負わせることはできませんが、根本的な部分であるやPuma、WEBrickのようなRackハンドラ(サーバー)部分に委ねることができます。
2644
2665
  Sinatra自身はスレッドセーフであり、もしRackハンドラが同時実行モデルのスレッドを使用していても問題はありません。
2645
2666
  つまり、これはサーバーを起動させる時、特定のRackハンドラに対して正しい起動処理を特定することが出来ます。
2646
- この例はThinサーバーをマルチスレッドで起動する方法のデモです。
2667
+ この例はRainbowsサーバーをマルチスレッドで起動する方法のデモです。
2647
2668
 
2648
2669
  ```ruby
2649
- # app.rb
2670
+ # config.ru
2650
2671
 
2651
2672
  require 'sinatra/base'
2652
2673
 
@@ -2656,13 +2677,22 @@ class App < Sinatra::Base
2656
2677
  end
2657
2678
  end
2658
2679
 
2659
- App.run!
2680
+ run App
2681
+ ```
2682
+
2683
+ ```ruby
2684
+ # rainbows.conf
2685
+
2686
+ # RainbowsのコンフィギュレータはUnicornのものをベースにしています。
2687
+ Rainbows! do
2688
+ use :ThreadSpawn
2689
+ end
2660
2690
  ```
2661
2691
 
2662
- サーバーを開始するコマンドです。
2692
+ 次のようなコマンドでサーバを起動します。
2663
2693
 
2664
2694
  ```
2665
- thin --threaded start
2695
+ rainbows -c rainbows.conf
2666
2696
  ```
2667
2697
 
2668
2698
  ## 必要環境