Class: Moku::Plan::Plan Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/moku/plan/plan.rb

Overview

This class is abstract.

Plans should be subclasses that override one or more of #prepare, #main, and/or #finish.

A plan is a series of tasks assembled to achieve a particular purpose. When a plan is executed, it procedes through the tasks sequentially until either the series if finished, or a failure is encountered.

Plans are divided into three phases: prepare, main, and finish, in that order. These phases are evaluated separately. #prepare is called first, and #main is not called until the tasks it defines have each executed successfully. The same relationship exists between #main and #finish. This allows for the latter two phases to determine their tasks at runtime based on changes made by the previous phases.

Direct Known Subclasses

BasicBuild, BasicDeploy, Restart

Instance Method Summary collapse

Constructor Details

#initialize(target, logger: Moku.logger) ⇒ Plan

Returns a new instance of Plan.

Parameters:

  • target (Object)

    The object upon which the plan operates.


24
25
26
27
# File 'lib/moku/plan/plan.rb', line 24

def initialize(target, logger: Moku.logger)
  @target = target
  @logger = logger
end

Instance Method Details

#callStatus

Execute the tasks of the plan. If a task fails, halt this process. This method returns the status of the last task.

Returns:


32
33
34
35
36
37
38
# File 'lib/moku/plan/plan.rb', line 32

def call
  Sequence.do([
    proc { run(prepare) },
    proc { run(main) },
    proc { run(finish) }
  ])
end