Class: Chiridion::Engine::SpecExampleLoader
- Inherits:
-
Object
- Object
- Chiridion::Engine::SpecExampleLoader
- Defined in:
- lib/chiridion/engine/spec_example_loader.rb
Overview
Extracts usage examples from RSpec files.
Parses spec files to find ‘let` declarations, `subject` blocks, and test descriptions that can serve as documentation examples.
Instance Method Summary collapse
-
#initialize(spec_path, verbose, logger) ⇒ SpecExampleLoader
constructor
A new instance of SpecExampleLoader.
-
#load ⇒ Hash{String => Hash}
Load spec examples for all spec files.
Constructor Details
#initialize(spec_path, verbose, logger) ⇒ SpecExampleLoader
Returns a new instance of SpecExampleLoader.
10 11 12 13 14 |
# File 'lib/chiridion/engine/spec_example_loader.rb', line 10 def initialize(spec_path, verbose, logger) @spec_path = spec_path @verbose = verbose @logger = logger end |
Instance Method Details
#load ⇒ Hash{String => Hash}
Load spec examples for all spec files.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/chiridion/engine/spec_example_loader.rb', line 19 def load examples = {} spec_files = Dir.glob("#{@spec_path}/**/*_spec.rb") return examples if spec_files.empty? @logger.info "Loading examples from #{spec_files.size} spec files..." if @verbose spec_files.each { |file| parse_file(file, examples) } examples end |