Class: Seijaku::Payload
- Inherits:
-
Object
- Object
- Seijaku::Payload
- Defined in:
- lib/seijaku/payload.rb
Overview
Payload refers to the payload YAML file submitted by the user. it includes tasks, steps, variables and name.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #execute! ⇒ Object
- #get_variables(payload_variables) ⇒ Object
-
#initialize(payload, logger) ⇒ Payload
constructor
A new instance of Payload.
Constructor Details
#initialize(payload, logger) ⇒ Payload
Returns a new instance of Payload.
9 10 11 12 13 14 15 16 17 |
# File 'lib/seijaku/payload.rb', line 9 def initialize(payload, logger) @name = payload.fetch(:name) @variables = get_variables(payload.fetch(:variables)) @ssh_hosts = SSHGroup.new(payload.fetch(:ssh, [])) @ssh_settings = payload.fetch(:ssh_settings, {}) @tasks = payload.fetch(:tasks).map do |task| Task.new(task, @variables, logger, @ssh_hosts, @ssh_settings) end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/seijaku/payload.rb', line 7 def name @name end |
Instance Method Details
#execute! ⇒ Object
19 20 21 |
# File 'lib/seijaku/payload.rb', line 19 def execute! @tasks.each(&:execute!) end |
#get_variables(payload_variables) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/seijaku/payload.rb', line 23 def get_variables(payload_variables) sorted_variables = {} variables = payload_variables.map do |var| Variable.new(var) end variables.each do |var| sorted_variables.merge!({ var.key => var.value }) end sorted_variables end |