Class: SpecForge::Loader
- Inherits:
-
Object
- Object
- SpecForge::Loader
- Defined in:
- lib/spec_forge/loader.rb,
lib/spec_forge/loader/filter.rb,
lib/spec_forge/loader/step_processor.rb
Overview
Loads and processes blueprint YAML files into executable Blueprint objects
The Loader handles the load-time phase of SpecForge, reading YAML files, parsing steps with line numbers, expanding includes, flattening hierarchies, and applying filters.
Defined Under Namespace
Classes: Filter, StepProcessor
Class Method Summary collapse
-
.load_blueprints(base_path: nil, paths: [], tags: [], skip_tags: []) ⇒ Array<Blueprint>, Hash
Loads blueprints from disk with optional filtering.
Instance Method Summary collapse
-
#initialize(base_path: nil, paths: [], filter: {}) ⇒ Loader
constructor
Creates a new Loader with the specified base path and filter options.
-
#load ⇒ Array<Blueprint>, Hash
Loads and processes all blueprints, extracting any hook data at the same time.
Constructor Details
#initialize(base_path: nil, paths: [], filter: {}) ⇒ Loader
Creates a new Loader with the specified base path and filter options
35 36 37 38 39 |
# File 'lib/spec_forge/loader.rb', line 35 def initialize(base_path: nil, paths: [], filter: {}) @base_path = base_path.present? ? Pathname.new(base_path) : SpecForge.forge_path.join("blueprints") @paths = Array.wrap(paths).map { |p| Pathname.new(p) } @filter = filter end |
Class Method Details
.load_blueprints(base_path: nil, paths: [], tags: [], skip_tags: []) ⇒ Array<Blueprint>, Hash
Loads blueprints from disk with optional filtering
22 23 24 |
# File 'lib/spec_forge/loader.rb', line 22 def self.load_blueprints(base_path: nil, paths: [], tags: [], skip_tags: []) new(base_path:, paths:, filter: {tags:, skip_tags:}).load end |
Instance Method Details
#load ⇒ Array<Blueprint>, Hash
Loads and processes all blueprints, extracting any hook data at the same time
46 47 48 49 50 51 52 53 54 |
# File 'lib/spec_forge/loader.rb', line 46 def load blueprints, forge_hooks = read_blueprints .index_by { |b| b[:name] } .then { |blueprints| StepProcessor.new(blueprints).run } blueprints = Filter.new(blueprints).run(**@filter).map { |b| Blueprint.new(**b) } [blueprints, forge_hooks] end |