Sha256: f889ffdedd32e64957ac78a28a3f22c696ea67b9d918456808e40c4d37184a23

Contents?: true

Size: 1.2 KB

Versions: 11

Compression:

Stored size: 1.2 KB

Contents

module DeepTest
  module Distributed
    class RSync
      def self.sync(connection_info, options, destination)
        command = Args.new(connection_info, options).command(destination)
        DeepTest.logger.debug("rsycing: #{command}")
        successful = system command
        raise "RSync Failed!!" unless successful
      end

      class Args
        def initialize(connection_info, options)
          @connection_info = connection_info
          @options = options
          @sync_options = options.sync_options
        end

        def command(destination)
          # The '/' after source tells rsync to copy the contents
          # of source to destination, rather than the source directory
          # itself
          "rsync -az --delete #{@sync_options[:rsync_options]} #{source_location}/ #{destination}".strip.squeeze(" ")
        end

        def source_location
          source = ""
          unless @sync_options[:local]
            source << @sync_options[:username] << '@' if @sync_options[:username]
            source << @connection_info.address
            source << (@sync_options[:daemon] ? '::' : ':')
          end
          source << @sync_options[:source]
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
jason-o-matic-deep_test-1.2.2.1 lib/deep_test/distributed/rsync.rb
jason-o-matic-deep_test-1.2.2.2 lib/deep_test/distributed/rsync.rb
jperkins-deep_test-1.2.2 lib/deep_test/distributed/rsync.rb
jstorimer-deep-test-1.4.0 lib/deep_test/distributed/rsync.rb
jstorimer-deep-test-1.3.0 lib/deep_test/distributed/rsync.rb
jstorimer-deep-test-1.2.0 lib/deep_test/distributed/rsync.rb
jstorimer-deep-test-1.1.0 lib/deep_test/distributed/rsync.rb
jstorimer-deep-test-1.0.0 lib/deep_test/distributed/rsync.rb
deep_test-1.2.0 lib/deep_test/distributed/rsync.rb
deep_test-1.2.2 lib/deep_test/distributed/rsync.rb
deep_test-1.2.1 lib/deep_test/distributed/rsync.rb