Class: Seijaku::Task
- Inherits:
-
Object
- Object
- Seijaku::Task
- Defined in:
- lib/seijaku/task.rb
Overview
Task is composed of a name, an array of Step (Pre, Post)
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize(task, variables, logger, ssh_hosts = nil, ssh_settings = {}) ⇒ Task
constructor
A new instance of Task.
Constructor Details
#initialize(task, variables, logger, ssh_hosts = nil, ssh_settings = {}) ⇒ Task
Returns a new instance of Task.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/seijaku/task.rb', line 8 def initialize(task, variables, logger, ssh_hosts = nil, ssh_settings = {}) @name = task.fetch(:name, nil) @host = task.fetch(:host, nil) @steps = task.fetch(:steps, []).map { |step| Step.new(step, variables, :steps, logger, self, ssh_hosts, ssh_settings) } @pre_steps = task.fetch(:pre, []).map { |step| Step.new(step, variables, :pre, logger, self, ssh_hosts, ssh_settings) } @post_steps = task.fetch(:post, []).map { |step| Step.new(step, variables, :post, logger, self, ssh_hosts, ssh_settings) } @logger = logger raise TaskError, "no name set in task", [] if @name.nil? end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
6 7 8 |
# File 'lib/seijaku/task.rb', line 6 def host @host end |
Instance Method Details
#execute! ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/seijaku/task.rb', line 19 def execute! [@pre_steps, @steps, @post_steps].each do |pipeline_steps| pipeline_steps.each do |step| @logger.info(format("[%<name>s:%<pipeline>s] running %<command>s", name: @name, pipeline: step.pipeline, command: step.command)) step.execute! end end end |