sinatra 3.2.0 → 4.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.

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: 6eddf8c0c677b8b8b7f15bb03834147034ead41bc6310bf773ac84712bb43a14
4
- data.tar.gz: c35de3457f199d57a3c8a4419bd0ad113df38ba071cfffbcc79311db910bc1cb
3
+ metadata.gz: 931652dc91884a733d4cab3fd2679533de8a78d80a9c7d19d2cecf2798a678c6
4
+ data.tar.gz: b6b633d00b67e7318547f5b066aeee0956ecd8b448f910f829d2cf33cb2d208c
5
5
  SHA512:
6
- metadata.gz: 33e0785425af5a32c7e09d95e2d11e02d83cdda1d907b34197c63642bfec81cd04a40ffc2e25486fe45af66d9a681f57c41d083d7bc56f24b69f1cf4b3a478f6
7
- data.tar.gz: 6aa65f3b65c819171bcadb61a3a43c3ff7af748d29a9177dbd02549229e3b9fa64b338d0404383b97615e74aa5381dd8a4c997edbf86ca0e8a2970e0213b2ece
6
+ metadata.gz: 8181093ece483ffdde4f660feb8c9bfe821260fa7af456820a0ecbafcd74a2932a835f7bee35b79d070755bb36b75d14077aa3e9fbf9ee8a33eebd92f13195ba
7
+ data.tar.gz: 280db78b6907477f15d9bdb9def5985f6ef62a70e697c61f85d00dc35a0e21397656d5ab862ee17fbafe05ff5e45c1eac1d14dfa73d75cb1e4f5d4e91f81001b
data/CHANGELOG.md CHANGED
@@ -1,6 +1,54 @@
1
- ## Unreleased
1
+ ## 4.0.1 / 2025-05-24
2
2
 
