Class: Outback::Manager
- Inherits:
-
Object
- Object
- Outback::Manager
- Defined in:
- lib/outback/manager.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#logger ⇒ Object
writeonly
Sets the attribute logger.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#tasks ⇒ Object
readonly
Returns the value of attribute tasks.
-
#workdir ⇒ Object
Returns the value of attribute workdir.
Instance Method Summary collapse
- #attempt ⇒ Object
- #current_task ⇒ Object
-
#initialize ⇒ Manager
constructor
A new instance of Manager.
- #latest_okay? ⇒ Boolean
- #rollback ⇒ Object
- #rollback_from(task) ⇒ Object
- #rollout ⇒ Object
- #rollout_from(task) ⇒ Object
- #state ⇒ Object
Constructor Details
#initialize ⇒ Manager
Returns a new instance of Manager.
12 13 14 15 16 17 |
# File 'lib/outback/manager.rb', line 12 def initialize @tasks = [] @statuses = [] @errors = [] @position = 0 end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
8 9 10 |
# File 'lib/outback/manager.rb', line 8 def errors @errors end |
#logger=(value) ⇒ Object (writeonly)
Sets the attribute logger
9 10 11 |
# File 'lib/outback/manager.rb', line 9 def logger=(value) @logger = value end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
8 9 10 |
# File 'lib/outback/manager.rb', line 8 def position @position end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
8 9 10 |
# File 'lib/outback/manager.rb', line 8 def status @status end |
#tasks ⇒ Object (readonly)
Returns the value of attribute tasks.
8 9 10 |
# File 'lib/outback/manager.rb', line 8 def tasks @tasks end |
#workdir ⇒ Object
Returns the value of attribute workdir.
10 11 12 |
# File 'lib/outback/manager.rb', line 10 def workdir @workdir end |
Instance Method Details
#attempt ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/outback/manager.rb', line 39 def attempt method = {1 => :rollout, -1 => :rollback}[@direction] Dir.chdir(@workdir || Dir.pwd) do @statuses << [method, *current_task.send(method)] end return latest_okay? end |
#current_task ⇒ Object
59 60 61 |
# File 'lib/outback/manager.rb', line 59 def current_task @tasks[@position] end |
#latest_okay? ⇒ Boolean
47 48 49 |
# File 'lib/outback/manager.rb', line 47 def latest_okay? status[1] == 0 end |
#rollback ⇒ Object
24 25 26 27 |
# File 'lib/outback/manager.rb', line 24 def rollback @direction = -1 run end |
#rollback_from(task) ⇒ Object
34 35 36 37 |
# File 'lib/outback/manager.rb', line 34 def rollback_from( task ) @position = @tasks.index(task) - 1 rollback end |
#rollout ⇒ Object
19 20 21 22 |
# File 'lib/outback/manager.rb', line 19 def rollout @direction = 1 run end |
#rollout_from(task) ⇒ Object
29 30 31 32 |
# File 'lib/outback/manager.rb', line 29 def rollout_from( task ) @position = @tasks.index(task) rollout end |
#state ⇒ Object
63 64 65 66 67 |
# File 'lib/outback/manager.rb', line 63 def state { :position => @position, :direction => @direction, :statuses => @statuses } end |