Sha256: 452b38b7432527c5d4e1f75407c9abca0739f2e2e422e2b001aa553ca33c35a3
Contents?: true
Size: 1.86 KB
Versions: 3
Compression:
Stored size: 1.86 KB
Contents
require 'awestruct/deploy/base_deploy' require 'shellwords' require 'open3' module Awestruct module Deploy class RSyncDeploy < Base 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 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}" # Shellwords mangles windows rsync command so we need to skip shell words if(RUBY_PLATFORM !~ /mingw/) cmd = Shellwords.escape(cmd) end 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]}" when 'cd+++++++' puts " creating #{line[10..-1]}" when '<f+++++++' puts " adding #{line[10..-1]}" when '<f..T....' # ignoring unchanged files # puts " no change to #{line[10..-1]}" else puts line end end end threads << Thread.new(stderr) do |i| while ( ! i.eof? ) line = i.readline puts line end end threads.each{|t|t.join} end end end end end Awestruct::Deployers.instance[ :rsync ] = Awestruct::Deploy::RSyncDeploy
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
awestruct-0.4.8 | lib/awestruct/deploy/rsync_deploy.rb |
awestruct-0.4.7 | lib/awestruct/deploy/rsync_deploy.rb |
awestruct-0.4.6 | lib/awestruct/deploy/rsync_deploy.rb |