Class: RosettAi::Backup::Compressor
- Inherits:
-
Object
- Object
- RosettAi::Backup::Compressor
- Defined in:
- lib/rosett_ai/backup/compressor.rb
Overview
Factory and base for compression handlers
Direct Known Subclasses
Constant Summary collapse
- ALGORITHMS =
Returns Algorithms constant.
['zip', 'tar.gz', 'tar.xz'].freeze
Class Method Summary collapse
-
.for(algorithm) ⇒ Compressor
Returns a compressor instance for the given algorithm.
Instance Method Summary collapse
-
#available? ⇒ Boolean
abstract
Whether the compression tool is available on this system.
-
#compress(files, base_dirs, output_path, level: nil) ⇒ String
abstract
Compresses files into an archive at
output_path. -
#extension ⇒ String
File extension for archives produced by this compressor.
Class Method Details
.for(algorithm) ⇒ Compressor
Returns a compressor instance for the given algorithm.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rosett_ai/backup/compressor.rb', line 23 def self.for(algorithm) case algorithm when 'zip' then ZipCompressor.new when 'tar.gz' then TarGzCompressor.new when 'tar.xz' then TarXzCompressor.new else raise RosettAi::BackupError, "Unknown compression algorithm: #{algorithm}. Supported: #{ALGORITHMS.join(', ')}" end end |
Instance Method Details
#available? ⇒ Boolean
This method is abstract.
Subclasses must implement this method.
Whether the compression tool is available on this system.
38 39 40 |
# File 'lib/rosett_ai/backup/compressor.rb', line 38 def available? raise NotImplementedError end |
#compress(files, base_dirs, output_path, level: nil) ⇒ String
This method is abstract.
Subclasses must implement this method.
Compresses files into an archive at output_path.
57 58 59 |
# File 'lib/rosett_ai/backup/compressor.rb', line 57 def compress(files, base_dirs, output_path, level: nil) raise NotImplementedError end |
#extension ⇒ String
File extension for archives produced by this compressor.
45 46 47 |
# File 'lib/rosett_ai/backup/compressor.rb', line 45 def extension raise NotImplementedError end |