lib/rdiff_simple/rdiff_backup.rb in rdiff-simple-0.0.9 vs lib/rdiff_simple/rdiff_backup.rb in rdiff-simple-0.1.0
- old
+ new
@@ -1,22 +1,20 @@
-require 'open3'
module RdiffSimple
class RdiffBackup
- attr_reader :output_log
+ def initialize(logger = Logger.new(STDOUT), open3 = Open3)
+ @logger = logger
+ @open3 = open3
+ end
def execute(*args)
- raise NotInstalledError, 'rdiff-backup not installed' unless installed?
+ command_arguments = OptionsParser.parse(*args)
- command = ['rdiff-backup', args].flatten!.compact.join(' ').strip
+ out, err, result = @open3.capture3("rdiff-backup #{command_arguments}".strip)
- @output_log, status = Open3.capture2e(command)
- status == EXIT_CODE[:success]
- end
+ @logger.info(out) if out.length > 0
+ @logger.error(err) if err.length > 0
- private
- def installed?
- output, status = Open3.capture2e(COMMANDS[:installed])
- status == EXIT_CODE[:success]
+ return result.exitstatus
end
end
end