Beispiel
Autovivify namespace modules with Zeitwerk across empty directories, non-Ruby assets, and multi-level subdirectory trees
sha256:8fa0af5cf0e7a129c995c34fca5c50864a243c0f2ab9a568a2c7a3633e99b46b
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Fall
- Ziel
- Autovivify namespace modules with Zeitwerk across empty directories, non-Ruby assets, and multi-level subdirectory trees HOW
- Pakete
- zeitwerk 2.8.3
- Umgebung
- ruby
- Erstellt
- 2026-08-16T17:20:20Z
Häufige Annahme
Zeitwerk autovivifies a namespace module for every subdirectory in a managed root directory, treating empty folders and non-Ruby asset directories as constant namespaces.
So hat der Autor des Samples festgehalten, was eine Entwicklerin oder ein Modell hier erwarten würde. Der Vertrag darunter ist das, was tatsächlich lief.
Contract
- assert empty directories and directories containing only non-Ruby assets or hidden dotfiles do not autovivify namespace modules and raise NameError on constant access rather than resolving to Module instances
- assert loader.all_expected_cpaths only tracks directories that contain Ruby source files, omitting empty and non-Ruby directories while cpath_expected_at still computes hypothetical inflection names
- assert accessing nested constants through directories lacking matching Ruby files autovivifies intermediate namespace segments strictly as Module instances, which causes class re-opening to fail with TypeError
- assert providing an explicit matching Ruby file defining a Class allows subsequent nested classes and class re-openings without TypeError
- assert loader.eager_load walks all valid Ruby file trees and autovivifies intermediate modules while leaving empty and non-Ruby directories completely uninitialized
Dateien
- Gemfile
- NOTES.md
- app/asset_dir/README.md
- app/asset_dir/config.json
- app/backup_dir/handler.rb.bak
- app/billing.rb
- app/billing/invoice.rb
- app/billing/invoice/line_item.rb
- app/domain/order/item.rb
- app/empty_dir/.gitkeep
- app/hidden_dir/.secret.rb
- app/services/README.md
- app/services/worker.rb
- csx.json
- test/contract.rb
Verifiziertes Artefakt herunterladen (tar.gz) — genau die Bytes, gegen die der Contract lief
Ursprungs-Seeder
Verifizierungsbelege
- ruby 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · rubygems@1 · 2026-08-16 · ed25519:d91480838ac982c9