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-3.11.0 lib/backup/compressor/bzip2.rb
backup-3.10.0 lib/backup/compressor/bzip2.rb
backup-3.9.0 lib/backup/compressor/bzip2.rb
backup-3.8.0 lib/backup/compressor/bzip2.rb
backup-3.7.2 lib/backup/compressor/bzip2.rb
backup-3.7.1 lib/backup/compressor/bzip2.rb
backup-3.7.0 lib/backup/compressor/bzip2.rb
backup-3.6.0 lib/backup/compressor/bzip2.rb
backup-3.5.1 lib/backup/compressor/bzip2.rb
backup-3.5.0 lib/backup/compressor/bzip2.rb
backup-3.4.0 lib/backup/compressor/bzip2.rb
backup-3.3.2 lib/backup/compressor/bzip2.rb
backup-3.3.1 lib/backup/compressor/bzip2.rb
backup-3.3.0 lib/backup/compressor/bzip2.rb
backup-3.2.0 lib/backup/compressor/bzip2.rb
backup-3.1.3 lib/backup/compressor/bzip2.rb
backup-3.1.2 lib/backup/compressor/bzip2.rb
backup-3.1.1 lib/backup/compressor/bzip2.rb
backup-3.1.0 lib/backup/compressor/bzip2.rb
backup-agoddard-3.0.28 lib/backup/compressor/bzip2.rb