Class: Harrison::Deploy::Phase
- Inherits:
-
Object
- Object
- Harrison::Deploy::Phase
- Defined in:
- lib/harrison/deploy/phase.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #_fail(context) ⇒ Object
-
#_run(context) ⇒ Object
These should only be invoked by the deploy action.
- #add_condition(&block) ⇒ Object
-
#initialize(name) {|_self| ... } ⇒ Phase
constructor
A new instance of Phase.
-
#matches_context?(context) ⇒ Boolean
Ensure all conditions eval to true for this context.
- #on_fail(&block) ⇒ Object
- #on_run(&block) ⇒ Object
Constructor Details
#initialize(name) {|_self| ... } ⇒ Phase
Returns a new instance of Phase.
5 6 7 8 9 10 11 |
# File 'lib/harrison/deploy/phase.rb', line 5 def initialize(name, &phase_config) self.name = name @conditions = Array.new yield self if block_given? end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/harrison/deploy/phase.rb', line 3 def name @name end |
Instance Method Details
#_fail(context) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/harrison/deploy/phase.rb', line 40 def _fail(context) # 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) end end |
#_run(context) ⇒ Object
These should only be invoked by the deploy action.
31 32 33 34 35 36 37 38 |
# File 'lib/harrison/deploy/phase.rb', line 31 def _run(context) return unless matches_context?(context) if @run_block puts "[#{context.host}] Executing \"#{self.name}\"..." @run_block.call(context) end end |
#add_condition(&block) ⇒ Object
13 14 15 |
# File 'lib/harrison/deploy/phase.rb', line 13 def add_condition(&block) @conditions << block end |
#matches_context?(context) ⇒ Boolean
Ensure all conditions eval to true for this context.
18 19 20 |
# File 'lib/harrison/deploy/phase.rb', line 18 def matches_context?(context) @conditions.all? { |cblock| cblock.call(context) } end |
#on_fail(&block) ⇒ Object
26 27 28 |
# File 'lib/harrison/deploy/phase.rb', line 26 def on_fail(&block) @fail_block = block end |
#on_run(&block) ⇒ Object
22 23 24 |
# File 'lib/harrison/deploy/phase.rb', line 22 def on_run(&block) @run_block = block end |