Sha256: d0ec21ffc84241b1f4079362209077576efcdfa9390ccccc0424b40ed9e02ddf
Contents?: true
Size: 1.28 KB
Versions: 2
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true module Backup module Compressor class Custom < Base ## # Specify the system command to invoke a compressor, # including any command-line arguments. # e.g. @compressor.command = 'pbzip2 -p2 -4' # # The data to be compressed will be piped to the command's STDIN, # and it should write the compressed data to STDOUT. # i.e. `cat file.tar | %command% > file.tar.%extension%` attr_accessor :command ## # File extension to append to the compressed file's filename. # e.g. @compressor.extension = '.bz2' attr_accessor :extension ## # Initializes a new custom compressor. def initialize(&block) load_defaults! instance_eval(&block) if block_given? @cmd = set_cmd @ext = set_ext end private ## # Return the command line using the full path. # Ensures the command exists and is executable. def set_cmd parts = @command.to_s.split(" ") parts[0] = utility(parts[0]) parts.join(" ") end ## # Return the extension given without whitespace. # If extension was not set, return an empty string def set_ext @extension.to_s.strip end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
backupii-0.1.0.pre.alpha.2 | lib/backup/compressor/custom.rb |
backupii-0.1.0.pre.alpha.1 | lib/backup/compressor/custom.rb |