Sha256: c15dd3518792622655450f9c669f3181d9dd28fb389d2cc23647993ef924f0b3

Contents?: true

Size: 790 Bytes

Versions: 6

Compression:

Stored size: 790 Bytes

Contents

module Rbfs
  class Rsync
    def initialize(config = {}, host = nil)
      @config = config
      @host = host
    end

    def sync
      args = ["-ae", "ssh", "--delete", @config[:root], "#{@host.ip}:#{@config[:root]}"]
      args << "-v" if @config[:verbose]
      args << "-n" if @config[:dry]
      args << "--timeout=#{@config[:timeout]}" if @config[:timeout]
      output = command("rsync", args)
      exitcode = $?
      {:output => output, :exitcode => exitcode}
    end

    def command(cmd, options = [], &block)
      cmd_line = "#{cmd} "
      cmd_line += options.join(' ')
      run_command(cmd_line, &block)
    end

    def run_command(cmd, &block)
      if block_given?
        IO.popen("#{cmd} 2>&1", &block)
      else
        `#{cmd} 2>&1`
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rbfs-0.0.8 lib/rbfs/rsync.rb
rbfs-0.0.7 lib/rbfs/rsync.rb
rbfs-0.0.6 lib/rbfs/rsync.rb
rbfs-0.0.5 lib/rbfs/rsync.rb
rbfs-0.0.4 lib/rbfs/rsync.rb
rbfs-0.0.3 lib/rbfs/rsync.rb