3
- * _Your new feature here._
3
+ * Rack 3.1 compatibility ([#2035])
4
+
5
+ * Fix malformed Content-Type headers ([#2081])
6
+
7
+ * Avoid crash for integer values in `content_type` parameters ([#2078])
8
+
9
+ * Fix compatibility with --enable-frozen-string-literal ([#2033])
10
+
11
+ * Declare missing dependencies for Ruby 3.5 ([#2032])
12
+
13
+ * Fix warning about Hash construction. ([#2028])
14
+
15
+ * Support Zeitwerk 2.7.0+ ([#2050])
16
+
17
+ * Address URI depreciation ([#2060])
18
+
19
+ [#2035]: https://github.com/sinatra/sinatra/pull/2035
20
+ [#2081]: https://github.com/sinatra/sinatra/pull/2081
21
+ [#2078]: https://github.com/sinatra/sinatra/pull/2078
22
+ [#2033]: https://github.com/sinatra/sinatra/pull/2033
23
+ [#2032]: https://github.com/sinatra/sinatra/pull/2032
24
+ [#2028]: https://github.com/sinatra/sinatra/pull/2028
25
+ [#2050]: https://github.com/sinatra/sinatra/pull/2050
26
+ [#2060]: https://github.com/sinatra/sinatra/pull/2060
27
+
28
+ ## 4.0.0. / 2024-01-19
29
+
30
+ * New: Add support for Rack 3 ([#1857])
31
+ * Note: you may want to read the [Rack 3 Upgrade Guide]
32
+
33
+ * Require Ruby 2.7.8 as minimum Ruby version ([#1993])
34
+
35
+ * Breaking change: Drop support for Rack 2 ([#1857])
36
+ * Note: when using Sinatra to start the web server, you now need the `rackup` gem installed
37
+
38
+ * Breaking change: Remove the `IndifferentHash` initializer ([#1982])
39
+
40
+ * Breaking change: Disable `session_hijacking` protection by default ([#1984])
41
+
42
+ * Breaking change: Remove `Rack::Protection::EncryptedCookie` ([#1989])
43
+ * Note: cookies are still encrypted (by [`Rack::Session::Cookie`])
44
+
45
+ [#1857]: https://github.com/sinatra/sinatra/pull/1857
46
+ [#1993]: https://github.com/sinatra/sinatra/pull/1993
47
+ [#1982]: https://github.com/sinatra/sinatra/pull/1982
48
+ [#1984]: https://github.com/sinatra/sinatra/pull/1984
49
+ [#1989]: https://github.com/sinatra/sinatra/pull/1989
50
+ [`Rack::Session::Cookie`]: https://github.com/rack/rack-session
51
+ [Rack 3 Upgrade Guide]: https://github.com/rack/rack/blob/main/UPGRADE-GUIDE.md
4
52
 
5
53
  ## 3.2.0 / 2023-12-29
6
54
 
@@ -23,7 +71,7 @@
23
71
  [#1949]: https://github.com/sinatra/sinatra/pull/1949
24
72
  [#1952]: https://github.com/sinatra/sinatra/pull/1952
25
73
  [#1960]: https://github.com/sinatra/sinatra/pull/1960
26
- [#1975]: https://github.com/sinatra/sinatra/pull/1960
74
+ [#1975]: https://github.com/sinatra/sinatra/pull/1975
27
75
 
28
76
  ## 3.1.0 / 2023-08-07
29
77
 
data/Gemfile CHANGED
@@ -1,13 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Why use bundler?
4
- # Well, not all development dependencies install on all rubies. Moreover, `gem
5
- # install sinatra --development` doesn't work, as it will also try to install
6
- # development dependencies of our dependencies, and those are not conflict free.
7
- # So, here we are, `bundle install`.
8
- #
9
- # If you have issues with a gem: `bundle install --without-coffee-script`.
10
-
11
3
  source 'https://rubygems.org'
12
4
  gemspec
13
5
 
@@ -18,11 +10,22 @@ rack_version = nil if rack_version.empty? || (rack_version == 'stable')
18
10
  rack_version = { github: 'rack/rack' } if rack_version == 'head'
19
11
  gem 'rack', rack_version
20
12
 
13
+ rack_session_version = ENV['rack_session'].to_s
14
+ rack_session_version = nil if rack_session_version.empty? || (rack_session_version == 'stable')
15
+ rack_session_version = { github: 'rack/rack-session' } if rack_session_version == 'head'
16
+ gem 'rack-session', rack_session_version
17
+
18
+ gem 'rackup'
19
+
21
20
  puma_version = ENV['puma'].to_s
22
21
  puma_version = nil if puma_version.empty? || (puma_version == 'stable')
23
22
  puma_version = { github: 'puma/puma' } if puma_version == 'head'
24
23
  gem 'puma', puma_version
25
24
 
25
+ zeitwerk_version = ENV['zeitwerk'].to_s
26
+ zeitwerk_version = nil if zeitwerk_version.empty? || (zeitwerk_version == 'stable')
27
+ gem 'zeitwerk', zeitwerk_version
28
+
26
29
  gem 'minitest', '~> 5.0'
27
30
  gem 'rack-test'
28
31
  gem 'rubocop', '~> 1.32.0', require: false
@@ -31,15 +34,9 @@ gem 'yard' # used by rake doc
31
34
  gem 'rack-protection', path: 'rack-protection'
32
35
  gem 'sinatra-contrib', path: 'sinatra-contrib'
33
36
 
34
- # traces 0.10.0 started to use Ruby 2.7 syntax without specifying required Ruby version
35
- # https://github.com/socketry/traces/pull/8#discussion_r1237988182
36
- # async-http 0.60.2 added traces 0.10.0 as dependency
37
- # https://github.com/socketry/async-http/pull/124/files#r1237988899
38
- gem 'traces', '< 0.10.0' if RUBY_VERSION >= '2.6.0' && RUBY_VERSION < '2.7.0'
39
-
40
37
  gem 'asciidoctor'
41
38
  gem 'builder'
42
- gem 'childprocess'
39
+ gem 'childprocess', '>= 5'
43
40
  gem 'commonmarker', '~> 0.23.4', platforms: [:ruby]
44
41
  gem 'erubi'
45
42
  gem 'eventmachine'
@@ -47,25 +44,22 @@ gem 'falcon', '~> 0.40', platforms: [:ruby]
47
44
  gem 'haml', '~> 6'
48
45
  gem 'kramdown'
49
46
  gem 'liquid'
50
- # markaby 0.9.1 introduced Ruby 2.7 syntax in https://github.com/markaby/markaby/pull/44
51
- # and does not specify required_ruby_version
52
- if RUBY_VERSION >= '2.6.0' && RUBY_VERSION < '2.7.0'
53
- gem 'markaby', '< 0.9.1'
54
- else
55
- gem 'markaby'
56
- end
47
+ gem 'markaby'
57
48
  gem 'nokogiri', '> 1.5.0'
49
+ gem 'ostruct'
58
50
  gem 'pandoc-ruby', '~> 2.0.2'
59
51
  gem 'rabl'
60
- if RUBY_ENGINE == 'truffleruby'
61
- gem 'rdiscount', '< 2.2.7.2' # https://github.com/oracle/truffleruby/issues/3362
62
- else
63
- gem 'rdiscount', platforms: [:ruby]
64
- end
52
+ gem 'rdiscount', platforms: [:ruby]
65
53
  gem 'rdoc'
66
54
  gem 'redcarpet', platforms: [:ruby]
67
- gem 'sass-embedded', '~> 1.54'
68
55
  gem 'simplecov', require: false
69
- gem 'slim', '~> 4'
56
+ gem 'slim', '~> 5'
70
57
  gem 'yajl-ruby', platforms: [:ruby]
71
- gem 'zeitwerk'
58
+
59
+ # sass-embedded depends on google-protobuf
60
+ # which fails to be installed on JRuby and TruffleRuby under aarch64
61
+ # https://github.com/jruby/jruby/issues/8062
62
+ # https://github.com/protocolbuffers/protobuf/issues/11935
63
+ java = %w(jruby truffleruby).include?(RUBY_ENGINE)
64
+ aarch64 = RbConfig::CONFIG["target_cpu"] == 'aarch64'
65
+ gem 'sass-embedded', '~> 1.54' unless java && aarch64
data/README.md CHANGED
@@ -1922,7 +1922,7 @@ set :protection, :except => :path_traversal
1922
1922
  You can also hand in an array in order to disable a list of protections:
1923
1923
 
1924
1924
  ```ruby
1925
- set :protection, :except => [:path_traversal, :session_hijacking]
1925
+ set :protection, :except => [:path_traversal, :remote_token]
1926
1926
  ```
1927
1927
 
1928
1928
  By default, Sinatra will only set up session based protection if `:sessions`
@@ -2820,30 +2820,24 @@ uses a threaded model of concurrency.
2820
2820
 
2821
2821
  The following Ruby versions are officially supported:
2822
2822
  <dl>
2823
- <dt>Ruby 2.6</dt>
2823
+ <dt>Ruby</dt>
2824
2824
  <dd>
2825
- 2.6 is fully supported and recommended. There are currently no plans to
2826
- drop official support for it.
2825
+ <a href="https://www.ruby-lang.org/en/downloads/">The stable releases</a> are fully supported and recommended.
2827
2826
  </dd>
2828
2827
 
2829
- <dt>Rubinius</dt>
2828
+ <dt>TruffleRuby</dt>
2830
2829
  <dd>
2831
- Rubinius is officially supported (Rubinius >= 2.x). It is recommended to
2832
- <tt>gem install puma</tt>.
2830
+ The latest stable release of TruffleRuby is supported.
2833
2831
  </dd>
2834
2832
 
2835
2833
  <dt>JRuby</dt>
2836
2834
  <dd>
2837
- The latest stable release of JRuby is officially supported. It is not
2838
- recommended to use C extensions with JRuby. It is recommended to
2839
- <tt>gem install trinidad</tt>.
2835
+ The latest stable release of JRuby is supported. It is not
2836
+ recommended to use C extensions with JRuby.
2840
2837
  </dd>
2841
2838
  </dl>
2842
2839
 
2843
- Versions of Ruby before 2.6 are no longer supported as of Sinatra 3.0.0.
2844
-
2845
- We also keep an eye on upcoming Ruby versions. Expect upcoming
2846
- 3.x releases to be fully supported.
2840
+ Versions of Ruby before 2.7.8 are no longer supported as of Sinatra 4.0.0.
2847
2841
 
2848
2842
  Sinatra should work on any operating system supported by the chosen Ruby
2849
2843
  implementation.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.2.0
1
+ 4.0.1
data/lib/sinatra/base.rb CHANGED
@@ -2,8 +2,13 @@
2
2
 
3
3
  # external dependencies
4
4
  require 'rack'
5
+ begin
6
+ require 'rackup'
7
+ rescue LoadError
8
+ end
5
9
  require 'tilt'
6
10
  require 'rack/protection'
11
+ require 'rack/session'
7
12
  require 'mustermann'
8
13
  require 'mustermann/sinatra'
9
14
  require 'mustermann/regular'
@@ -17,6 +22,8 @@ require 'sinatra/indifferent_hash'
17
22
  require 'sinatra/show_exceptions'
18
23
  require 'sinatra/version'
19
24
 
25
+ require_relative 'middleware/logger'
26
+
20
27
  module Sinatra
21
28
  # The request object. See Rack::Request for more info:
22
29
  # https://rubydoc.info/github/rack/rack/main/Rack/Request
@@ -176,8 +183,8 @@ module Sinatra
176
183
  result = body
177
184
 
178
185
  if drop_content_info?
179
- headers.delete 'Content-Length'
180
- headers.delete 'Content-Type'
186
+ headers.delete 'content-length'
187
+ headers.delete 'content-type'
181
188
  end
182
189
 
183
190
  if drop_body?
@@ -186,9 +193,9 @@ module Sinatra
186
193
  end
187
194
 
188
195
  if calculate_content_length?
189
- # if some other code has already set Content-Length, don't muck with it
196
+ # if some other code has already set content-length, don't muck with it
190
197
  # currently, this would be the static file-handler
191
- headers['Content-Length'] = body.map(&:bytesize).reduce(0, :+).to_s
198
+ headers['content-length'] = body.map(&:bytesize).reduce(0, :+).to_s
192
199
  end
193
200
 
194
201
  [status, headers, result]
@@ -197,7 +204,7 @@ module Sinatra
197
204
  private
198
205
 
199
206
  def calculate_content_length?
200
- headers['Content-Type'] && !headers['Content-Length'] && (Array === body)
207
+ headers['content-type'] && !headers['content-length'] && (Array === body)
201
208
  end
202
209
 
203
210
  def drop_content_info?
@@ -289,10 +296,8 @@ module Sinatra
289
296
  def block.each; yield(call) end
290
297
  response.body = block
291
298
  elsif value
292
- # Rack 2.0 returns a Rack::File::Iterator here instead of
293
- # Rack::File as it was in the previous API.
294
- unless request.head? || value.is_a?(Rack::Files::Iterator) || value.is_a?(Stream)
295
- headers.delete 'Content-Length'
299
+ unless request.head? || value.is_a?(Rack::Files::BaseIterator) || value.is_a?(Stream)
300
+ headers.delete 'content-length'
296
301
  end
297
302
  response.body = value
298
303
  else
@@ -302,7 +307,10 @@ module Sinatra
302
307
 
303
308
  # Halt processing and redirect to the URI provided.
304
309
  def redirect(uri, *args)
305
- if (env['HTTP_VERSION'] == 'HTTP/1.1') && (env['REQUEST_METHOD'] != 'GET')
310
+ # SERVER_PROTOCOL is required in Rack 3, fall back to HTTP_VERSION
311
+ # for servers not updated for Rack 3 (like Puma 5)
312
+ http_version = env['SERVER_PROTOCOL'] || env['HTTP_VERSION']
313
+ if (http_version == 'HTTP/1.1') && (env['REQUEST_METHOD'] != 'GET')
306
314
  status 303
307
315
  else
308
316
  status 302
@@ -372,10 +380,10 @@ module Sinatra
372
380
  Base.mime_type(type)
373
381
  end
374
382
 
375
- # Set the Content-Type of the response body given a media type or file
383
+ # Set the content-type of the response body given a media type or file
376
384
  # extension.
377
385
  def content_type(type = nil, params = {})
378
- return response['Content-Type'] unless type
386
+ return response['content-type'] unless type
379
387
 
380
388
  default = params.delete :default
381
389
  mime_type = mime_type(type) || default
@@ -387,13 +395,13 @@ module Sinatra
387
395
  end
388
396
  params.delete :charset if mime_type.include? 'charset'
389
397
  unless params.empty?
390
- mime_type << (mime_type.include?(';') ? ', ' : ';')
398
+ mime_type << ';'
391
399
  mime_type << params.map do |key, val|
392
- val = val.inspect if val =~ /[";,]/
400
+ val = val.inspect if val.to_s =~ /[";,]/
393
401
  "#{key}=#{val}"
394
- end.join(', ')
402
+ end.join(';')
395
403
  end
396
- response['Content-Type'] = mime_type
404
+ response['content-type'] = mime_type
397
405
  end
398
406
 
399
407
  # https://html.spec.whatwg.org/#multipart-form-data
@@ -412,12 +420,12 @@ module Sinatra
412
420
  params = format('; filename="%s"', File.basename(filename).gsub(/["\r\n]/, MULTIPART_FORM_DATA_REPLACEMENT_TABLE))
413
421
  response['Content-Disposition'] << params
414
422
  ext = File.extname(filename)
415
- content_type(ext) unless response['Content-Type'] || ext.empty?
423
+ content_type(ext) unless response['content-type'] || ext.empty?
416
424
  end
417
425
 
418
426
  # Use the contents of the file at +path+ as the response body.
419
427
  def send_file(path, opts = {})
420
- if opts[:type] || !response['Content-Type']
428
+ if opts[:type] || !response['content-type']
421
429
  content_type opts[:type] || File.extname(path), default: 'application/octet-stream'
422
430
  end
423
431
 
@@ -433,7 +441,7 @@ module Sinatra
433
441
  result = file.serving(request, path)
434
442
 
435
443
  result[1].each { |k, v| headers[k] ||= v }
436
- headers['Content-Length'] = result[1]['Content-Length']
444
+ headers['content-length'] = result[1]['content-length']
437
445
  opts[:status] &&= Integer(opts[:status])
438
446
  halt (opts[:status] || result[0]), result[2]
439
447
  rescue Errno::ENOENT
@@ -966,7 +974,7 @@ module Sinatra
966
974
  include Helpers
967
975
  include Templates
968
976
 
969
- URI_INSTANCE = URI::Parser.new
977
+ URI_INSTANCE = defined?(URI::RFC2396_PARSER) ? URI::RFC2396_PARSER : URI::RFC2396_Parser.new
970
978
 
971
979
  attr_accessor :app, :env, :request, :response, :params
972
980
  attr_reader :template_cache
@@ -995,7 +1003,7 @@ module Sinatra
995
1003
  invoke { dispatch! }
996
1004
  invoke { error_block!(response.status) } unless @env['sinatra.error']
997
1005
 
998
- unless @response['Content-Type']
1006
+ unless @response['content-type']
999
1007
  if Array === body && body[0].respond_to?(:content_type)
1000
1008
  content_type body[0].content_type
1001
1009
  elsif (default = settings.default_content_type)
@@ -1058,7 +1066,7 @@ module Sinatra
1058
1066
  routes = base.routes[@request.request_method]
1059
1067
 
1060
1068
  routes&.each do |pattern, conditions, block|
1061
- response.delete_header('Content-Type') unless @pinned_response
1069
+ response.delete_header('content-type') unless @pinned_response
1062
1070
 
1063
1071
  returned_pass_block = process_route(pattern, conditions) do |*args|
1064
1072
  env['sinatra.route'] = "#{@request.request_method} #{pattern}"
@@ -1179,7 +1187,7 @@ module Sinatra
1179
1187
  invoke do
1180
1188
  static! if settings.static? && (request.get? || request.head?)
1181
1189
  filter! :before do
1182
- @pinned_response = !response['Content-Type'].nil?
1190
+ @pinned_response = !response['content-type'].nil?
1183
1191
  end
1184
1192
  route!
1185
1193
  end
@@ -1286,7 +1294,7 @@ module Sinatra
1286
1294
  /active_support/, # active_support require hacks
1287
1295
  %r{bundler(/(?:runtime|inline))?\.rb}, # bundler require hacks
1288
1296
  /<internal:/, # internal in ruby >= 1.9.2
1289
- %r{zeitwerk/kernel\.rb} # Zeitwerk kernel#require decorator
1297
+ %r{zeitwerk/(core_ext/)?kernel\.rb} # Zeitwerk kernel#require decorator
1290
1298
  ].freeze
1291
1299
 
1292
1300
  attr_reader :routes, :filters, :templates, :errors, :on_start_callback, :on_stop_callback
@@ -1460,7 +1468,13 @@ module Sinatra
1460
1468
  # mime_types :js # => ['application/javascript', 'text/javascript']
1461
1469
  def mime_types(type)
1462
1470
  type = mime_type type
1463
- type =~ %r{^application/(xml|javascript)$} ? [type, "text/#{$1}"] : [type]
1471
+ if type =~ %r{^application/(xml|javascript)$}
1472
+ [type, "text/#{$1}"]
1473
+ elsif type =~ %r{^text/(xml|javascript)$}
1474
+ [type, "application/#{$1}"]
1475
+ else
1476
+ [type]
1477
+ end
1464
1478
  end
1465
1479
 
1466
1480
  # Define a before filter; runs before all requests within the same
@@ -1589,10 +1603,27 @@ module Sinatra
1589
1603
  # Puma, Falcon, or WEBrick (in that order). If given a block, will call
1590
1604
  # with the constructed handler once we have taken the stage.
1591
1605
  def run!(options = {}, &block)
1606
+ unless defined?(Rackup::Handler)
1607
+ rackup_warning = <<~MISSING_RACKUP
1608
+ Sinatra could not start, the "rackup" gem was not found!
1609
+
1610
+ Add it to your bundle with:
1611
+
1612
+ bundle add rackup
1613
+
1614
+ or install it with:
1615
+
1616
+ gem install rackup
1617
+
1618
+ MISSING_RACKUP
1619
+ warn rackup_warning
1620
+ exit 1
1621
+ end
1622
+
1592
1623
  return if running?
1593
1624
 
1594
1625
  set options
1595
- handler = Rack::Handler.pick(server)
1626
+ handler = Rackup::Handler.pick(server)
1596
1627
  handler_name = handler.name.gsub(/.*::/, '')
1597
1628
  server_settings = settings.respond_to?(:server_settings) ? settings.server_settings : {}
1598
1629
  server_settings.merge!(Port: port, Host: bind)
@@ -1724,7 +1755,7 @@ module Sinatra
1724
1755
  types.map! { |t| mime_types(t) }
1725
1756
  types.flatten!
1726
1757
  condition do
1727
- response_content_type = response['Content-Type']
1758
+ response_content_type = response['content-type']
1728
1759
  preferred_type = request.preferred_type(types)
1729
1760
 
1730
1761
  if response_content_type
@@ -1806,7 +1837,7 @@ module Sinatra
1806
1837
  end
1807
1838
 
1808
1839
  def setup_null_logger(builder)
1809
- builder.use Rack::NullLogger
1840
+ builder.use Sinatra::Middleware::Logger, ::Logger::FATAL
1810
1841
  end
1811
1842
 
1812
1843
  def setup_common_logger(builder)
@@ -1815,9 +1846,9 @@ module Sinatra
1815
1846
 
1816
1847
  def setup_custom_logger(builder)
1817
1848
  if logging.respond_to? :to_int
1818
- builder.use Rack::Logger, logging
1849
+ builder.use Sinatra::Middleware::Logger, logging
1819
1850
  else
1820
- builder.use Rack::Logger
1851
+ builder.use Sinatra::Middleware::Logger
1821
1852
  end
1822
1853
  end
1823
1854
 
@@ -1901,7 +1932,7 @@ module Sinatra
1901
1932
  set :dump_errors, proc { !test? }
1902
1933
  set :show_exceptions, proc { development? }
1903
1934
  set :sessions, false
1904
- set :session_store, Rack::Protection::EncryptedCookie
1935
+ set :session_store, Rack::Session::Cookie
1905
1936
  set :logging, false
1906
1937
  set :protection, true
1907
1938
  set :method_override, false
@@ -43,12 +43,6 @@ module Sinatra
43
43
  new.merge!(Hash[*args])
44
44
  end
45
45
 
46
- def initialize(*args)
47
- args.map!(&method(:convert_value))
48
-
49
- super(*args)
50
- end
51
-
52
46
  def default(*args)
53
47
  args.map!(&method(:convert_key))
54
48
 
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'logger'
4
+
5
+ module Sinatra
6
+ module Middleware
7
+ class Logger
8
+ def initialize(app, level = ::Logger::INFO)
9
+ @app, @level = app, level
10
+ end
11
+
12
+ def call(env)
13
+ logger = ::Logger.new(env[Rack::RACK_ERRORS])
14
+ logger.level = @level
15
+
16
+ env[Rack::RACK_LOGGER] = logger
17
+ @app.call(env)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -38,8 +38,8 @@ module Sinatra
38
38
  [
39
39
  500,
40
40
  {
41
- 'Content-Type' => content_type,
42
- 'Content-Length' => body.bytesize.to_s
41
+ 'content-type' => content_type,
42
+ 'content-length' => body.bytesize.to_s
43
43
  },
44
44
  [body]
45
45
  ]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sinatra
4
- VERSION = '3.2.0'
4
+ VERSION = '4.0.1'
5
5
  end
data/sinatra.gemspec CHANGED
@@ -40,13 +40,16 @@ RubyGems 2.0 or newer is required to protect against public gem pushes. You can
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',
43
- 'documentation_uri' => 'https://www.rubydoc.info/gems/sinatra'
43
+ 'documentation_uri' => 'https://www.rubydoc.info/gems/sinatra',
44
+ 'rubygems_mfa_required' => 'true',
44
45
  }
45
46
 
46
- s.required_ruby_version = '>= 2.6.0'
47
+ s.required_ruby_version = '>= 2.7.8'
47
48
 
49
+ s.add_dependency 'logger', '>= 1.6.0'
48
50
  s.add_dependency 'mustermann', '~> 3.0'
49
- s.add_dependency 'rack', '~> 2.2', '>= 2.2.4'
51
+ s.add_dependency 'rack', '>= 3.0.0', '< 4'
50
52
  s.add_dependency 'rack-protection', version
53
+ s.add_dependency 'rack-session', '>= 2.0.0', '< 3'
51
54
  s.add_dependency 'tilt', '~> 2.0'
52
55
  end
metadata CHANGED
@@ -1,18 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Mizerany
8
8
  - Ryan Tomayko
9
9
  - Simon Rozet
10
10
  - Konstantin Haase
11
- autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2023-12-29 00:00:00.000000000 Z
13
+ date: 1980-01-02 00:00:00.000000000 Z
15
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: logger
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: 1.6.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: 1.6.0
16
29
  - !ruby/object:Gem::Dependency
17
30
  name: mustermann
18
31
  requirement: !ruby/object:Gem::Requirement
@@ -31,36 +44,56 @@ dependencies:
31
44
  name: rack
32
45
  requirement: !ruby/object:Gem::Requirement
33
46
  requirements:
34
- - - "~>"
35
- - !ruby/object:Gem::Version
36
- version: '2.2'
37
47
  - - ">="
38
48
  - !ruby/object:Gem::Version
39
- version: 2.2.4
49
+ version: 3.0.0
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '4'
40
53
  type: :runtime
41
54
  prerelease: false
42
55
  version_requirements: !ruby/object:Gem::Requirement
43
56
  requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '2.2'
47
57
  - - ">="
48
58
  - !ruby/object:Gem::Version
49
- version: 2.2.4
59
+ version: 3.0.0
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '4'
50
63
  - !ruby/object:Gem::Dependency
51
64
  name: rack-protection
52
65
  requirement: !ruby/object:Gem::Requirement
53
66
  requirements:
54
67
  - - '='
55
68
  - !ruby/object:Gem::Version
56
- version: 3.2.0
69
+ version: 4.0.1
57
70
  type: :runtime
58
71
  prerelease: false
59
72
  version_requirements: !ruby/object:Gem::Requirement
60
73
  requirements:
61
74
  - - '='
62
75
  - !ruby/object:Gem::Version
63
- version: 3.2.0
76
+ version: 4.0.1
77
+ - !ruby/object:Gem::Dependency
78
+ name: rack-session
79
+ requirement: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 2.0.0
84
+ - - "<"
85
+ - !ruby/object:Gem::Version
86
+ version: '3'
87
+ type: :runtime
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: 2.0.0
94
+ - - "<"
95
+ - !ruby/object:Gem::Version
96
+ version: '3'
64
97
  - !ruby/object:Gem::Dependency
65
98
  name: tilt
66
99
  requirement: !ruby/object:Gem::Requirement
@@ -81,8 +114,8 @@ email: sinatrarb@googlegroups.com
81
114
  executables: []
82
115
  extensions: []
83
116
  extra_rdoc_files:
84
- - README.md
85
117
  - LICENSE
118
+ - README.md
86
119
  files:
87
120
  - ".yardopts"
88
121
  - AUTHORS.md
@@ -105,6 +138,7 @@ files:
105
138
  - lib/sinatra/images/500.png
106
139
  - lib/sinatra/indifferent_hash.rb
107
140
  - lib/sinatra/main.rb
141
+ - lib/sinatra/middleware/logger.rb
108
142
  - lib/sinatra/show_exceptions.rb
109
143
  - lib/sinatra/version.rb
110
144
  - sinatra.gemspec
@@ -118,7 +152,7 @@ metadata:
118
152
  bug_tracker_uri: https://github.com/sinatra/sinatra/issues
119
153
  mailing_list_uri: http://groups.google.com/group/sinatrarb
120
154
  documentation_uri: https://www.rubydoc.info/gems/sinatra
121
- post_install_message:
155
+ rubygems_mfa_required: 'true'
122
156
  rdoc_options:
123
157
  - "--line-numbers"
124
158
  - "--title"
@@ -132,15 +166,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
132
166
  requirements:
133
167
  - - ">="
134
168
  - !ruby/object:Gem::Version
135
- version: 2.6.0
169
+ version: 2.7.8
136
170
  required_rubygems_version: !ruby/object:Gem::Requirement
137
171
  requirements:
138
172
  - - ">="
139
173
  - !ruby/object:Gem::Version
140
174
  version: '0'
141
175
  requirements: []
142
- rubygems_version: 3.5.3
143
- signing_key:
176
+ rubygems_version: 3.6.7
144
177
  specification_version: 4
145
178
  summary: Classy web-development dressed in a DSL
146
179
  test_files: []