diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d5db9ab2c1..daf28bdd62 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,8 +26,6 @@ jobs: ruby: ['2.7', '3.0', '3.1', '3.2'] gemfile: [rack_2_0, rack_3_0, rails_6_0, rails_6_1, rails_7_0, rails_7_1] include: - - ruby: '2.6' - gemfile: rails_5_2 - ruby: '2.7' gemfile: rack_1_0 - ruby: '2.7' diff --git a/.rubocop.yml b/.rubocop.yml index 089a33cf67..1776de3c75 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,6 @@ AllCops: NewCops: enable - TargetRubyVersion: 2.6 + TargetRubyVersion: 2.7 SuggestExtensions: false Exclude: - vendor/**/* diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index cffa616810..b065e043fd 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 5000` -# on 2023-07-04 00:22:04 UTC using RuboCop version 1.50.2. +# on 2023-12-19 10:12:38 UTC using RuboCop version 1.50.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -20,7 +20,7 @@ Lint/AmbiguousBlockAssociation: Exclude: - 'spec/grape/dsl/routing_spec.rb' -# Offense count: 40 +# Offense count: 56 # Configuration parameters: AllowedMethods. # AllowedMethods: enums Lint/ConstantDefinitionInBlock: @@ -34,7 +34,6 @@ Lint/ConstantDefinitionInBlock: - 'spec/grape/api_spec.rb' - 'spec/grape/entity_spec.rb' - 'spec/grape/loading_spec.rb' - - 'spec/grape/middleware/auth/strategies_spec.rb' - 'spec/grape/middleware/base_spec.rb' - 'spec/grape/middleware/error_spec.rb' - 'spec/grape/middleware/formatter_spec.rb' @@ -52,7 +51,7 @@ Lint/DuplicateBranch: Exclude: - 'spec/support/versioned_helpers.rb' -# Offense count: 71 +# Offense count: 75 # Configuration parameters: AllowComments, AllowEmptyLambdas. Lint/EmptyBlock: Exclude: @@ -134,7 +133,7 @@ RSpec/AnyInstance: - 'spec/grape/api_spec.rb' - 'spec/grape/middleware/base_spec.rb' -# Offense count: 343 +# Offense count: 344 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: @@ -226,7 +225,7 @@ RSpec/ExpectInHook: - 'spec/grape/api_spec.rb' - 'spec/grape/validations/validators/values_spec.rb' -# Offense count: 43 +# Offense count: 47 # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. # Include: **/*_spec*rb*, **/spec/**/* RSpec/FilePath: @@ -289,7 +288,7 @@ RSpec/IndexedLet: - 'spec/grape/presenters/presenter_spec.rb' - 'spec/shared/versioning_examples.rb' -# Offense count: 38 +# Offense count: 44 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: Exclude: @@ -301,7 +300,7 @@ RSpec/InstanceVariable: - 'spec/grape/middleware/versioner/header_spec.rb' - 'spec/grape/validations/validators/except_values_spec.rb' -# Offense count: 84 +# Offense count: 98 RSpec/LeakyConstantDeclaration: Exclude: - 'spec/grape/api/defines_boolean_in_params_spec.rb' @@ -313,7 +312,6 @@ RSpec/LeakyConstantDeclaration: - 'spec/grape/api_spec.rb' - 'spec/grape/entity_spec.rb' - 'spec/grape/loading_spec.rb' - - 'spec/grape/middleware/auth/strategies_spec.rb' - 'spec/grape/middleware/base_spec.rb' - 'spec/grape/middleware/error_spec.rb' - 'spec/grape/middleware/exception_spec.rb' @@ -342,7 +340,7 @@ RSpec/MissingExampleGroupArgument: Exclude: - 'spec/grape/middleware/exception_spec.rb' -# Offense count: 772 +# Offense count: 788 # Configuration parameters: Max. RSpec/MultipleExpectations: Exclude: @@ -422,7 +420,7 @@ RSpec/MultipleMemoizedHelpers: - 'spec/grape/request_spec.rb' - 'spec/grape/validations/attributes_doc_spec.rb' -# Offense count: 2150 +# Offense count: 2182 # Configuration parameters: EnforcedStyle, IgnoreSharedExamples. # SupportedStyles: always, named_only RSpec/NamedSubject: @@ -487,7 +485,7 @@ RSpec/NamedSubject: - 'spec/grape/validations/validators/presence_spec.rb' - 'spec/grape/validations_spec.rb' -# Offense count: 173 +# Offense count: 174 # Configuration parameters: Max, AllowedGroups. RSpec/NestedGroups: Exclude: diff --git a/CHANGELOG.md b/CHANGELOG.md index 76f3ce19ac..821d3fd3b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * [#2379](https://github.com/ruby-grape/grape/pull/2379): Take into account the `route_param` type in `recognize_path` - [@jcagarcia](https://github.com/jcagarcia). * [#2383](https://github.com/ruby-grape/grape/pull/2383): Use regex block instead of if - [@ericproulx](https://github.com/ericproulx). * [#2384](https://github.com/ruby-grape/grape/pull/2384): Allow to use `before/after/rescue_from` methods in any order when using `mount` - [@jcagarcia](https://github.com/jcagarcia). +* [#2390](https://github.com/ruby-grape/grape/pull/2390): Drop support for Ruby 2.6 and Rails 5 - [@ericproulx](https://github.com/ericproulx). * Your contribution here. #### Fixes diff --git a/README.md b/README.md index bc2509cf57..3d4f586f82 100644 --- a/README.md +++ b/README.md @@ -178,7 +178,7 @@ The maintainers of Grape are working with Tidelift to deliver commercial support ## Installation -Ruby 2.6 or newer is required. +Ruby 2.7 or newer is required. Grape is available as a gem, to install it run: diff --git a/gemfiles/rails_5_2.gemfile b/gemfiles/rails_5_2.gemfile deleted file mode 100644 index f5e3f2a55c..0000000000 --- a/gemfiles/rails_5_2.gemfile +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -# This file was generated by Appraisal - -source 'https://rubygems.org' - -gem 'rails', '~> 5.2' - -group :development, :test do - gem 'bundler' - gem 'hashie' - gem 'rake' - gem 'rubocop', '1.50.2', require: false - gem 'rubocop-performance', '1.17.1', require: false - gem 'rubocop-rspec', '2.20.0', require: false -end - -group :development do - gem 'appraisal' - gem 'benchmark-ips' - gem 'benchmark-memory' - gem 'guard' - gem 'guard-rspec' - gem 'guard-rubocop' -end - -group :test do - gem 'cookiejar' - gem 'grape-entity', '~> 0.6', require: false - gem 'mime-types' - gem 'rack-jsonp', require: 'rack/jsonp' - gem 'rack-test', '< 2.1' - gem 'rspec', '< 4' - gem 'ruby-grape-danger', '~> 0.2.0', require: false - gem 'simplecov', '~> 0.21.2' - gem 'simplecov-lcov', '~> 0.8.0' - gem 'test-prof', require: false -end - -platforms :jruby do - gem 'racc' -end - -gemspec path: '../' diff --git a/grape.gemspec b/grape.gemspec index 7dbc25a0e7..3ea7193b77 100644 --- a/grape.gemspec +++ b/grape.gemspec @@ -20,7 +20,7 @@ Gem::Specification.new do |s| 'source_code_uri' => "https://github.com/ruby-grape/grape/tree/v#{s.version}" } - s.add_runtime_dependency 'activesupport', '>= 5' + s.add_runtime_dependency 'activesupport', '>= 6' s.add_runtime_dependency 'builder' s.add_runtime_dependency 'dry-types', '>= 1.1' s.add_runtime_dependency 'mustermann-grape', '~> 1.1.0' @@ -29,5 +29,5 @@ Gem::Specification.new do |s| s.files = Dir['lib/**/*', 'CHANGELOG.md', 'CONTRIBUTING.md', 'README.md', 'grape.png', 'UPGRADING.md', 'LICENSE', 'grape.gemspec'] s.require_paths = ['lib'] - s.required_ruby_version = '>= 2.6.0' + s.required_ruby_version = '>= 2.7.0' end diff --git a/lib/grape/api.rb b/lib/grape/api.rb index ef6cb5cf35..536d997e9f 100644 --- a/lib/grape/api.rb +++ b/lib/grape/api.rb @@ -26,8 +26,8 @@ class << self attr_accessor :base_instance, :instances # Rather than initializing an object of type Grape::API, create an object of type Instance - def new(*args, &block) - base_instance.new(*args, &block) + def new(...) + base_instance.new(...) end # When inherited, will create a list of all instances (times the API was mounted) @@ -77,8 +77,8 @@ def configure # the headers, and the body. See [the rack specification] # (http://www.rubydoc.info/github/rack/rack/master/file/SPEC) for more. # NOTE: This will only be called on an API directly mounted on RACK - def call(*args, &block) - instance_for_rack.call(*args, &block) + def call(...) + instance_for_rack.call(...) end # Alleviates problems with autoloading by tring to search for the constant diff --git a/lib/grape/endpoint.rb b/lib/grape/endpoint.rb index f50084270e..121b1c4d68 100644 --- a/lib/grape/endpoint.rb +++ b/lib/grape/endpoint.rb @@ -13,8 +13,8 @@ class Endpoint attr_reader :env, :request, :headers, :params class << self - def new(*args, &block) - self == Endpoint ? Class.new(Endpoint).new(*args, &block) : super + def new(...) + self == Endpoint ? Class.new(Endpoint).new(...) : super end def before_each(new_setup = false, &block) @@ -55,7 +55,7 @@ def generate_api_method(method_name, &block) proc do |endpoint_instance| ActiveSupport::Notifications.instrument('endpoint_render.grape', endpoint: endpoint_instance) do - method.bind(endpoint_instance).call + method.bind_call(endpoint_instance) end end end