Skip to content

Commit be8f382

Browse files
authored
Merge pull request #2572 from ericproulx/drop_support_ruby_2_7_0
Drop support ruby 2.7 and active_support 6.1
2 parents 3a06a60 + c4e7bfc commit be8f382

23 files changed

+34
-73
lines changed

.github/workflows/edge.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ jobs:
66
strategy:
77
fail-fast: false
88
matrix:
9-
ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4', ruby-head, truffleruby-head, jruby-head]
9+
ruby: ['3.0', '3.1', '3.2', '3.3', '3.4', ruby-head, truffleruby-head, jruby-head]
1010
gemfile: [rails_edge, rack_edge]
1111
exclude:
12-
- ruby: '2.7'
13-
gemfile: rails_edge
1412
- ruby: '3.0'
1513
gemfile: rails_edge
1614
runs-on: ubuntu-latest

.github/workflows/test.yml

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,10 @@ jobs:
2323
strategy:
2424
fail-fast: false
2525
matrix:
26-
ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4']
27-
gemfile: [Gemfile, gemfiles/rack_2_0.gemfile, gemfiles/rack_3_0.gemfile, gemfiles/rack_3_1.gemfile, gemfiles/rails_6_1.gemfile, gemfiles/rails_7_0.gemfile, gemfiles/rails_7_1.gemfile, gemfiles/rails_7_2.gemfile, gemfiles/rails_8_0.gemfile]
26+
ruby: ['3.0', '3.1', '3.2', '3.3', '3.4']
27+
gemfile: [Gemfile, gemfiles/rack_2_0.gemfile, gemfiles/rack_3_0.gemfile, gemfiles/rack_3_1.gemfile, gemfiles/rails_7_0.gemfile, gemfiles/rails_7_1.gemfile, gemfiles/rails_7_2.gemfile, gemfiles/rails_8_0.gemfile]
2828
specs: ['spec --exclude-pattern=spec/integration/**/*_spec.rb']
2929
include:
30-
- ruby: '2.7'
31-
gemfile: gemfiles/multi_json.gemfile
32-
specs: 'spec/integration/multi_json'
33-
- ruby: '2.7'
34-
gemfile: gemfiles/multi_xml.gemfile
35-
specs: 'spec/integration/multi_xml'
36-
- ruby: '2.7'
37-
gemfile: gemfiles/rack_3_0.gemfile
38-
specs: 'spec/integration/rack_3_0'
3930
- ruby: '3.3'
4031
gemfile: gemfiles/grape_entity.gemfile
4132
specs: 'spec/integration/grape_entity'
@@ -45,9 +36,6 @@ jobs:
4536
- ruby: '3.3'
4637
gemfile: gemfiles/dry_validation.gemfile
4738
specs: 'spec/integration/dry_validation'
48-
- ruby: '3.3'
49-
gemfile: gemfiles/rails_6_1.gemfile
50-
specs: 'spec/integration/rails'
5139
- ruby: '3.3'
5240
gemfile: gemfiles/rails_7_0.gemfile
5341
specs: 'spec/integration/rails'
@@ -61,12 +49,8 @@ jobs:
6149
gemfile: gemfiles/rails_8_0.gemfile
6250
specs: 'spec/integration/rails'
6351
exclude:
64-
- ruby: '2.7'
65-
gemfile: gemfiles/rails_7_2.gemfile
6652
- ruby: '3.0'
6753
gemfile: gemfiles/rails_7_2.gemfile
68-
- ruby: '2.7'
69-
gemfile: gemfiles/rails_8_0.gemfile
7054
- ruby: '3.0'
7155
gemfile: gemfiles/rails_8_0.gemfile
7256
- ruby: '3.1'

.rubocop.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
AllCops:
22
NewCops: enable
3-
TargetRubyVersion: 2.7
3+
TargetRubyVersion: 3.0
44
SuggestExtensions: false
55
Exclude:
66
- vendor/**/*
77
- bin/**/*
88

