Skip to content

Commit 048c8de

Browse files
Support Ruby 2.7.3
Keep the latest Ruby 2.7 release line by using the leading-argument forwarding syntax available since Ruby 2.7.3. Test both the minimum version and the latest 2.7 patch release. Assisted-By: devx/4adb4993-e502-416b-8fe7-efc94c16ae7e
1 parent cb7852f commit 048c8de

8 files changed

Lines changed: 21 additions & 14 deletions

File tree

.github/workflows/test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
os:
1414
- ubuntu-latest
1515
ruby:
16+
- '2.7'
17+
- '2.7.3'
1618
- '3.0'
1719
- '3.1'
1820
- '3.2'

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ require:
22
- rubocop-packaging
33

44
AllCops:
5-
TargetRubyVersion: 3.0
5+
TargetRubyVersion: 2.7
66
DisabledByDefault: true
77
Exclude:
88
- '**/vendor/**/*'

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ All notable changes to this project will be documented in this file. For info on
2020

2121
### Changed
2222

23-
- Require Ruby 3.0 or newer and replace `ruby2_keywords` with argument forwarding.
23+
- Require Ruby 2.7.3 or newer and replace `ruby2_keywords` with argument forwarding.
2424
- Raise before exceeding a part limit, not after. ([#2362](https://github.com/rack/rack/pull/2362), [@matthew-puku](https://github.com/matthew-puku))
2525
- Rack::Deflater now uses a fixed GZip mtime value. ([#2372](https://github.com/rack/rack/pull/2372), [@bensheldon](https://github.com/bensheldon))
2626
- Multipart parser drops support for RFC 2231 `filename*` parameter (prohibited by RFC 7578) and now properly handles UTF-8 encoded filenames via percent-encoding and direct UTF-8 bytes. ([#2398](https://github.com/rack/rack/pull/2398), [@wtn](https://github.com/wtn))

lib/rack/headers.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,11 @@ def transform_keys!
217217
replace(hash)
218218
end
219219

220-
def except(*a)
221-
super(*a.map!{|key| downcase_key(key)})
220+
# Ruby < 3.0 does not provide Hash#except.
221+
if Hash.method_defined?(:except)
222+
def except(*a)
223+
super(*a.map!{|key| downcase_key(key)})
224+
end
222225
end
223226

224227
private

lib/rack/mock_response.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def initialize(args)
2323
@secure = args["secure"]
2424
end
2525

26-
def method_missing(method_name, ...)
27-
@value.send(method_name, ...)
26+
def method_missing(...)
27+
@value.send(...)
2828
end
2929

3030
def respond_to_missing?(method_name, include_all = false)

lib/rack/multipart/uploaded_file.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ def respond_to_missing?(*args)
7474
end
7575

7676
# Delegate method missing calls to the tempfile.
77-
def method_missing(method_name, ...) #:nodoc:
78-
@tempfile.__send__(method_name, ...)
77+
def method_missing(...) #:nodoc:
78+
@tempfile.__send__(...)
7979
end
8080
end
8181
end

rack.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
2525

2626
s.homepage = 'https://github.com/rack/rack'
2727

28-
s.required_ruby_version = '>= 3.0.0'
28+
s.required_ruby_version = '>= 2.7.3'
2929

3030
s.metadata = {
3131
"bug_tracker_uri" => "https://github.com/rack/rack/issues",

test/spec_headers.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -503,10 +503,12 @@ def test_deconstruct_keys
503503
assert_equal(Rack::Headers, @fh.deconstruct_keys([]).class)
504504
end
505505

506-
def test_except
507-
@fh = Rack::Headers['AB'=>'1', 'Cd'=>'2', '3'=>'4']
508-
assert_equal(@fh, @fh.except)
509-
assert_equal(Rack::Headers['cD'=>'2', '3'=>'4'], @fh.except('AB', 5))
510-
assert_equal(Rack::Headers['AB'=>'1'], @fh.except('cD', '3'))
506+
if Hash.method_defined?(:except)
507+
def test_except
508+
@fh = Rack::Headers['AB'=>'1', 'Cd'=>'2', '3'=>'4']
509+
assert_equal(@fh, @fh.except)
510+
assert_equal(Rack::Headers['cD'=>'2', '3'=>'4'], @fh.except('AB', 5))
511+
assert_equal(Rack::Headers['AB'=>'1'], @fh.except('cD', '3'))
512+
end
511513
end
512514
end

0 commit comments

Comments
 (0)