Skip to content

Commit

Permalink
Locked version 1 of Grape to Rack 2
Browse files Browse the repository at this point in the history
  • Loading branch information
schinery committed Oct 22, 2023
1 parent 51b081c commit 270e542
Show file tree
Hide file tree
Showing 24 changed files with 43 additions and 271 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
fail-fast: false
matrix:
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]
gemfile: [rack_2_0, rails_6_0, rails_6_1, rails_7_0]
include:
- ruby: '2.6'
gemfile: rails_5_2
Expand Down
12 changes: 0 additions & 12 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ appraise 'rails-7' do
gem 'rails', '~> 7.0'
end

appraise 'rails-edge' do
gem 'rails', github: 'rails/rails'
end

appraise 'rack-edge' do
gem 'rack', github: 'rack/rack'
end

appraise 'multi_json' do
gem 'multi_json', require: 'multi_json'
end
Expand All @@ -39,7 +31,3 @@ end
appraise 'rack2' do
gem 'rack', '~> 2.0.0'
end

appraise 'rack3' do
gem 'rack', '~> 3.0.0'
end
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#### Features

* [#2353](https://github.com/ruby-grape/grape/pull/2353): Added Rails 7.1 support - [@ericproulx](https://github.com/ericproulx).
* [#2360](https://github.com/ruby-grape/grape/pull/2360): Reduce gem size by removing specs - [@ericproulx](https://github.com/ericproulx).
* Your contribution here.

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
- [Grape for Enterprise](#grape-for-enterprise)
- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Rails 7.1](#rails-71)
- [Mounting](#mounting)
- [All](#all)
- [Rack](#rack)
Expand All @@ -26,6 +25,7 @@
- [Rails](#rails)
- [Rails < 5.2](#rails--52)
- [Rails 6.0](#rails-60)
- [Rails >= 7.1](#rails--71)
- [Modules](#modules)
- [Remounting](#remounting)
- [Mount Configuration](#mount-configuration)
Expand All @@ -47,7 +47,7 @@
- [Integer/Fixnum and Coercions](#integerfixnum-and-coercions)
- [Custom Types and Coercions](#custom-types-and-coercions)
- [Multipart File Parameters](#multipart-file-parameters)
- [First-Class JSON Types](#first-class-json-types)
- [First-Class `JSON` Types](#first-class-json-types)
- [Multiple Allowed Types](#multiple-allowed-types)
- [Validation of Nested Parameters](#validation-of-nested-parameters)
- [Dependent Parameters](#dependent-parameters)
Expand Down Expand Up @@ -269,10 +269,6 @@ module Twitter
end
```

## Rails 7.1

Grape's [deprecator](https://api.rubyonrails.org/v7.1.0/classes/ActiveSupport/Deprecation.html) will be added to your application's deprecators [automatically](lib/grape/railtie.rb) as `:grape`, so that your application's configuration can be applied to it.

## Mounting

### All
Expand Down Expand Up @@ -396,6 +392,10 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
end
```

#### Rails >= 7.1

You will need to use version >= 2.0.0 of Grape as that supports Rack >= 3.0, which Rails bumped to in >= 7.1.

### Modules

You can mount multiple API implementations inside another one. These don't have to be
Expand Down
44 changes: 0 additions & 44 deletions gemfiles/rack_3_0.gemfile

This file was deleted.

44 changes: 0 additions & 44 deletions gemfiles/rack_edge.gemfile

This file was deleted.

45 changes: 0 additions & 45 deletions gemfiles/rails_7_1.gemfile

This file was deleted.

44 changes: 0 additions & 44 deletions gemfiles/rails_edge.gemfile

This file was deleted.

4 changes: 2 additions & 2 deletions grape.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ 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', '>= 5', '< 7.1'
s.add_runtime_dependency 'builder'
s.add_runtime_dependency 'dry-types', '>= 1.1'
s.add_runtime_dependency 'mustermann-grape', '~> 1.0.0'
s.add_runtime_dependency 'rack', '>= 1.3.0'
s.add_runtime_dependency 'rack', '>= 1.3.0', '< 3'
s.add_runtime_dependency 'rack-accept'

s.files = Dir['lib/**/*', 'CHANGELOG.md', 'CONTRIBUTING.md', 'README.md', 'grape.png', 'UPGRADING.md', 'LICENSE', 'grape.gemspec']
Expand Down
9 changes: 1 addition & 8 deletions lib/grape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ module Grape
include ActiveSupport::Configurable
extend ::ActiveSupport::Autoload

def self.deprecator
@deprecator ||= ActiveSupport::Deprecation.new('2.0', 'Grape')
end

eager_autoload do
autoload :API
autoload :Endpoint
Expand Down Expand Up @@ -305,8 +301,5 @@ module Types
require 'grape/util/lazy_value'
require 'grape/util/lazy_block'
require 'grape/util/endpoint_configuration'
require 'grape/version'

# https://api.rubyonrails.org/classes/ActiveSupport/Deprecation.html
# adding Grape.deprecator to Rails App if any
require 'grape/railtie' if defined?(Rails::Railtie) && ActiveSupport.gem_version >= Gem::Version.new('7.1')
require 'grape/version'
2 changes: 1 addition & 1 deletion lib/grape/dsl/desc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def desc(description, options = {}, &config_block)
end

config_class.configure(&config_block)
Grape.deprecator.warn('Passing a options hash and a block to `desc` is deprecated. Move all hash options to block.') if options.any?
ActiveSupport::Deprecation.warn('Passing a options hash and a block to `desc` is deprecated. Move all hash options to block.') if options.any?
options = config_class.settings
else
options = options.merge(description: description)
Expand Down
6 changes: 3 additions & 3 deletions lib/grape/dsl/inside_route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,13 @@ def return_no_content
# Deprecated method to send files to the client. Use `sendfile` or `stream`
def file(value = nil)
if value.is_a?(String)
Grape.deprecator.warn('Use sendfile or stream to send files.')
ActiveSupport::Deprecation.warn('Use sendfile or stream to send files.')
sendfile(value)
elsif !value.is_a?(NilClass)
Grape.deprecator.warn('Use stream to use a Stream object.')
ActiveSupport::Deprecation.warn('Use stream to use a Stream object.')
stream(value)
else
Grape.deprecator.warn('Use sendfile or stream to send files.')
ActiveSupport::Deprecation.warn('Use sendfile or stream to send files.')
sendfile
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/grape/exceptions/missing_group_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ def initialize
end
end

Grape::Exceptions::MissingGroupTypeError = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('Grape::Exceptions::MissingGroupTypeError', 'Grape::Exceptions::MissingGroupType', Grape.deprecator)
Grape::Exceptions::MissingGroupTypeError = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('Grape::Exceptions::MissingGroupTypeError', 'Grape::Exceptions::MissingGroupType')
2 changes: 1 addition & 1 deletion lib/grape/exceptions/unsupported_group_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ def initialize
end
end

Grape::Exceptions::UnsupportedGroupTypeError = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('Grape::Exceptions::UnsupportedGroupTypeError', 'Grape::Exceptions::UnsupportedGroupType', Grape.deprecator)
Grape::Exceptions::UnsupportedGroupTypeError = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('Grape::Exceptions::UnsupportedGroupTypeError', 'Grape::Exceptions::UnsupportedGroupType')
9 changes: 0 additions & 9 deletions lib/grape/railtie.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/grape/router/route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def warn_route_methods(name, location, expected = nil)
path, line = *location.scan(SOURCE_LOCATION_REGEXP).first
path = File.realpath(path) if Pathname.new(path).relative?
expected ||= name
Grape.deprecator.warn("#{path}:#{line}: The route_xxx methods such as route_#{name} have been deprecated, please use #{expected}.")
ActiveSupport::Deprecation.warn("#{path}:#{line}: The route_xxx methods such as route_#{name} have been deprecated, please use #{expected}.")
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/grape/validations/validators/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def fail_fast?

Grape::Validations::Base = Class.new(Grape::Validations::Validators::Base) do
def self.inherited(*)
Grape.deprecator.warn 'Grape::Validations::Base is deprecated! Use Grape::Validations::Validators::Base instead.'
ActiveSupport::Deprecation.warn 'Grape::Validations::Base is deprecated! Use Grape::Validations::Validators::Base instead.'
super
end
end
4 changes: 2 additions & 2 deletions lib/grape/validations/validators/values_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ def initialize(attrs, options, required, scope, **opts)
@values = options[:value]
@proc = options[:proc]

Grape.deprecator.warn('The values validator except option is deprecated. Use the except validator instead.') if @excepts
ActiveSupport::Deprecation.warn('The values validator except option is deprecated. Use the except validator instead.') if @excepts

raise ArgumentError, 'proc must be a Proc' if @proc && !@proc.is_a?(Proc)

Grape.deprecator.warn('The values validator proc option is deprecated. The lambda expression can now be assigned directly to values.') if @proc
ActiveSupport::Deprecation.warn('The values validator proc option is deprecated. The lambda expression can now be assigned directly to values.') if @proc
else
@excepts = nil
@values = nil
Expand Down
9 changes: 0 additions & 9 deletions spec/config/spec_test_prof.rb

This file was deleted.

Loading

0 comments on commit 270e542

Please sign in to comment.