Class: Outback::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/outback/manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeManager

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

#errorsObject (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

Parameters:

  • value

    the value to set the attribute logger to.



9
10
11
# File 'lib/outback/manager.rb', line 9

def logger=(value)
  @logger = value
end

#positionObject (readonly)

Returns the value of attribute position.



8
9
10
# File 'lib/outback/manager.rb', line 8

def position
  @position
end

#statusObject (readonly)

Returns the value of attribute status.



8
9
10
# File 'lib/outback/manager.rb', line 8

def status
  @status
end

#tasksObject (readonly)

Returns the value of attribute tasks.



8
9
10
# File 'lib/outback/manager.rb', line 8

def tasks
  @tasks
end

#workdirObject

Returns the value of attribute workdir.



10
11
12
# File 'lib/outback/manager.rb', line 10

def workdir
  @workdir
end

Instance Method Details

#attemptObject



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_taskObject



59
60
61
# File 'lib/outback/manager.rb', line 59

def current_task
  @tasks[@position]
end

#latest_okay?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/outback/manager.rb', line 47

def latest_okay?
  status[1] == 0
end

#rollbackObject



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

#rolloutObject



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

#stateObject



63
64
65
66
67
# File 'lib/outback/manager.rb', line 63

def state
  { :position => @position, 
    :direction => @direction, 
    :statuses => @statuses }
end