Sha256: f03f2f99d1a14f072c5cd37027587909fa82e0f8ffcc28544c7caeb84b9c15c8

Contents?: true

Size: 816 Bytes

Versions: 1

Compression:

Stored size: 816 Bytes

Contents

require 'logger'
require 'open3'
require_relative 'options_parser'

module RdiffSimple
  class RdiffBackup
    attr_accessor :logger

    def initialize
      yield self if block_given?

      @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.3 lib/rdiff_simple/rdiff_backup.rb