Skip to content

Commit

Permalink
Introducing zeitwerk (#2363)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericproulx committed Apr 11, 2024
1 parent 71330b3 commit 2c79b2f
Show file tree
Hide file tree
Showing 73 changed files with 432 additions and 861 deletions.
18 changes: 7 additions & 11 deletions .rubocop_todo.yml
@@ -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
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
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
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
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

0 comments on commit 2c79b2f

Please sign in to comment.