[ruby-nextgen] fix: autoload broken when moduleName differs from camelized gemName
IN
8h ago+146+146+012345678901234567890123456789-50-50-01234567890123456789
Fixes #24997.
ruby-nextgen used Zeitwerk::Loader.for_gem when moduleName is a single level (not nested). for_gem derives its root namespace from the gem name, so with gemName=things_api, moduleName=Things it targeted ThingsApi while the generated files define constants under Things — nothing autoloaded, require 'things_api' then Things::Client raised NameError, and Things.eager_load! failed on uninitialized constant ThingsApi.
What changed
ruby-nextgen/gem.mustache: always drive Zeitwerk explicitly (Zeitwerk::Loader.new+push_dir(..., namespace: self)), removing themoduleNameNestedbranch that fell back tofor_gem. The explicit loader never depended ongemNamematchingmoduleName, and the nested case already used it — so this only changes behavior for the previously broken single-level case. Suggested in the issue by the reporter.
Verification
- New unit test
testZeitwerkLoaderWhenModuleNameDiffersFromGemNamegenerates withgemName=things_api, moduleName=Thingsand asserts the explicitpush_dir(namespace: self)loader is emitted andfor_gemis not.RubyNextgenClientCodegenTest: 24 tests, 0 failures. - Regenerated both
ruby-nextgensample configs (matching gemName/moduleName, so only the loader lines change);ruby -csyntax check passes on the regenerated gems. - The issue reporter verified the same change restores
require 'things_api'+Things::Client.new(...)for the mismatching pair whilegemName=thingskeeps working.
PR checklist
- Read the contribution guidelines.
- Regenerated the affected samples via
./bin/generate-samples.sh(bothruby-nextgenconfigs); no files deleted. - Pull request is created against the
masterbranch.
Summary by cubic
Fixes ruby-nextgen autoloading when moduleName differs from the camelized gemName, URI-encodes Dart-dio path parameters, and pins source_helper below 1.4.0 to fix the freezed variant's build_runner builds.
Bug Fixes
ruby-nextgennow always drives Zeitwerk explicitly withpush_dir(namespace: self)instead ofZeitwerk::Loader.for_gem, which derived the namespace fromgemNameand autoloaded nothing when it didn't matchmoduleName.- Dart-dio path parameters are now wrapped in
Uri.encodeComponentvia a newapi/path_parampartial for all three serialization libraries, so values containing/, spaces, or reserved characters no longer break the request path. - The freezed variant pins
source_helperat>=1.3.8 <1.4.0: 1.4.0's extension members clash withjson_serializable6.x and breakbuild_runnerbuilds, and the 1.3.8 lower bound keeps 1.3.9+ (which requires Dart 3.9) resolvable for the variant's 3.8 baseline.