샘플
zeitwerk 2.8.3: Autoload constants with Zeitwerk and work out why a correctly written class raises Zeitwerk::NameError, what the error does and does not tell you, and what eager loading really catches
검증된 샘플 — gem zeitwerk 2.8.3: Autoload constants with Zeitwerk and work out why a correctly written class raises Zeitwerk::NameError, what the error does and…
sha256:fe3c29ae9cd4ff1fa9203d040133804b1057836934a88d30aab4c109c86f7647
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 2
- 빌드한 서명 키
- 2
선언된 환경
ruby 3 linux x64 ruby 3 ruby bundler
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| ruby 3 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · gem@1 |
2026-08-14 |
| ruby 3 · linux debian/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · gem@1 |
2026-08-18 |
케이스
HOW- 목표
- Autoload constants with Zeitwerk and work out why a correctly written class raises Zeitwerk::NameError, what the error does and does not tell you, and what eager loading really catches
- 패키지
- 심벌
-
- Zeitwerk::Loader
- Zeitwerk::Loader#push_dir
- Zeitwerk::Loader#setup
- Zeitwerk::Loader#eager_load
- Zeitwerk::Loader#all_expected_cpaths
- Zeitwerk::Inflector
- Zeitwerk::Inflector#camelize
- Zeitwerk::Inflector#inflect
- Zeitwerk::NameError
- Zeitwerk::Error
- 환경
- ruby 3
- 생성일
- 2026-08-14T20:49:04Z
컨트랙트
- assert a conventionally named file installs a pending autoload at setup and runs its body only on the first reference, and that const_defined? cannot tell the two states apart while autoload? can
- assert Zeitwerk::Inflector#camelize is plain underscore camelization, so http_client.rb owes HttpClient and not HTTPClient, with no special case for acronyms
- assert a file that defines the acronym spelling instead raises Zeitwerk::NameError whose message is exactly the file plus the constant Zeitwerk expected, whose name is that expected constant, and which never mentions the constant the file actually defined
- assert the failed autoload still leaves the wrongly named constant loaded and the file in $LOADED_FEATURES, removes the autoload, and degrades the second reference to a plain uninitialized-constant NameError
- assert plain Object.autoload ends in the same state as Zeitwerk for a file that defines the wrong constant, and only keeps the constant pending when the require raises, which is the shape Zeitwerk removes the autoload for
- assert an inflector override replaces the derived name outright so APIGateway autoloads, ApiGateway is never registered, and eager_load then passes
- assert a file that defines no constant at all fails with the same Zeitwerk::NameError after its body has already run
- assert eager_load aborts on the first mismatch in sorted order rather than reporting every mismatch, leaving the later broken file unopened, and that a second run reports the next one
- assert all_expected_cpaths returns the whole path to expected constant map for the tree in one call without loading anything
- assert a directory can be managed by only one loader, and that the second push_dir raises Zeitwerk::Error naming the directory before setup is ever called
- assert zeitwerk 2.8.3 ships no C extension and no runtime dependency, which is why the newest release installs on an image with no compiler
파일
- Gemfile
- Gemfile.lock
- csx.json
- src/autoloading.rb
- src/trees/aftermath/soap_client.rb
- src/trees/audit/oauth_token.rb
- src/trees/audit/sql_builder.rb
- src/trees/audit/user_record.rb
- src/trees/claimed/widget.rb
- src/trees/conventional/json_parser.rb
- src/trees/eager/csv_writer.rb
- src/trees/eager/plain_report.rb
- src/trees/eager/xml_writer.rb
- src/trees/inflected/api_gateway.rb
- src/trees/mismatch/http_client.rb
- src/trees/plain_ruby/legacy_uri.rb
- src/trees/plain_ruby/raises_on_load.rb
- src/trees/silent/audit_log.rb
- test/contract.rb