Sha256: 21ebfb3b89e24bcdc90e4710eceb8b591665084912d94965702139c2d7527a72

Contents?: true

Size: 1.25 KB

Versions: 23

Compression:

Stored size: 1.25 KB

Contents

# encoding: utf-8

module Backup
  module Compressor
    class Bzip2 < 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 9.
      attr_accessor :level

      attr_deprecate :fast, :version => '3.0.24',
                     :message => 'Use Bzip2#level instead.',
                     :action => lambda {|klass, val|
                       klass.level = 1 if val
                     }
      attr_deprecate :best, :version => '3.0.24',
                     :message => 'Use Bzip2#level instead.',
                     :action => lambda {|klass, val|
                       klass.level = 9 if val
                     }

      ##
      # Creates a new instance of Backup::Compressor::Bzip2
      def initialize(&block)
        load_defaults!

        @level ||= false

        instance_eval(&block) if block_given?

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

      private

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

    end
  end
end

Version data entries

23 entries across 23 versions & 3 rubygems

Version Path
backup-agoddard-3.0.27 lib/backup/compressor/bzip2.rb
ey-vendored-backup-3.0.27 lib/backup/compressor/bzip2.rb
backup-3.0.27 lib/backup/compressor/bzip2.rb