Sha256: df8403a048fc31f249d09d08b2c2d5ef98b194f458062ff908b4aca60b00bf91

Contents?: true

Size: 780 Bytes

Versions: 1

Compression:

Stored size: 780 Bytes

Contents

module RdiffSimple
  class RdiffBackup
    attr_accessor :logger, :open3

    def initialize
      yield self if block_given?

      @open3  ||= Open3
      @logger ||= Logger.new(STDOUT)
    end

    def backup(source, destination, *args)
      command_args = OptionsParser.parse *args
      execute "#{command_args} #{source} #{destination}"
    end

    def verify(destination)
      verify_at_time destination, "now"
    end

    def verify_at_time(destination, time)
      execute "--verify-at-time #{time} #{destination}"
    end

    private
    def execute(command)
      output, error, result = open3.capture3 "rdiff-backup #{command}"

      logger.info output unless output.empty?
      logger.error error unless error.empty?

      result.exitstatus
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rdiff-simple-0.1.1 lib/rdiff_simple/rdiff_backup.rb