Class: SpecForge::Forge::Hooks

Inherits:
Object
  • Object
show all
Defined in:
lib/spec_forge/forge/hooks.rb

Overview

Executes lifecycle hooks at various points during forge execution

Provides class methods for triggering before/after hooks at the forge, blueprint, and step levels.

Class Method Summary collapse

Class Method Details

.after_blueprint(forge, blueprint) ⇒ void

This method returns an undefined value.

Executes after-blueprint hooks

Parameters:

  • forge (Forge)

    The forge instance

  • blueprint (Blueprint)

    The blueprint that finished



85
86
87
88
89
90
91
# File 'lib/spec_forge/forge/hooks.rb', line 85

def after_blueprint(forge, blueprint)
  hooks = blueprint.hooks[:after]
  return if hooks.blank?

  context = SpecForge::Forge.context.with(forge:, blueprint:)
  run(forge, context, hooks)
end

.after_forge(forge) ⇒ void

This method returns an undefined value.

Executes after-forge hooks

Parameters:

  • forge (Forge)

    The forge instance



100
101
102
103
104
105
106
# File 'lib/spec_forge/forge/hooks.rb', line 100

def after_forge(forge)
  hooks = forge.hooks[:after]
  return if hooks.blank?

  context = SpecForge::Forge.context.with(forge:)
  run(forge, context, hooks)
end

.after_step(forge, blueprint, step, error: nil) ⇒ void

This method returns an undefined value.

Executes after-step hooks

Parameters:

  • forge (Forge)

    The forge instance

  • step (Step)

    The step that finished

  • error (Exception, nil) (defaults to: nil)

    Any error that occurred



69
70
71
72
73
74
75
# File 'lib/spec_forge/forge/hooks.rb', line 69

def after_step(forge, blueprint, step, error: nil)
  hooks = step.hooks[:after]
  return if hooks.blank?

  context = SpecForge::Forge.context.with(forge:, blueprint:, step:, error:)
  run(forge, context, hooks, leading_newline: true)
end

.before_blueprint(forge, blueprint) ⇒ void

This method returns an undefined value.

Executes before-blueprint hooks

Parameters:

  • forge (Forge)

    The forge instance

  • blueprint (Blueprint)

    The blueprint about to execute



36
37
38
39
40
41
42
# File 'lib/spec_forge/forge/hooks.rb', line 36

def before_blueprint(forge, blueprint)
  hooks = blueprint.hooks[:before]
  return if hooks.blank?

  context = SpecForge::Forge.context.with(forge:, blueprint:)
  run(forge, context, hooks, trailing_newline: true)
end

.before_forge(forge) ⇒ void

This method returns an undefined value.

Executes before-forge hooks

Parameters:

  • forge (Forge)

    The forge instance



20
21
22
23
24
25
26
# File 'lib/spec_forge/forge/hooks.rb', line 20

def before_forge(forge)
  hooks = forge.hooks[:before]
  return if hooks.blank?

  context = SpecForge::Forge.context.with(forge:)
  run(forge, context, hooks)
end

.before_step(forge, blueprint, step) ⇒ void

This method returns an undefined value.

Executes before-step hooks

Parameters:

  • forge (Forge)

    The forge instance

  • step (Step)

    The step about to execute



52
53
54
55
56
57
58
# File 'lib/spec_forge/forge/hooks.rb', line 52

def before_step(forge, blueprint, step)
  hooks = step.hooks[:before]
  return if hooks.blank?

  context = SpecForge::Forge.context.with(forge:, blueprint:, step:)
  run(forge, context, hooks, trailing_newline: true)
end