Class: Backup::Compressor::Custom

Inherits:
Base
  • Object
show all
Defined in:
lib/backup/compressor/custom.rb

Constant Summary

Constants included from Backup::CLI::Helpers

Backup::CLI::Helpers::UTILITY

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#compress_with

Methods included from Backup::Configuration::Helpers

included

Constructor Details

#initialize(&block) ⇒ Custom

Initializes a new custom compressor.



24
25
26
27
28
29
30
31
# File 'lib/backup/compressor/custom.rb', line 24

def initialize(&block)
  load_defaults!

  instance_eval(&block) if block_given?

  @cmd = set_cmd
  @ext = set_ext
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Backup::Configuration::Helpers

Instance Attribute Details

#commandObject

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%`



15
16
17
# File 'lib/backup/compressor/custom.rb', line 15

def command
  @command
end

#extensionObject

File extension to append to the compressed file’s filename. e.g. @compressor.extension = ‘.bz2’



20
21
22
# File 'lib/backup/compressor/custom.rb', line 20

def extension
  @extension
end