Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing zeitwerk #2363

Merged
merged 25 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 5000`
# on 2024-03-26 03:54:44 UTC using RuboCop version 1.59.0.
# on 2024-04-01 12:18:08 UTC using RuboCop version 1.59.0.
# 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
Expand Down Expand Up @@ -40,7 +40,7 @@ Lint/EmptyClass:
Exclude:
- 'lib/grape/dsl/parameters.rb'

# Offense count: 6
# Offense count: 5
# Configuration parameters: AllowedParentClasses.
Lint/MissingSuper:
Exclude:
Expand All @@ -49,7 +49,6 @@ Lint/MissingSuper:
- 'lib/grape/namespace.rb'
- 'lib/grape/path.rb'
- 'lib/grape/router/pattern.rb'
- 'lib/grape/validations/validators/base.rb'

# Offense count: 1
# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns.
Expand Down Expand Up @@ -92,7 +91,7 @@ RSpec/AnyInstance:
- 'spec/grape/api_spec.rb'
- 'spec/grape/middleware/base_spec.rb'

# Offense count: 2
# Offense count: 1
# Configuration parameters: IgnoredMetadata.
RSpec/DescribeClass:
Exclude:
Expand All @@ -102,7 +101,6 @@ RSpec/DescribeClass:
- '**/spec/system/**/*'
- '**/spec/views/**/*'
- 'spec/grape/named_api_spec.rb'
- 'spec/grape/validations/instance_behaivour_spec.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
Expand Down Expand Up @@ -156,7 +154,7 @@ RSpec/MessageChain:
Exclude:
- 'spec/grape/middleware/formatter_spec.rb'

# Offense count: 148
# Offense count: 144
# Configuration parameters: .
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
Expand Down Expand Up @@ -206,17 +204,15 @@ RSpec/RepeatedExampleGroupDescription:
- 'spec/grape/util/inheritable_setting_spec.rb'
- 'spec/grape/validations/validators/values_spec.rb'

# Offense count: 6
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
RSpec/ScatteredSetup:
Exclude:
- 'spec/grape/util/inheritable_setting_spec.rb'
- 'spec/grape/validations_spec.rb'

# Offense count: 9
# Offense count: 8
RSpec/StubbedMock:
Exclude:
- 'spec/grape/api_spec.rb'
- 'spec/grape/dsl/inside_route_spec.rb'
- 'spec/grape/dsl/routing_spec.rb'
- 'spec/grape/middleware/formatter_spec.rb'
Expand Down Expand Up @@ -295,7 +291,7 @@ Style/OptionalBooleanParameter:
- 'lib/grape/validations/types/primitive_coercer.rb'
- 'lib/grape/validations/types/set_coercer.rb'

# Offense count: 28
# Offense count: 29
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantConstantBase:
Exclude:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* [#2389](https://github.com/ruby-grape/grape/pull/2389): Remove rack-accept dependency - [@ericproulx](https://github.com/ericproulx).
* [#2426](https://github.com/ruby-grape/grape/pull/2426): Drop support for rack 1.x series - [@ericproulx](https://github.com/ericproulx).
* [#2427](https://github.com/ruby-grape/grape/pull/2427): Use `rack-contrib` jsonp instead of rack-jsonp - [@ericproulx](https://github.com/ericproulx).
* [#2363](https://github.com/ruby-grape/grape/pull/2363): Replace autoload by zeitwerk - [@ericproulx](https://github.com/ericproulx).
* Your contribution here.

#### Fixes
Expand Down
7 changes: 7 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ Upgrading Grape

### Upgrading to >= 2.1.0

#### Zeitwerk

Grape's autoloader has been updated and it's now based on [Zeitwerk](https://github.com/fxn/zeitwerk).
If you MP (Monkey Patch) some files and you're not following the [file structure](https://github.com/fxn/zeitwerk?tab=readme-ov-file#file-structure), you might end up with a Zeitwerk error.

See [#2363](https://github.com/ruby-grape/grape/pull/2363) for more information.

#### Changes in rescue_from

The `rack_response` method has been deprecated and the `error_response` method has been removed. Use `error!` instead.
Expand Down
3 changes: 0 additions & 3 deletions benchmark/compile_many_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'grape'
require 'benchmark/ips'
require 'grape/eager_load'

Grape.eager_load!

class API < Grape::API
prefix :api
Expand Down
1 change: 1 addition & 0 deletions grape.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency 'dry-types', '>= 1.1'
s.add_runtime_dependency 'mustermann-grape', '~> 1.1.0'
s.add_runtime_dependency 'rack', '>= 2'
s.add_runtime_dependency 'zeitwerk'

s.files = Dir['lib/**/*', 'CHANGELOG.md', 'CONTRIBUTING.md', 'README.md', 'grape.png', 'UPGRADING.md', 'LICENSE', 'grape.gemspec']
s.require_paths = ['lib']
Expand Down
Loading
Loading