Sha256: 764d41aa9db9135b245d4cc017303f5bf3446e7df9712340e9e3c00a373f9701

Contents?: true

Size: 1.49 KB

Versions: 26

Compression:

Stored size: 1.49 KB

Contents

# encoding: utf-8

module Backup
  module Compressor
    class Pbzip2 < Base

      ##
      # Tells Backup::Compressor::Lzma to compress
      # better (-9) rather than faster when set to true
      attr_accessor :best

      ##
      # Tells Backup::Compressor::Lzma to compress
      # faster (-1) rather than better when set to true
      attr_accessor :fast

      ##
      # Tells Backup::Compressor::Pbzip2 how many processors to use.
      # Autodetects the number of active CPUs by default.
      attr_accessor :processors

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

        @best       ||= false
        @fast       ||= false
        @processors ||= false

        instance_eval(&block) if block_given?

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

      ##
      # Yields to the block the compressor command and filename extension.
      def compress_with
        Backup::Logger.warn(
          "[DEPRECATION WARNING]\n" +
          "  Compressor::Pbzip2 is being deprecated as of backup v.3.0.24\n" +
          "  and will soon be removed. Please see the Compressors wiki page at\n" +
          "  https://github.com/meskyanichi/backup/wiki/Compressors"
        )
        super
      end

      private

      def options
        level = (' --best' if @best) || (' --fast' if @fast)
        cpus  = " -p#{ @processors }" if @processors
        "#{ level }#{ cpus }"
      end

    end
  end
end

Version data entries

26 entries across 26 versions & 3 rubygems

Version Path
backup-3.11.0 lib/backup/compressor/pbzip2.rb
backup-3.10.0 lib/backup/compressor/pbzip2.rb
backup-3.9.0 lib/backup/compressor/pbzip2.rb
backup-3.8.0 lib/backup/compressor/pbzip2.rb
backup-3.7.2 lib/backup/compressor/pbzip2.rb
backup-3.7.1 lib/backup/compressor/pbzip2.rb
backup-3.7.0 lib/backup/compressor/pbzip2.rb
backup-3.6.0 lib/backup/compressor/pbzip2.rb
backup-3.5.1 lib/backup/compressor/pbzip2.rb
backup-3.5.0 lib/backup/compressor/pbzip2.rb
backup-3.4.0 lib/backup/compressor/pbzip2.rb
backup-3.3.2 lib/backup/compressor/pbzip2.rb
backup-3.3.1 lib/backup/compressor/pbzip2.rb
backup-3.3.0 lib/backup/compressor/pbzip2.rb
backup-3.2.0 lib/backup/compressor/pbzip2.rb
backup-3.1.3 lib/backup/compressor/pbzip2.rb
backup-3.1.2 lib/backup/compressor/pbzip2.rb
backup-3.1.1 lib/backup/compressor/pbzip2.rb
backup-3.1.0 lib/backup/compressor/pbzip2.rb
backup-agoddard-3.0.28 lib/backup/compressor/pbzip2.rb