sinatra 3.0.5 → 3.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 253794a685657aa33414a6384abfa99f0c4b0a8aa97a9f15aa6d5ae88bcd747e
4
- data.tar.gz: 455faa2397e06210cdeeb6e90eb5b8ec56908695585c869bb9241afc1e480cca
3
+ metadata.gz: '08567da318760f376b1c6c8ccafd4e1268ff19a800c90939d9f1448a7c85edcb'
4
+ data.tar.gz: 4287d74952e33c257cd981ed731e732cd0811dbeaeeb7fa553817ef3ad44a9d8
5
5
  SHA512:
6
- metadata.gz: b8ca8d0630ca6a5b420a6066ac6bb0375092e92a549bf623974a8780b576b859a227eccf32402ffb4628a04523c107420cda5982bcc69a14dbb3779ff299b255
7
- data.tar.gz: 85352987ea63bcbdfa6a80af67a59e5e3e4e812f1aaf4f28016ebd085805934ffa2787278b3034cef623ee5ed278bb5b66eeb02f390b6b8fea5326f7f039c4d7
6
+ metadata.gz: af4979f21e7a5bc8e2aebadc68138ad5885829d5c25060303c526fec354552d178d39ae050f5a49700da4bc4b4653264e5371c6dfda44df585a7f198353f65dc
7
+ data.tar.gz: 3cd222fd4e5a5337cc63a6df8d813ec695cb2e4ea73294048de169e92c93dcee36a6d90f2bbb0a3525f3d27b86c3499f762f1c0b8904e79c7a012a9852095aeb
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  * _Your new feature here._
4
4
 
