Class: SpecForge::Loader::StepProcessor
- Inherits:
-
Object
- Object
- SpecForge::Loader::StepProcessor
- Defined in:
- lib/spec_forge/loader/step_processor.rb
Overview
Processes raw step hashes into normalized, flattened step arrays
Handles the heavy lifting of load-time processing: normalizing step structures, expanding includes, inheriting configuration from parents, applying tags, and flattening nested hierarchies.
Constant Summary collapse
- ACTION_ATTRIBUTES =
Action attributes that execute behavior and cannot be combined with steps
%i[request expects calls debug store].freeze
Instance Method Summary collapse
-
#initialize(blueprints) ⇒ StepProcessor
constructor
Creates a new step processor for the given blueprints.
-
#run ⇒ Array<Array<Hash>, Hash>
Processes all blueprints and returns the flattened, normalized steps.
Constructor Details
#initialize(blueprints) ⇒ StepProcessor
Creates a new step processor for the given blueprints
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/spec_forge/loader/step_processor.rb', line 25 def initialize(blueprints) @blueprints = blueprints @global_hooks = SpecForge.configuration.hooks.transform_values do |callbacks| Normalizer::Transformers.call(:normalize_callback, callbacks) end @forge_hooks = { before: Set.new(@global_hooks[:before_forge]), after: Set.new(@global_hooks[:after_forge]) } end |
Instance Method Details
#run ⇒ Array<Array<Hash>, Hash>
Processes all blueprints and returns the flattened, normalized steps
Performs two passes over the blueprints:
- Preprocessing: normalizes steps and assigns source information
- Main processing: expands includes, inherits shared config, extracts hooks, applies tags, and flattens nested step hierarchies
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/spec_forge/loader/step_processor.rb', line 48 def run # Do a preprocessing pass to ensure all steps are normalized and ready to be referenced @blueprints.each do |name, blueprint| blueprint[:hooks] = { before: Set.new(@global_hooks[:before_blueprint]), after: Set.new(@global_hooks[:after_blueprint]) } blueprint[:steps] = assign_source(blueprint[:steps], file_name: blueprint[:name]) .then { |s| normalize_steps(s) } end @blueprints.each do |name, blueprint| hooks = { before: Set.new(@global_hooks[:before_step]), after: Set.new(@global_hooks[:after_step]) } blueprint[:steps] = (blueprint[:steps]) .then { |s| inherit_shared(s) } .then { |s| validate_steps(s) } .then { |s| extract_and_assign_hooks(s, blueprint, all: hooks) } .then { |s| tag_steps(s) } .then { |s| flatten_steps(s) } .then { |s| remove_empty_steps(s) } end [@blueprints.values, @forge_hooks] end |