class Harrison::Deploy::Phase
Attributes
name[RW]
Public Class Methods
new(name) { |self| ... }
click to toggle source
# File lib/harrison/deploy/phase.rb, line 5 def initialize(name, &phase_config) self.name = name @conditions = Array.new @limit = nil @_run_count = 0 @_fail_count = 0 yield self if block_given? end
Public Instance Methods
_fail(context)
click to toggle source
# File lib/harrison/deploy/phase.rb, line 54 def _fail(context) # Ensure limit has not been met. return unless @limit.nil? || @_fail_count < @limit # Ensure all conditions eval to true for this context. return unless matches_context?(context) if @fail_block puts "[#{context.host}] Reverting \"#{self.name}\"..." @fail_block.call(context) @_fail_count += 1 end end
_run(context)
click to toggle source
These should only be invoked by the deploy action.
# File lib/harrison/deploy/phase.rb, line 40 def _run(context) # Ensure limit has not been met. return unless @limit.nil? || @_run_count < @limit # Ensure all conditions eval to true for this context. return unless matches_context?(context) if @run_block puts "[#{context.host}] Executing \"#{self.name}\"..." @run_block.call(context) @_run_count += 1 end end
add_condition(&block)
click to toggle source
# File lib/harrison/deploy/phase.rb, line 17 def add_condition(&block) @conditions << block end
matches_context?(context)
click to toggle source
Check if all conditions eval to true for this context.
# File lib/harrison/deploy/phase.rb, line 27 def matches_context?(context) @conditions.all? { |cblock| cblock.call(context) } end
on_fail(&block)
click to toggle source
# File lib/harrison/deploy/phase.rb, line 35 def on_fail(&block) @fail_block = block end
on_run(&block)
click to toggle source
# File lib/harrison/deploy/phase.rb, line 31 def on_run(&block) @run_block = block end
set_limit(n)
click to toggle source
Limit the number of times this phase is invoked per deployment.
# File lib/harrison/deploy/phase.rb, line 22 def set_limit(n) @limit = n end