Class: Mamiya::Steps::Switch
- Defined in:
- lib/mamiya/steps/switch.rb
Instance Attribute Summary
Attributes inherited from Abstract
Instance Method Summary collapse
-
#given_script ⇒ Object
This class see target_dir’s script.
- #release ⇒ Object
- #run! ⇒ Object
-
#script ⇒ Object
XXX: modulize?.
- #switch ⇒ Object
Methods inherited from Abstract
Constructor Details
This class inherits a constructor from Mamiya::Steps::Abstract
Instance Method Details
#given_script ⇒ Object
This class see target_dir’s script
58 |
# File 'lib/mamiya/steps/switch.rb', line 58 alias given_script script |
#release ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/mamiya/steps/switch.rb', line 44 def release # TODO: link with relative if available? # TODO: Restore this if FAILED Mamiya.chdir(target) do logger.info "Releasing..." script.release(labels)[@exception] end end |
#run! ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mamiya/steps/switch.rb', line 7 def run! @exception = nil @switched = false if current_targets_release? logger.info "Already switched" else switch end if @switched ? do_release? : force_release? release else logger.warn "Skipping release" end rescue Exception => e @exception = e raise e ensure logger.warn "Exception occured, cleaning up..." if @exception script.after_switch(labels)[@exception] if @switched logger.info "DONE!" unless @exception end |
#script ⇒ Object
XXX: modulize?
61 62 63 64 65 66 67 68 |
# File 'lib/mamiya/steps/switch.rb', line 61 def script @target_script ||= Mamiya::Script.new.load!( target.join('.mamiya.script', ['script'])).tap do |script| script.set(:deploy_to, config.deploy_to_for(script.application)) script.set(:release_path, target) script.set(:logger, logger) end end |
#switch ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/mamiya/steps/switch.rb', line 34 def switch logger.info "Switching to #{target}" @switched = true script.before_switch(labels)[] next_path = script.release_path.parent.join(script.current_path.basename) next_path.make_symlink(target.realpath) File.rename(next_path, script.current_path) end |