9-
require:
10-
- rubocop-rspec
11-
129
plugins:
1310
- rubocop-performance
11+
- rubocop-rspec
1412

1513
inherit_from: .rubocop_todo.yml
1614

.rubocop_todo.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2025-02-23 19:41:28 UTC using RuboCop version 1.71.2.
3+
# on 2025-06-18 20:27:19 UTC using RuboCop version 1.76.2.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -15,7 +15,7 @@ Metrics/MethodLength:
1515
# Offense count: 18
1616
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
1717
# SupportedStyles: snake_case, normalcase, non_integer
18-
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
18+
# AllowedIdentifiers: TLS1_1, TLS1_2, capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
1919
Naming/VariableNumber:
2020
Exclude:
2121
- 'spec/grape/dsl/settings_spec.rb'
@@ -39,7 +39,7 @@ RSpec/ExampleWording:
3939
- 'spec/grape/integration/global_namespace_function_spec.rb'
4040
- 'spec/grape/validations_spec.rb'
4141

42-
# Offense count: 7
42+
# Offense count: 6
4343
# This cop supports safe autocorrection (--autocorrect).
4444
RSpec/ExpectActual:
4545
Exclude:
@@ -60,7 +60,7 @@ RSpec/IndexedLet:
6060
- 'spec/grape/presenters/presenter_spec.rb'
6161
- 'spec/shared/versioning_examples.rb'
6262

63-
# Offense count: 39
63+
# Offense count: 40
6464
# Configuration parameters: AssignmentOnly.
6565
RSpec/InstanceVariable:
6666
Exclude:
@@ -75,7 +75,7 @@ RSpec/MessageChain:
7575
Exclude:
7676
- 'spec/grape/middleware/formatter_spec.rb'
7777

78-
# Offense count: 12
78+
# Offense count: 10
7979
RSpec/MissingExampleGroupArgument:
8080
Exclude:
8181
- 'spec/grape/middleware/exception_spec.rb'
@@ -149,12 +149,11 @@ Style/CombinableLoops:
149149
Exclude:
150150
- 'spec/grape/endpoint_spec.rb'
151151

152-
# Offense count: 12
152+
# Offense count: 11
153153
# Configuration parameters: AllowedMethods.
154154
# AllowedMethods: respond_to_missing?
155155
Style/OptionalBooleanParameter:
156156
Exclude:
157-
- 'lib/grape/api.rb'
158157
- 'lib/grape/dsl/inside_route.rb'
159158
- 'lib/grape/dsl/parameters.rb'
160159
- 'lib/grape/endpoint.rb'

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#### Features
44

