Class: RosettAi::Backup::TarGzCompressor
- Inherits:
-
Compressor
- Object
- Compressor
- RosettAi::Backup::TarGzCompressor
- Defined in:
- lib/rosett_ai/backup/compressor.rb
Overview
tar.gz compression using Ruby stdlib
Constant Summary
Constants inherited from Compressor
Instance Method Summary collapse
-
#available? ⇒ Boolean
Always true (uses Ruby stdlib).
-
#compress(files, _base_dirs, output_path, level: nil) ⇒ String
The output path.
-
#extension ⇒ String
".tar.gz".
Methods inherited from Compressor
Instance Method Details
#available? ⇒ Boolean
Returns always true (uses Ruby stdlib).
98 99 100 |
# File 'lib/rosett_ai/backup/compressor.rb', line 98 def available? true end |
#compress(files, _base_dirs, output_path, level: nil) ⇒ String
Returns the output path.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/rosett_ai/backup/compressor.rb', line 112 def compress(files, _base_dirs, output_path, level: nil) gz_level = level || Zlib::DEFAULT_COMPRESSION File.open(output_path, 'wb', 0o644) do |file| Zlib::GzipWriter.wrap(file, gz_level) do |gz| Gem::Package::TarWriter.new(gz) do |tar| files.each do |entry| content = File.read(entry[:full_path]) tar.add_file_simple(entry[:archive_path], 0o644, content.bytesize) do |io| io.write(content) end end end end end output_path end |
#extension ⇒ String
Returns ".tar.gz".
103 104 105 |
# File 'lib/rosett_ai/backup/compressor.rb', line 103 def extension '.tar.gz' end |