Class: Awestruct::Deploy::RSyncDeploy
- Defined in:
- lib/awestruct/deploy/rsync_deploy.rb
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
-
#initialize(site_config, deploy_config) ⇒ RSyncDeploy
constructor
A new instance of RSyncDeploy.
- #publish_site ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(site_config, deploy_config) ⇒ RSyncDeploy
Returns a new instance of RSyncDeploy.
9 10 11 12 13 14 |
# File 'lib/awestruct/deploy/rsync_deploy.rb', line 9 def initialize(site_config, deploy_config) @site_path = File.join( site_config.output_dir, '/' ).gsub(/^\w:\//, '/') @host = deploy_config['host'] @path = File.join( deploy_config['path'], '/' ) @exclude = deploy_config['exclude'] end |
Instance Method Details
#publish_site ⇒ Object
16 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 48 49 50 51 52 53 |
# File 'lib/awestruct/deploy/rsync_deploy.rb', line 16 def publish_site exclude_option = (!@exclude.nil? and !@exclude.empty?) ? "--exclude=" + Shellwords.escape(@exclude) : nil site_path = Shellwords.escape(@site_path) host = Shellwords.escape(@host) path = Shellwords.escape(@path) cmd = "rsync -r -l -i --no-p --no-g --chmod=Dg+sx,ug+rw --delete #{exclude_option} #{site_path} #{host}:#{path}" Open3.popen3( cmd ) do |stdin, stdout, stderr| stdin.close threads = [] threads << Thread.new(stdout) do |i| while ( ! i.eof? ) line = i.readline case line[0,9] when '<f.sT....' $LOG.info " updating #{line[10..-1]}" if $LOG.info? when 'cd+++++++' $LOG.info " creating #{line[10..-1]}" if $LOG.info? when '<f+++++++' $LOG.info " adding #{line[10..-1]}" if $LOG.info? when '<f..T....' # ignoring unchanged files $LOG.debug " no change to #{line[10..-1]}" if $LOG.debug? else $LOG.info line if $LOG.info end end end threads << Thread.new(stderr) do |i| while ( ! i.eof? ) line = i.readline $LOG.info line if $LOG.info? end end threads.each{|t|t.join} end end |