lib/backup/compressor/gzip.rb in backup-3.0.23 vs lib/backup/compressor/gzip.rb in backup-3.0.24

- old
+ new

@@ -3,44 +3,43 @@ module Backup module Compressor class Gzip < Base ## - # Tells Backup::Compressor::Gzip to compress - # better rather than faster when set to true - attr_accessor :best + # Specify the level of compression to use. + # + # Values should be a single digit from 1 to 9. + # Note that setting the level to either extreme may or may not + # give the desired result. Be sure to check the documentation + # for the compressor being used. + # + # The default `level` is 6. + attr_accessor :level - ## - # Tells Backup::Compressor::Gzip to compress - # faster rather than better when set to true - attr_accessor :fast + attr_deprecate :fast, :version => '3.0.24', + :replacement => :level, + :value => lambda {|val| val ? 1 : nil } + attr_deprecate :best, :version => '3.0.24', + :replacement => :level, + :value => lambda {|val| val ? 9 : nil } ## - # Creates a new instance of Backup::Compressor::Gzip and - # configures it to either compress faster or better + # Creates a new instance of Backup::Compressor::Gzip def initialize(&block) - super + load_defaults! - @best ||= false - @fast ||= false + @level ||= false instance_eval(&block) if block_given? - end - ## - # Yields to the block the compressor command with options - # and it's filename extension. - def compress_with - log! - yield "#{ utility(:gzip) }#{ options }", '.gz' + @cmd = "#{ utility(:gzip) }#{ options }" + @ext = '.gz' end private - ## - # Returns the gzip option syntax for compressing def options - " #{ '--best ' if @best }#{ '--fast' if @fast }".rstrip + " -#{ @level }" if @level end end end end