Sha256: a1d7ac56a196f1fb22cf195e167383db969af7d8adfa64347809ce6ab74f5e1a

Contents?: true

Size: 1.42 KB

Versions: 14

Compression:

Stored size: 1.42 KB

Contents

require 'awestruct/deployers'

require 'open3'

module Awestruct
  module Deploy
    class RSyncDeploy

      def initialize(site_config, deploy_config)
        @site_path = File.join( site_config.output_dir, '/' )
        @host      = deploy_config['host']
        @path      = File.join( deploy_config['path'], '/' )
      end

      def run
        cmd = "rsync -r -l -i --no-p --no-g --chmod=Dg+s,ug+w --delete #{@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]}"
              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

14 entries across 14 versions & 2 rubygems

Version Path
awestruct-0.4.4 lib/awestruct/deploy/rsync_deploy.rb
awestruct-0.4.3 lib/awestruct/deploy/rsync_deploy.rb
awestruct-0.4.2 lib/awestruct/deploy/rsync_deploy.rb
awestruct-0.4.2.x10 lib/awestruct/deploy/rsync_deploy.rb
awestruct-0.4.2.x9 lib/awestruct/deploy/rsync_deploy.rb
awestruct-0.4.2.x8 lib/awestruct/deploy/rsync_deploy.rb
awestruct-0.4.2.x7 lib/awestruct/deploy/rsync_deploy.rb
awestruct-0.4.2.x6 lib/awestruct/deploy/rsync_deploy.rb
awestruct-0.4.2.x5 lib/awestruct/deploy/rsync_deploy.rb
awestruct-0.4.2.x4 lib/awestruct/deploy/rsync_deploy.rb
awestruct-0.4.2.x3 lib/awestruct/deploy/rsync_deploy.rb
awestruct-0.4.2.x2 lib/awestruct/deploy/rsync_deploy.rb
awestruct-0.4.2.x1 lib/awestruct/deploy/rsync_deploy.rb
awestructx-0.4.1.x1 lib/awestruct/deploy/rsync_deploy.rb