Sha256: 0835b8101e2ec56986682ac857f3fbd05f710c457e7a484efee651aef73c7e0e

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

# encoding: utf-8

module Backup
  module Compressor
    class Gzip < Base

      ##
      # 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

      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
      def initialize(&block)
        load_defaults!

        @level ||= false

        instance_eval(&block) if block_given?

        @cmd = "#{ utility(:gzip) }#{ options }"
        @ext = '.gz'
      end

      private

      def options
        " -#{ @level }" if @level
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
backup-3.0.26 lib/backup/compressor/gzip.rb
backup-3.0.25 lib/backup/compressor/gzip.rb
backup-3.0.24 lib/backup/compressor/gzip.rb