Sha256: f9f7f73b34e89e7a4963919649bf0e399972682e1ccce5f69173418d24c9c63d

Contents?: true

Size: 1.35 KB

Versions: 25

Compression:

Stored size: 1.35 KB

Contents

# encoding: utf-8

module Backup
  module Compressor
    class Gzip < Base

      ##
      # Tells Backup::Compressor::Gzip to compress
      # better rather than faster when set to true
      attr_writer :best

      ##
      # Tells Backup::Compressor::Gzip to compress
      # faster rather than better when set to true
      attr_writer :fast

      ##
      # Creates a new instance of Backup::Compressor::Gzip and
      # configures it to either compress faster or better
      def initialize(&block)
        load_defaults!

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

        instance_eval(&block) if block_given?
      end

      ##
      # Performs the compression of the packages backup file
      def perform!
        log!
        run("#{ utility(:gzip) } #{ options } '#{ Backup::Model.file }'")
        Backup::Model.extension += '.gz'
      end

    private

      ##
      # Combines the provided options and returns a gzip options string
      def options
        (best + fast).join("\s")
      end

      ##
      # Returns the gzip option syntax for compressing
      # better when @best is set to true
      def best
        return ['--best'] if @best; []
      end

      ##
      # Returns the gzip option syntax for compressing
      # faster when @fast is set to true
      def fast
        return ['--fast'] if @fast; []
      end

    end
  end
end

Version data entries

25 entries across 25 versions & 3 rubygems

Version Path
backup-3.0.20 lib/backup/compressor/gzip.rb
backup-3.0.19 lib/backup/compressor/gzip.rb
backup-3.0.18 lib/backup/compressor/gzip.rb
interu-backup-3.0.16 lib/backup/compressor/gzip.rb
backup-3.0.16 lib/backup/compressor/gzip.rb
backup-3.0.15 lib/backup/compressor/gzip.rb
backup-3.0.14 lib/backup/compressor/gzip.rb
backup-3.0.13 lib/backup/compressor/gzip.rb
backup-3.0.12 lib/backup/compressor/gzip.rb
backup-3.0.11 lib/backup/compressor/gzip.rb
alg-backup-3.0.10 lib/backup/compressor/gzip.rb
backup-3.0.10 lib/backup/compressor/gzip.rb
backup-3.0.9 lib/backup/compressor/gzip.rb
backup-3.0.8 lib/backup/compressor/gzip.rb
backup-3.0.7 lib/backup/compressor/gzip.rb
backup-3.0.6 lib/backup/compressor/gzip.rb
backup-3.0.5 lib/backup/compressor/gzip.rb
backup-3.0.4 lib/backup/compressor/gzip.rb
backup-3.0.3 lib/backup/compressor/gzip.rb
backup-3.0.2.build.0 lib/backup/compressor/gzip.rb