Class: Roast::Workflow::StepExecutors::HashStepExecutor

Inherits:
BaseStepExecutor show all
Defined in:
lib/roast/workflow/step_executors/hash_step_executor.rb

Instance Method Summary collapse

Methods inherited from BaseStepExecutor

#initialize

Constructor Details

This class inherits a constructor from Roast::Workflow::StepExecutors::BaseStepExecutor

Instance Method Details

#execute(step) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/roast/workflow/step_executors/hash_step_executor.rb', line 7

def execute(step)
  # execute a command and store the output in a variable
  name, command = step.to_a.flatten

  # Interpolate variable name if it contains {{}}
  interpolated_name = workflow_executor.interpolate(name)

  if command.is_a?(Hash)
    step_runner.execute_steps([command])
  else
    # Interpolate command value
    interpolated_command = workflow_executor.interpolate(command)

    # Check if this step has exit_on_error configuration
    step_config = config_hash[interpolated_name]
    exit_on_error = step_config.is_a?(Hash) ? step_config.fetch("exit_on_error", true) : true

    workflow.output[interpolated_name] = step_runner.execute_step(interpolated_command, exit_on_error: exit_on_error, step_key: interpolated_name)
  end
end