5+
* [#2572](https://github.com/ruby-grape/grape/pull/2572): Drop support ruby 2.7 and active_support 6.1 - [@ericproulx](https://github.com/ericproulx).
56
* Your contribution here.
67

78
#### Fixes

CONTRIBUTING.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Here are some examples:
4848
- running rspec on a specific file `docker-compose run --rm --build grape rspec spec/:file_path`
4949
- running task `docker-compose run --rm --build grape rake <task_name>`
5050
- running rubocop `docker-compose run --rm --build grape rubocop`
51-
- running all specs on a specific ruby version (e.g 2.7.7) `RUBY_VERSION=2.7.7 docker-compose run --rm --build grape rspec`
51+
- running all specs on a specific ruby version (e.g 3.0) `RUBY_VERSION=3.0 docker-compose run --rm --build grape rspec`
5252
- running specs on a specific gemfile (e.g rails_7_0.gemfile) `docker-compose run -e GEMFILE=rails_7_0 --rm --build grape rspec`
5353
5454
#### Bundle Install and Test
@@ -60,14 +60,6 @@ bundle install
6060
bundle exec rake
6161
```
6262
63-
Run tests against all supported versions of Rails.
64-
65-
```
66-
gem install appraisal
67-
appraisal install
68-
appraisal rake spec
69-
```
70-
7163
#### Write Tests
7264
7365
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [spec/grape](spec/grape).

Gemfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
# when changing this file, run appraisal install ; rubocop -a gemfiles/*.gemfile
4-
53
source('https://rubygems.org')
64

75
gemspec
@@ -10,9 +8,9 @@ group :development, :test do
108
gem 'builder', require: false
119
gem 'bundler'
1210
gem 'rake'
13-
gem 'rubocop', '1.75.8', require: false
11+
gem 'rubocop', '1.76.2', require: false
1412
gem 'rubocop-performance', '1.25.0', require: false
15-
gem 'rubocop-rspec', '3.4.0', require: false
13+
gem 'rubocop-rspec', '3.6.0', require: false
1614
end
1715

1816
group :development do

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ The maintainers of Grape are working with Tidelift to deliver commercial support
174174

175175
## Installation
176176

177-
Ruby 2.7 or newer is required.
177+
Ruby 3.0 or newer is required.
178178

179179
Grape is available as a gem, to install it run:
180180

SECURITY.md

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

33
## Supported Versions
44

5-
Version 1.2.0 or newer is currently supported.
5+
Version 2.2 or newer is currently supported.
66

77
## Reporting a Vulnerability
88

gemfiles/rails_6_1.gemfile

Lines changed: 0 additions & 7 deletions
This file was deleted.

grape.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ Gem::Specification.new do |s|
2121
'rubygems_mfa_required' => 'true'
2222
}
2323

24-
s.add_dependency 'activesupport', '>= 6.1'
24+
s.add_dependency 'activesupport', '>= 7.0'
2525
s.add_dependency 'dry-types', '>= 1.1'
2626
s.add_dependency 'mustermann-grape', '~> 1.1.0'
2727
s.add_dependency 'rack', '>= 2'
2828
s.add_dependency 'zeitwerk'
2929

3030
s.files = Dir['lib/**/*', 'CHANGELOG.md', 'CONTRIBUTING.md', 'README.md', 'grape.png', 'UPGRADING.md', 'LICENSE', 'grape.gemspec']
3131
s.require_paths = ['lib']
32-
s.required_ruby_version = '>= 2.7.0'
32+
s.required_ruby_version = '>= 3.0'
3333
end

lib/grape.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
require 'active_support/concern'
66
require 'active_support/configurable'
77
require 'active_support/version'
8-
require 'active_support/isolated_execution_state' if ActiveSupport::VERSION::MAJOR > 6
8+
require 'active_support/isolated_execution_state'
99
require 'active_support/core_ext/array/conversions'
1010
require 'active_support/core_ext/array/extract_options'
1111
require 'active_support/core_ext/array/wrap'

lib/grape/dsl/request_response.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module ClassMethods
1111
# Specify the default format for the API's serializers.
1212
# May be `:json` or `:txt` (default).
1313
def default_format(new_format = nil)
14-
namespace_inheritable(:default_format, new_format.nil? ? nil : new_format.to_sym)
14+
namespace_inheritable(:default_format, new_format&.to_sym)
1515
end
1616

1717
# Specify the format for the API's serializers.

lib/grape/middleware/formatter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def format_from_extension
132132
dot_pos = request_path.rindex('.')
133133
return unless dot_pos
134134

135-
extension = request_path[dot_pos + 1..]
135+
extension = request_path[(dot_pos + 1)..]
136136
extension if content_type_for(extension)
137137
end
138138

lib/grape/middleware/stack.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ def insert(index, klass, *args, &block)
5959

6060
alias insert_before insert
6161

62-
def insert_after(index, *args, &block)
62+
def insert_after(index, ...)
6363
index = assert_index(index, :after)
64-
insert(index + 1, *args, &block)
64+
insert(index + 1, ...)
6565
end
6666

6767
def use(klass, *args, &block)

lib/grape/middleware/versioner/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Middleware
55
module Versioner
66
class Base < Grape::Middleware::Base
77
DEFAULT_OPTIONS = {
8-
pattern: /.*/i.freeze,
8+
pattern: /.*/i,
99
version_options: {
1010
strict: false,
1111
cascade: true,

lib/grape/middleware/versioner/path.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def before
2828
slash_position = path_info.index('/', 1) # omit the first one
2929
return unless slash_position
3030

31-
potential_version = path_info[1..slash_position - 1]
31+
potential_version = path_info[1..(slash_position - 1)]
3232
return unless potential_version.match?(pattern)
3333

3434
version_not_found! unless potential_version_match?(potential_version)

lib/grape/router.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def self.normalize_path(path)
1919

2020
# Slow path
2121
encoding = path.encoding
22-
path = +"/#{path}"
22+
path = "/#{path}"
2323
path.squeeze!('/')
2424

2525
unless path == '/'

lib/grape/util/media_type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class MediaType
77

88
# based on the HTTP Accept header with the pattern:
99
# application/vnd.:vendor-:version+:format
10-
VENDOR_VERSION_HEADER_REGEX = /\Avnd\.(?<vendor>[a-z0-9.\-_!^]+?)(?:-(?<version>[a-z0-9*.]+))?(?:\+(?<format>[a-z0-9*\-.]+))?\z/.freeze
10+
VENDOR_VERSION_HEADER_REGEX = /\Avnd\.(?<vendor>[a-z0-9.\-_!^]+?)(?:-(?<version>[a-z0-9*.]+))?(?:\+(?<format>[a-z0-9*\-.]+))?\z/
1111

1212
def initialize(type:, subtype:)
1313
@type = type

spec/grape/api_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ def to_txt
10901090

10911091
it 'adds a before filter to current and child namespaces only' do
10921092
subject.get '/' do
1093-
"root - #{instance_variable_defined?(:@foo) ? @foo : nil}"
1093+
"root - #{@foo if instance_variable_defined?(:@foo)}"
10941094
end
10951095
subject.namespace :blah do
10961096
before { @foo = 'foo' }
@@ -1676,13 +1676,13 @@ def call(env)
16761676

16771677
it 'has access to helper methods' do
16781678
subject.helpers do
1679-
def authorize(user, password)
1679+
def authorize?(user, password)
16801680
user == 'allow' && password == 'whatever'
16811681
end
16821682
end
16831683

16841684
subject.http_basic do |u, p|
1685-
authorize(u, p)
1685+
authorize?(u, p)
16861686
end
16871687

16881688
subject.get(:hello) { 'Hello, world.' }

spec/spec_helper.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
Grape.deprecator.behavior = :raise
99

1010
%w[config support].each do |dir|
11-
Dir["#{File.dirname(__FILE__)}/#{dir}/**/*.rb"].sort.each do |file|
11+
Dir["#{File.dirname(__FILE__)}/#{dir}/**/*.rb"].each do |file|
1212
require file
1313
end
1414
end
1515

1616
Grape.config.lint = true # lint all apis by default
1717
Grape::Util::Registry.include(Deregister)
18-
# issue with ruby 2.7 with ^. We need to extend it again
19-
Grape::Validations.extend(Grape::Util::Registry) if Gem::Version.new(RUBY_VERSION).release < Gem::Version.new('3.0')
2018

2119
# The default value for this setting is true in a standard Rails app,
2220
# so it should be set to true here as well to reflect that.

spec/support/chunked_response.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class ChunkedResponse
66
class Body
77
TERM = "\r\n"
8-
TAIL = "0#{TERM}"
8+
TAIL = "0#{TERM}".freeze
99

1010
# Store the response body to be chunked.
1111
def initialize(body)

spec/support/deprecated_warning_handlers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
module DeprecatedWarningHandler
66
class DeprecationWarning < StandardError; end
77

8-
DEPRECATION_REGEX = /is deprecated/.freeze
8+
DEPRECATION_REGEX = /is deprecated/
99

1010
def warn(message)
1111
return super unless message.match?(DEPRECATION_REGEX)

0 commit comments

Comments
 (0)