lib/awestruct/deploy/rsync_deploy.rb in awestruct-0.4.8 vs lib/awestruct/deploy/rsync_deploy.rb in awestruct-0.5.0.cr
- old
+ new
@@ -12,45 +12,41 @@
@path = File.join( deploy_config['path'], '/' )
@exclude = deploy_config['exclude']
end
def publish_site
- exclude_option = ""
- if ! (@exclude.nil? or @exclude.empty?)
- exclude_option = "--exclude=#{@exclude}"
- end
- cmd = "rsync -r -l -i --no-p --no-g --chmod=Dg+sx,ug+rw --delete #{exclude_option} #{@site_path} #{@host}:#{@path}"
+ 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)
- # Shellwords mangles windows rsync command so we need to skip shell words
- if(RUBY_PLATFORM !~ /mingw/)
- cmd = Shellwords.escape(cmd)
- end
+ 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....'
- puts " updating #{line[10..-1]}"
+ $LOG.info " updating #{line[10..-1]}" if $LOG.info?
when 'cd+++++++'
- puts " creating #{line[10..-1]}"
+ $LOG.info " creating #{line[10..-1]}" if $LOG.info?
when '<f+++++++'
- puts " adding #{line[10..-1]}"
+ $LOG.info " adding #{line[10..-1]}" if $LOG.info?
when '<f..T....'
# ignoring unchanged files
- # puts " no change to #{line[10..-1]}"
+ $LOG.debug " no change to #{line[10..-1]}" if $LOG.debug?
else
- puts line
+ $LOG.info line if $LOG.info
end
end
end
threads << Thread.new(stderr) do |i|
while ( ! i.eof? )
line = i.readline
- puts line
+ $LOG.info line if $LOG.info?
end
end
threads.each{|t|t.join}
end
end