Class: Bolt::PAL::YamlPlan::Step::Script

Inherits:
Bolt::PAL::YamlPlan::Step show all
Defined in:
lib/bolt/pal/yaml_plan/step/script.rb

Constant Summary

Constants inherited from Bolt::PAL::YamlPlan::Step

COMMON_STEP_KEYS, STEP_KEYS

Instance Attribute Summary

Attributes inherited from Bolt::PAL::YamlPlan::Step

#body, #name, #target, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Bolt::PAL::YamlPlan::Step

create, #function_call, parse_code_string, step_error, validate, validate_puppet_code, validate_step_keys

Constructor Details

#initialize(step_body) ⇒ Script

Returns a new instance of Script.



16
17
18
19
20
21
# File 'lib/bolt/pal/yaml_plan/step/script.rb', line 16

def initialize(step_body)
  super
  @script = step_body['script']
  @parameters = step_body.fetch('parameters', {})
  @arguments = step_body.fetch('arguments', [])
end

Class Method Details

.allowed_keysObject



8
9
10
# File 'lib/bolt/pal/yaml_plan/step/script.rb', line 8

def self.allowed_keys
  super + Set['script', 'parameters', 'arguments']
end

.required_keysObject



12
13
14
# File 'lib/bolt/pal/yaml_plan/step/script.rb', line 12

def self.required_keys
  Set['target']
end

Instance Method Details

#transpileObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/bolt/pal/yaml_plan/step/script.rb', line 23

def transpile
  code = String.new("  ")
  code << "$#{@name} = " if @name

  options = @parameters.dup
  options['arguments'] = @arguments unless @arguments.empty?

  fn = 'run_script'
  args = [@script, @target]
  args << @description if @description
  args << options unless options.empty?

  code << function_call(fn, args)

  code << "\n"
end