Class: OdaniaStaticPages::Deploy::Rsync
- Inherits:
-
Object
- Object
- OdaniaStaticPages::Deploy::Rsync
- Defined in:
- lib/odania_static_pages/deploy/rsync.rb
Instance Method Summary collapse
-
#initialize ⇒ Rsync
constructor
A new instance of Rsync.
- #prepare ⇒ Object
- #publish(color, do_rebuild) ⇒ Object
Constructor Details
#initialize ⇒ Rsync
Returns a new instance of Rsync.
4 5 6 7 8 9 |
# File 'lib/odania_static_pages/deploy/rsync.rb', line 4 def initialize @config = OdaniaStaticPages.config @deploy_config = @config.current_environment.deploy_module @generator_config = @config.generator @local_state = '_local_state.yml' end |
Instance Method Details
#prepare ⇒ Object
11 12 13 14 15 |
# File 'lib/odania_static_pages/deploy/rsync.rb', line 11 def prepare puts 'Preparing rsync state' load_state save_state end |
#publish(color, do_rebuild) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/odania_static_pages/deploy/rsync.rb', line 17 def publish(color, do_rebuild) puts 'Rsync website' load_state color = color.nil? ? @state[:color] : color new_color = 'green'.eql?(color) ? 'blue' : 'green' puts " -> Current color: #{color}" @site_path = @config.output_site_path puts " -> Deploying to color: #{new_color} [Path: #{@site_path}]" @deploy_config.targets[new_color].each do |target| puts puts puts "Syncing target #{target} " + '-' * 50 cmd = "cd #{@site_path} && rsync #{@deploy_config.} . #{target}" puts "Executing: #{cmd}" puts `#{cmd}`.split("\n").join("\n ") unless $?.success? puts 'Error during rsync!!' exit 1 end end @state[:color] = new_color save_state @config.current_environment.do_notify new_color, color puts puts "Finished deploying color #{new_color}" end |