5
+ ## 3.0.6 / 2023-04-11
6
+
7
+ * Fix: Add support to keep open streaming connections with Puma [#1858](https://github.com/sinatra/sinatra/pull/1858) by Jordan Owens
8
+
9
+ * Fix: Avoid crash in `uri` helper on Integer input [#1890](https://github.com/sinatra/sinatra/pull/1890) by Patrik Ragnarsson
10
+
11
+ * Fix: Rescue `RuntimeError` when trying to use `SecureRandom` [#1888](https://github.com/sinatra/sinatra/pull/1888) by Stefan Sundin
12
+
5
13
  ## 3.0.5 / 2022-12-16
6
14
 
7
15
  * Fix: Add Zeitwerk compatibility. [#1831](https://github.com/sinatra/sinatra/pull/1831) by Dawid Janczak
data/CONTRIBUTING.md CHANGED
@@ -65,21 +65,21 @@ track patch requests.
65
65
  also has its own [Git repository](http://github.com/sinatra/sinatra-recipes).
66
66
 
67
67
  * [The Introduction](http://www.sinatrarb.com/intro.html) is generated from
68
- Sinatra's [README file](http://github.com/sinatra/sinatra/blob/master/README.md).
68
+ Sinatra's [README file](http://github.com/sinatra/sinatra/blob/main/README.md).
69
69
 
70
70
  * If you want to help translating the documentation, the README is already
71
71
  available in
72
- [Japanese](http://github.com/sinatra/sinatra/blob/master/README.ja.md),
73
- [German](http://github.com/sinatra/sinatra/blob/master/README.de.md),
74
- [Chinese](https://github.com/sinatra/sinatra/blob/master/README.zh.md),
75
- [Russian](https://github.com/sinatra/sinatra/blob/master/README.ru.md),
76
- [European](https://github.com/sinatra/sinatra/blob/master/README.pt-pt.md) and
77
- [Brazilian](https://github.com/sinatra/sinatra/blob/master/README.pt-br.md)
72
+ [Japanese](http://github.com/sinatra/sinatra/blob/main/README.ja.md),
73
+ [German](http://github.com/sinatra/sinatra/blob/main/README.de.md),
74
+ [Chinese](https://github.com/sinatra/sinatra/blob/main/README.zh.md),
75
+ [Russian](https://github.com/sinatra/sinatra/blob/main/README.ru.md),
76
+ [European](https://github.com/sinatra/sinatra/blob/main/README.pt-pt.md) and
77
+ [Brazilian](https://github.com/sinatra/sinatra/blob/main/README.pt-br.md)
78
78
  Portuguese,
79
- [French](https://github.com/sinatra/sinatra/blob/master/README.fr.md),
80
- [Spanish](https://github.com/sinatra/sinatra/blob/master/README.es.md),
81
- [Korean](https://github.com/sinatra/sinatra/blob/master/README.ko.md), and
82
- [Hungarian](https://github.com/sinatra/sinatra/blob/master/README.hu.md).
79
+ [French](https://github.com/sinatra/sinatra/blob/main/README.fr.md),
80
+ [Spanish](https://github.com/sinatra/sinatra/blob/main/README.es.md),
81
+ [Korean](https://github.com/sinatra/sinatra/blob/main/README.ko.md), and
82
+ [Hungarian](https://github.com/sinatra/sinatra/blob/main/README.hu.md).
83
83
  The translations tend to fall behind the English version. Translations into
84
84
  other languages would also be appreciated.
85
85
 
data/Gemfile CHANGED
@@ -15,12 +15,12 @@ gem 'rake'
15
15
 
16
16
  rack_version = ENV['rack'].to_s
17
17
  rack_version = nil if rack_version.empty? || (rack_version == 'stable')
18
- rack_version = { github: 'rack/rack' } if rack_version == 'latest'
18
+ rack_version = { github: 'rack/rack' } if rack_version == 'head'
19
19
  gem 'rack', rack_version
20
20
 
21
21
  puma_version = ENV['puma'].to_s
22
22
  puma_version = nil if puma_version.empty? || (puma_version == 'stable')
23
- puma_version = { github: 'puma/puma' } if puma_version == 'latest'
23
+ puma_version = { github: 'puma/puma' } if puma_version == 'head'
24
24
  gem 'puma', puma_version
25
25
 
26
26
  gem 'minitest', '~> 5.0'
@@ -39,7 +39,7 @@ gem 'commonmarker', '~> 0.23.4', platforms: [:ruby]
39
39
  gem 'erubi'
40
40
  gem 'eventmachine'
41
41
  gem 'falcon', '~> 0.40', platforms: [:ruby]
42
- gem 'haml', '~> 5'
42
+ gem 'haml', '~> 6'
43
43
  gem 'kramdown'
44
44
  gem 'liquid'
45
45
  gem 'markaby'
data/MAINTENANCE.md CHANGED
@@ -4,13 +4,13 @@
4
4
 
5
5
  ### Releases
6
6
 
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.
7
+ The next major version of Sinatra will be released from the main 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.
8
8
 
9
9
  ## Issues
10
10
 
11
11
  ### New features
12
12
 
13
- New features will only be added to the master branch and will not be made available in point releases.
13
+ New features will only be added to the main branch and will not be made available in point releases.
14
14
 
15
15
  ### Bug fixes
16
16
 
data/README.md CHANGED
@@ -1933,7 +1933,7 @@ end
1933
1933
  ### Configuring attack protection
1934
1934
 
1935
1935
  Sinatra is using
1936
- [Rack::Protection](https://github.com/sinatra/sinatra/tree/master/rack-protection#readme) to
1936
+ [Rack::Protection](https://github.com/sinatra/sinatra/tree/main/rack-protection#readme) to
1937
1937
  defend your application against common, opportunistic attacks. You can
1938
1938
  easily disable this behavior (which will open up your application to tons
1939
1939
  of common vulnerabilities):
@@ -2319,7 +2319,7 @@ end
2319
2319
  ```
2320
2320
 
2321
2321
  The semantics of `use` are identical to those defined for the
2322
- [Rack::Builder](http://www.rubydoc.info/github/rack/rack/master/Rack/Builder) DSL
2322
+ [Rack::Builder](https://www.rubydoc.info/github/rack/rack/main/Rack/Builder) DSL
2323
2323
  (most frequently used from rackup files). For example, the `use` method
2324
2324
  accepts multiple/variable args as well as blocks:
2325
2325
 
@@ -2335,7 +2335,7 @@ many of these components automatically based on configuration so you
2335
2335
  typically don't have to `use` them explicitly.
2336
2336
 
2337
2337
  You can find useful middleware in
2338
- [rack](https://github.com/rack/rack/tree/master/lib/rack),
2338
+ [rack](https://github.com/rack/rack/tree/main/lib/rack),
2339
2339
  [rack-contrib](https://github.com/rack/rack-contrib#readme),
2340
2340
  or in the [Rack wiki](https://github.com/rack/rack/wiki/List-of-Middleware).
2341
2341
 
@@ -2343,7 +2343,7 @@ or in the [Rack wiki](https://github.com/rack/rack/wiki/List-of-Middleware).
2343
2343
 
2344
2344
  Sinatra tests can be written using any Rack-based testing library or
2345
2345
  framework.
2346
- [Rack::Test](http://www.rubydoc.info/github/brynary/rack-test/master/frames)
2346
+ [Rack::Test](https://www.rubydoc.info/github/rack/rack-test/main/frames)
2347
2347
  is recommended:
2348
2348
 
2349
2349
  ```ruby
@@ -2838,7 +2838,7 @@ Running Sinatra on a not officially supported Ruby flavor means that if things o
2838
2838
  ## The Bleeding Edge
2839
2839
 
2840
2840
  If you would like to use Sinatra's latest bleeding-edge code, feel free
2841
- to run your application against the master branch, it should be rather
2841
+ to run your application against the main branch, it should be rather
2842
2842
  stable.
2843
2843
 
2844
2844
  We also push out prerelease gems from time to time, so you can do a
@@ -2887,20 +2887,19 @@ SemVerTag.
2887
2887
 
2888
2888
  ## Further Reading
2889
2889
 
2890
- * [Project Website](http://www.sinatrarb.com/) - Additional documentation,
2890
+ * [Project Website](https://sinatrarb.com/) - Additional documentation,
2891
2891
  news, and links to other resources.
2892
- * [Contributing](http://www.sinatrarb.com/contributing) - Find a bug? Need
2892
+ * [Contributing](https://sinatrarb.com/contributing) - Find a bug? Need
2893
2893
  help? Have a patch?
2894
2894
  * [Issue tracker](https://github.com/sinatra/sinatra/issues)
2895
2895
  * [Twitter](https://twitter.com/sinatra)
2896
2896
  * [Mailing List](https://groups.google.com/forum/#!forum/sinatrarb)
2897
2897
  * IRC: [#sinatra](irc://chat.freenode.net/#sinatra) on [Freenode](https://freenode.net)
2898
- * [Sinatra & Friends](https://sinatrarb.slack.com) on Slack
2899
- ([get an invite](https://sinatra-slack.herokuapp.com/))
2898
+ * [Sinatra & Friends](https://discord.gg/ncjsfsNHh7) on Discord
2900
2899
  * [Sinatra Book](https://github.com/sinatra/sinatra-book) - Cookbook Tutorial
2901
2900
  * [Sinatra Recipes](http://recipes.sinatrarb.com/) - Community contributed
2902
2901
  recipes
2903
- * API documentation for the [latest release](http://www.rubydoc.info/gems/sinatra)
2904
- or the [current HEAD](http://www.rubydoc.info/github/sinatra/sinatra) on
2905
- [RubyDoc](http://www.rubydoc.info/)
2902
+ * API documentation for the [latest release](https://www.rubydoc.info/gems/sinatra)
2903
+ or the [current HEAD](https://www.rubydoc.info/github/sinatra/sinatra) on
2904
+ [RubyDoc](https://www.rubydoc.info/)
2906
2905
  * [CI Actions](https://github.com/sinatra/sinatra/actions)
data/Rakefile CHANGED
@@ -1,14 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rake/clean'
4
- require 'rake/testtask'
4
+ require 'minitest/test_task'
5
5
  require 'fileutils'
6
6
  require 'date'
7
7
 
8
8
  task default: :test
9
- task spec: :test
10
-
11
- CLEAN.include '**/*.rbc'
12
9
 
13
10
  def source_version
14
11
  @source_version ||= File.read(File.expand_path('VERSION', __dir__)).strip
@@ -24,27 +21,20 @@ def prev_version
24
21
  source_version.gsub(/\d+$/) { |s| s.to_i - 1 }
25
22
  end
26
23
 
27
- # SPECS ===============================================================
24
+ # Tests ===============================================================
28
25
 
29
- Rake::TestTask.new(:test) do |t|
30
- t.test_files = FileList['test/*_test.rb']
31
- t.ruby_opts = ['-r rubygems'] if defined? Gem
26
+ Minitest::TestTask.create # Default `test` task
27
+ Minitest::TestTask.create(:'test:core') do |t|
32
28
  t.warning = true
33
- end
34
-
35
- Rake::TestTask.new(:'test:core') do |t|
36
- core_tests = %w[
29
+ t.test_globs = %w[
37
30
  base delegator encoding extensions filter
38
31
  helpers mapped_error middleware rdoc
39
32
  readme request response result route_added_hook
40
33
  routing server settings sinatra static templates
41
- ]
42
- t.test_files = core_tests.map { |n| "test/#{n}_test.rb" }
43
- t.ruby_opts = ['-r rubygems'] if defined? Gem
44
- t.warning = true
34
+ ].map { |n| "test/#{n}_test.rb" }
45
35
  end
46
36
 
47
- # Rcov ================================================================
37
+ # Test code coverage ==================================================
48
38
 
49
39
  namespace :test do
50
40
  desc 'Measures test coverage'
@@ -54,6 +44,7 @@ namespace :test do
54
44
  Rake::Task['test'].invoke
55
45
  end
56
46
  end
47
+ CLEAN.include('coverage')
57
48
 
58
49
  # Website =============================================================
59
50
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.5
1
+ 3.0.6
data/examples/chat.rb CHANGED
@@ -1,11 +1,13 @@
1
1
  #!/usr/bin/env ruby -I ../lib -I lib
2
2
  # frozen_string_literal: true
3
3
 
4
- require_relative 'rainbows'
4
+ # This example does *not* work properly with WEBrick or other
5
+ # servers that buffer output. To shut down the server, close any
6
+ # open browser tabs that are connected to the chat server.
5
7
 
6
8
  require 'sinatra'
7
- set :server, :rainbows
8
- connections = []
9
+ set :server, :puma
10
+ connections = Set.new
9
11
 
10
12
  get '/' do
11
13
  halt erb(:login) unless params[:user]
@@ -14,13 +16,22 @@ end
14
16
 
15
17
  get '/stream', provides: 'text/event-stream' do
16
18
  stream :keep_open do |out|
17
- connections << out
18
- out.callback { connections.delete(out) }
19
+ if connections.add?(out)
20
+ out.callback { connections.delete(out) }
21
+ end
22
+ out << "heartbeat:\n"
23
+ sleep 1
24
+ rescue
25
+ out.close
19
26
  end
20
27
  end
21
28
 
22
29
  post '/' do
23
- connections.each { |out| out << "data: #{params[:msg]}\n\n" }
30
+ connections.each do |out|
31
+ out << "data: #{params[:msg]}\n\n"
32
+ rescue
33
+ out.close
34
+ end
24
35
  204 # response without entity body
25
36
  end
26
37
 
@@ -37,10 +48,10 @@ __END__
37
48
  </html>
38
49
 
39
50
  @@ login
40
- <form action='/'>
51
+ <form action="/">
41
52
  <label for='user'>User Name:</label>
42
- <input name='user' value='' />
43
- <input type='submit' value="GO!" />
53
+ <input name="user" value="" />
54
+ <input type="submit" value="GO!" />
44
55
  </form>
45
56
 
46
57
  @@ chat
data/lib/sinatra/base.rb CHANGED
@@ -19,7 +19,7 @@ require 'sinatra/version'
19
19
 
20
20
  module Sinatra
21
21
  # The request object. See Rack::Request for more info:
22
- # http://rubydoc.info/github/rack/rack/master/Rack/Request
22
+ # https://rubydoc.info/github/rack/rack/main/Rack/Request
23
23
  class Request < Rack::Request
24
24
  HEADER_PARAM = /\s*[\w.]+=(?:[\w.]+|"(?:[^"\\]|\\.)*")?\s*/.freeze
25
25
  HEADER_VALUE_WITH_PARAMS = %r{(?:(?:\w+|\*)/(?:\w+(?:\.|-|\+)?|\*)*)\s*(?:;#{HEADER_PARAM})*}.freeze
@@ -158,8 +158,8 @@ module Sinatra
158
158
 
159
159
  # The response object. See Rack::Response and Rack::Response::Helpers for
160
160
  # more info:
161
- # http://rubydoc.info/github/rack/rack/master/Rack/Response
162
- # http://rubydoc.info/github/rack/rack/master/Rack/Response/Helpers
161
+ # https://rubydoc.info/github/rack/rack/main/Rack/Response
162
+ # https://rubydoc.info/github/rack/rack/main/Rack/Response/Helpers
163
163
  class Response < Rack::Response
164
164
  DROP_BODY_RESPONSES = [204, 304].freeze
165
165
 
@@ -291,7 +291,7 @@ module Sinatra
291
291
  elsif value
292
292
  # Rack 2.0 returns a Rack::File::Iterator here instead of
293
293
  # Rack::File as it was in the previous API.
294
- unless request.head? || value.is_a?(Rack::File::Iterator) || value.is_a?(Stream)
294
+ unless request.head? || value.is_a?(Rack::Files::Iterator) || value.is_a?(Stream)
295
295
  headers.delete 'Content-Length'
296
296
  end
297
297
  response.body = value
@@ -317,7 +317,7 @@ module Sinatra
317
317
  # Generates the absolute URI for a given path in the app.
318
318
  # Takes Rack routers and reverse proxies into account.
319
319
  def uri(addr = nil, absolute = true, add_script_name = true)
320
- return addr if addr =~ /\A[a-z][a-z0-9+.\-]*:/i
320
+ return addr if addr.to_s =~ /\A[a-z][a-z0-9+.\-]*:/i
321
321
 
322
322
  uri = [host = String.new]
323
323
  if absolute
@@ -429,7 +429,7 @@ module Sinatra
429
429
 
430
430
  last_modified opts[:last_modified] if opts[:last_modified]
431
431
 
432
- file = Rack::File.new(File.dirname(settings.app_file))
432
+ file = Rack::Files.new(File.dirname(settings.app_file))
433
433
  result = file.serving(request, path)
434
434
 
435
435
  result[1].each { |k, v| headers[k] ||= v }
@@ -474,8 +474,9 @@ module Sinatra
474
474
  @back.call(self)
475
475
  rescue Exception => e
476
476
  @scheduler.schedule { raise e }
477
+ ensure
478
+ close unless @keep_open
477
479
  end
478
- close unless @keep_open
479
480
  end
480
481
  end
481
482
 
@@ -506,7 +507,16 @@ module Sinatra
506
507
  def stream(keep_open = false)
507
508
  scheduler = env['async.callback'] ? EventMachine : Stream
508
509
  current = @params.dup
509
- body Stream.new(scheduler, keep_open) { |out| with_params(current) { yield(out) } }
510
+ stream = if scheduler == Stream && keep_open
511
+ Stream.new(scheduler, false) do |out|
512
+ until out.closed?
513
+ with_params(current) { yield(out) }
514
+ end
515
+ end
516
+ else
517
+ Stream.new(scheduler, keep_open) { |out| with_params(current) { yield(out) } }
518
+ end
519
+ body stream
510
520
  end
511
521
 
512
522
  # Specify response freshness policy for HTTP caches (Cache-Control header).
@@ -1838,8 +1848,9 @@ module Sinatra
1838
1848
  begin
1839
1849
  require 'securerandom'
1840
1850
  set :session_secret, SecureRandom.hex(64)
1841
- rescue LoadError, NotImplementedError
1851
+ rescue LoadError, NotImplementedError, RuntimeError
1842
1852
  # SecureRandom raises a NotImplementedError if no random device is available
1853
+ # RuntimeError raised due to broken openssl backend: https://bugs.ruby-lang.org/issues/19230
1843
1854
  set :session_secret, format('%064x', Kernel.rand((2**256) - 1))
1844
1855
  end
1845
1856
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sinatra
4
- VERSION = '3.0.4'
4
+ VERSION = '3.0.6'
5
5
  end
data/sinatra.gemspec CHANGED
@@ -36,7 +36,7 @@ RubyGems 2.0 or newer is required to protect against public gem pushes. You can
36
36
 
37
37
  s.metadata = {
38
38
  'source_code_uri' => 'https://github.com/sinatra/sinatra',
39
- 'changelog_uri' => 'https://github.com/sinatra/sinatra/blob/master/CHANGELOG.md',
39
+ 'changelog_uri' => 'https://github.com/sinatra/sinatra/blob/main/CHANGELOG.md',
40
40
  'homepage_uri' => 'http://sinatrarb.com/',
41
41
  'bug_tracker_uri' => 'https://github.com/sinatra/sinatra/issues',
42
42
  'mailing_list_uri' => 'http://groups.google.com/group/sinatrarb',
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.5
4
+ version: 3.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Mizerany
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2022-12-16 00:00:00.000000000 Z
14
+ date: 2023-04-11 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: mustermann
@@ -53,14 +53,14 @@ dependencies:
53
53
  requirements:
54
54
  - - '='
55
55
  - !ruby/object:Gem::Version
56
- version: 3.0.5
56
+ version: 3.0.6
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - '='
62
62
  - !ruby/object:Gem::Version
63
- version: 3.0.5
63
+ version: 3.0.6
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: tilt
66
66
  requirement: !ruby/object:Gem::Requirement
@@ -128,7 +128,7 @@ licenses:
128
128
  - MIT
129
129
  metadata:
130
130
  source_code_uri: https://github.com/sinatra/sinatra
131
- changelog_uri: https://github.com/sinatra/sinatra/blob/master/CHANGELOG.md
131
+ changelog_uri: https://github.com/sinatra/sinatra/blob/main/CHANGELOG.md
132
132
  homepage_uri: http://sinatrarb.com/
133
133
  bug_tracker_uri: https://github.com/sinatra/sinatra/issues
134
134
  mailing_list_uri: http://groups.google.com/group/sinatrarb
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  - !ruby/object:Gem::Version
155
155
  version: '0'
156
156
  requirements: []
157
- rubygems_version: 3.2.3
157
+ rubygems_version: 3.4.10
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: Classy web-development dressed in a DSL