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 =
['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.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rosett_ai/backup/compressor.rb', line 21 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.
36 37 38 |
# File 'lib/rosett_ai/backup/compressor.rb', line 36 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+.
55 56 57 |
# File 'lib/rosett_ai/backup/compressor.rb', line 55 def compress(files, base_dirs, output_path, level: nil) raise NotImplementedError end |
#extension ⇒ String
File extension for archives produced by this compressor.
43 44 45 |
# File 'lib/rosett_ai/backup/compressor.rb', line 43 def extension raise NotImplementedError end |