class Backup::Compressor::Custom
Attributes
command[RW]
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%`
extension[RW]
File extension to append to the compressed file’s filename. e.g. @compressor.extension = ‘.bz2’
Public Class Methods
new(&block)
click to toggle source
Initializes a new custom compressor.
# File lib/backup/compressor/custom.rb, line 21 def initialize(&block) load_defaults! instance_eval(&block) if block_given? @cmd = set_cmd @ext = set_ext end
Private Instance Methods
set_cmd()
click to toggle source
Return the command line using the full path. Ensures the command exists and is executable.
# File lib/backup/compressor/custom.rb, line 35 def set_cmd parts = @command.to_s.split(" ") parts[0] = utility(parts[0]) parts.join(" ") end
set_ext()
click to toggle source
Return the extension given without whitespace. If extension was not set, return an empty string
# File lib/backup/compressor/custom.rb, line 44 def set_ext @extension.to_s.strip end