lib/backup/compressor/gzip.rb in backup-4.4.1 vs lib/backup/compressor/gzip.rb in backup-5.0.0.beta.1
- old
+ new
@@ -1,7 +1,5 @@
-# encoding: utf-8
-
module Backup
module Compressor
class Gzip < Base
class Error < Backup::Error; end
extend Utilities::Helpers
@@ -33,12 +31,12 @@
##
# Determine if +--rsyncable+ is supported and cache the result.
def self.has_rsyncable?
return @has_rsyncable unless @has_rsyncable.nil?
- cmd = "#{ utility(:gzip) } --rsyncable --version >/dev/null 2>&1; echo $?"
- @has_rsyncable = %x[#{ cmd }].chomp == '0'
+ cmd = "#{utility(:gzip)} --rsyncable --version >/dev/null 2>&1; echo $?"
+ @has_rsyncable = `#{cmd}`.chomp == "0"
end
##
# Creates a new instance of Backup::Compressor::Gzip
def initialize(&block)
@@ -47,28 +45,29 @@
@level ||= false
@rsyncable ||= false
instance_eval(&block) if block_given?
- @cmd = "#{ utility(:gzip) }#{ options }"
- @ext = '.gz'
+ @cmd = "#{utility(:gzip)}#{options}"
+ @ext = ".gz"
end
private
def options
- opts = ''
- opts << " -#{ @level }" if @level
- if self.class.has_rsyncable?
- opts << ' --rsyncable'
- else
- Logger.warn Error.new(<<-EOS)
- 'rsyncable' option ignored.
- Your system's 'gzip' does not support the `--rsyncable` option.
- EOS
- end if @rsyncable
+ opts = ""
+ opts << " -#{@level}" if @level
+ if @rsyncable
+ if self.class.has_rsyncable?
+ opts << " --rsyncable"
+ else
+ Logger.warn Error.new(<<-EOS)
+ 'rsyncable' option ignored.
+ Your system's 'gzip' does not support the `--rsyncable` option.
+ EOS
+ end
+ end
opts
end
-
end
end
end