Class: Roast::Workflow::ShellScriptStep

Inherits:
BaseStep
  • Object
show all
Defined in:
lib/roast/workflow/shell_script_step.rb

Instance Attribute Summary collapse

Attributes inherited from BaseStep

#available_tools, #coerce_to, #context_path, #json, #model, #name, #params, #print_response, #resource, #workflow

Instance Method Summary collapse

Constructor Details

#initialize(workflow, script_path:, **options) ⇒ ShellScriptStep

Returns a new instance of ShellScriptStep.



9
10
11
12
13
14
# File 'lib/roast/workflow/shell_script_step.rb', line 9

def initialize(workflow, script_path:, **options)
  super(workflow, **options)
  @script_path = script_path
  @exit_on_error = true  # default to true
  @env = {}              # custom environment variables
end

Instance Attribute Details

#envObject

Returns the value of attribute env.



7
8
9
# File 'lib/roast/workflow/shell_script_step.rb', line 7

def env
  @env
end

#exit_on_errorObject

Returns the value of attribute exit_on_error.



7
8
9
# File 'lib/roast/workflow/shell_script_step.rb', line 7

def exit_on_error
  @exit_on_error
end

#script_pathObject (readonly)

Returns the value of attribute script_path.



6
7
8
# File 'lib/roast/workflow/shell_script_step.rb', line 6

def script_path
  @script_path
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/roast/workflow/shell_script_step.rb', line 16

def call
  validate_script!

  stdout, stderr, status = execute_script

  result = if status.success?
    parse_output(stdout)
  else
    handle_script_error(stderr, status.exitstatus)
  end

  process_output(result, print_response: @print_response)
  result
end