Class: Rigor::SigGen::LayoutIndex
- Inherits:
-
Object
- Object
- Rigor::SigGen::LayoutIndex
- Defined in:
- lib/rigor/sig_gen/layout_index.rb
Overview
Pre-scans every .rbs file under the configured signature_paths to build a qualified_class_name → sig_file_path map.
ADR-14 path-mapper limitation surfaced repeatedly during the self-dogfood: the existing rigor sig/
consolidates multiple .rb sources into one .rbs file (e.g. sig/rigor/type.rbs declares all 14
Type::* classes, sig/rigor.rbs declares CLI::TypeOfCommand and CLI::TypeScanCommand). The naive
1:1 mapper writes new files alongside the existing consolidated ones, producing
RBS::DuplicatedMethodDefinition errors at lookup time.
The index lets PathMapper route a candidate to the consolidated sig file when the class is already declared there, falling back to the 1:1 mirror only when the class has no existing declaration anywhere under the signature tree.
First-found wins on duplicate declarations across files; RBS itself allows the same class to be declared in multiple files for additive member contributions, but the writer only needs one canonical target per class.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#file_for(class_name) ⇒ Pathname?
Absolute path of the sig file that already declares this class, or
nilwhen no existing declaration is found. -
#initialize(signature_paths:, project_root: Dir.pwd) ⇒ LayoutIndex
constructor
A new instance of LayoutIndex.
Constructor Details
#initialize(signature_paths:, project_root: Dir.pwd) ⇒ LayoutIndex
Returns a new instance of LayoutIndex.
30 31 32 33 |
# File 'lib/rigor/sig_gen/layout_index.rb', line 30 def initialize(signature_paths:, project_root: Dir.pwd) @signature_paths = resolve_paths(signature_paths, project_root) @index = nil end |
Instance Method Details
#empty? ⇒ Boolean
44 45 46 |
# File 'lib/rigor/sig_gen/layout_index.rb', line 44 def empty? index.empty? end |
#file_for(class_name) ⇒ Pathname?
Returns absolute path of the sig file
that already declares this class, or nil when no
existing declaration is found.
40 41 42 |
# File 'lib/rigor/sig_gen/layout_index.rb', line 40 def file_for(class_name) index[class_name] end |