Skip to content

Improve gem loading#96

Merged
samsonjs merged 3 commits into
aserafin:masterfrom
n-rodriguez:wip/improve
Mar 5, 2026
Merged

Improve gem loading#96
samsonjs merged 3 commits into
aserafin:masterfrom
n-rodriguez:wip/improve

Conversation

@n-rodriguez
Copy link
Copy Markdown
Contributor

Fix wrong namespace for loggers, switch to zeitwerk to load gem and prevent this kind of issue in the future.

Thank you!

@samsonjs
Copy link
Copy Markdown
Collaborator

samsonjs commented Mar 5, 2026

Love this change! It is a breaking change so we need to bump the major version. And I think it would be good to go through a deprecation cycle where we assign the previous constants in a minor version bump, and then remove those deprecated compatibility shims in the next major version. Will you help work on that part as well?

Comment thread grape_logging.gemspec
@n-rodriguez
Copy link
Copy Markdown
Contributor Author

n-rodriguez commented Mar 5, 2026

Love this change! It is a breaking change so we need to bump the major version. And I think it would be good to go through a deprecation cycle where we assign the previous constants in a minor version bump, and then remove those deprecated compatibility shims in the next major version. Will you help work on that part as well?

Thank you! But I don't think this a breaking change, rather a fixing change 😄

  1. having Reporters::LoggerReporter, Reporters::ActiveSupportReporter and ParameterFilter badly namespaced was an error in the first place as it could create namespace collisions with user code
  2. by looking at the doc, it seems that these classes are implementation/internal details and users should not rely on it (contrary to the other classes, which don't change)
  3. assigning the previous constants will create the same namespace collisions we are fixing
#!/usr/bin/env ruby

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'grape_logging'
end

class Reporters
end

Reporters.new
./toto.rb:10:in '<main>': Reporters is not a class (TypeError)
/Users/nicolas/.asdf/installs/ruby/4.0.1/lib/ruby/gems/4.0.0/gems/grape_logging-3.0.0/lib/grape_logging/reporters/active_support_reporter.rb:1: previous definition of Reporters was here

@samsonjs
Copy link
Copy Markdown
Collaborator

samsonjs commented Mar 5, 2026

Fair enough, I'm convinced. It would be strange for someone to have been referring to ::Reporters directly without going through GrapeLogging first. Technically a breaking change but maybe I'm being too conservative here.

Copy link
Copy Markdown
Collaborator

@samsonjs samsonjs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much cleaner! 🧼

@samsonjs
Copy link
Copy Markdown
Collaborator

samsonjs commented Mar 5, 2026

Please add a line to changelog and then this is good to merge!

@n-rodriguez
Copy link
Copy Markdown
Contributor Author

@samsonjs

Please add a line to changelog and then this is good to merge!

Done! Thank you!

@samsonjs samsonjs merged commit 9f35f74 into aserafin:master Mar 5, 2026
7 checks passed
@n-rodriguez n-rodriguez deleted the wip/improve branch March 6, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants