Class: Chiridion::Engine::InlineRbsLoader
- Inherits:
-
Object
- Object
- Chiridion::Engine::InlineRbsLoader
- Defined in:
- lib/chiridion/engine/inline_rbs_loader.rb
Overview
Extracts RBS type signatures from inline annotations in Ruby source.
Supports the rbs-inline format where types are specified in comments:
# @rbs param: String -- description
# @rbs return: Integer
def method(param)
This is the preferred way to specify types in source code, as it keeps type information co-located with the code. The RbsLoader handles separate sig/ files as a fallback.
Instance Method Summary collapse
-
#initialize(verbose, logger) ⇒ InlineRbsLoader
constructor
A new instance of InlineRbsLoader.
-
#load(source_files) ⇒ Array(Hash, Hash, Hash)
Extract inline RBS annotations from Ruby source files.
Constructor Details
#initialize(verbose, logger) ⇒ InlineRbsLoader
Returns a new instance of InlineRbsLoader.
19 20 21 22 |
# File 'lib/chiridion/engine/inline_rbs_loader.rb', line 19 def initialize(verbose, logger) @verbose = verbose @logger = logger end |
Instance Method Details
#load(source_files) ⇒ Array(Hash, Hash, Hash)
Extract inline RBS annotations from Ruby source files.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/chiridion/engine/inline_rbs_loader.rb', line 31 def load(source_files) signatures = {} @rbs_file_namespaces = {} @attr_types = {} source_files.each do |file| next unless File.exist?(file) parse_file(file, signatures) end @logger.info "Extracted inline RBS from #{source_files.size} files" if @verbose && source_files.any? [signatures, @rbs_file_namespaces, @attr_types] end |