Class: Omnizip::Pipe::StreamDecompressor
- Inherits:
-
Object
- Object
- Omnizip::Pipe::StreamDecompressor
- Defined in:
- lib/omnizip/pipe/stream_decompressor.rb
Overview
Stream-based decompression for pipe operations
Accepts compressed archive from any IO-like source and extracts to directory or streams to output. Handles multi-file archives and provides error recovery for corrupted streams.
Constant Summary collapse
- DEFAULT_CHUNK_SIZE =
Default chunk size for streaming extraction (64KB)
64 * 1024
Instance Attribute Summary collapse
-
#bytes_written ⇒ Object
readonly
Returns the value of attribute bytes_written.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#output_dir ⇒ Object
readonly
Returns the value of attribute output_dir.
Instance Method Summary collapse
-
#decompress ⇒ Hash<String, Integer>, Integer
Decompress input stream.
-
#initialize(input, output_dir: nil, output: nil, **options) ⇒ StreamDecompressor
constructor
Initialize stream decompressor.
Constructor Details
#initialize(input, output_dir: nil, output: nil, **options) ⇒ StreamDecompressor
Initialize stream decompressor
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/omnizip/pipe/stream_decompressor.rb', line 36 def initialize(input, output_dir: nil, output: nil, **) @input = input @output_dir = output_dir @output = output @options = @chunk_size = [:chunk_size] || DEFAULT_CHUNK_SIZE @bytes_written = 0 @progress_callback = [:progress] @format = [:format] @preserve_paths = .fetch(:preserve_paths, true) end |
Instance Attribute Details
#bytes_written ⇒ Object (readonly)
Returns the value of attribute bytes_written.
24 25 26 |
# File 'lib/omnizip/pipe/stream_decompressor.rb', line 24 def bytes_written @bytes_written end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
24 25 26 |
# File 'lib/omnizip/pipe/stream_decompressor.rb', line 24 def input @input end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
24 25 26 |
# File 'lib/omnizip/pipe/stream_decompressor.rb', line 24 def @options end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
24 25 26 |
# File 'lib/omnizip/pipe/stream_decompressor.rb', line 24 def output @output end |
#output_dir ⇒ Object (readonly)
Returns the value of attribute output_dir.
24 25 26 |
# File 'lib/omnizip/pipe/stream_decompressor.rb', line 24 def output_dir @output_dir end |
Instance Method Details
#decompress ⇒ Hash<String, Integer>, Integer
Decompress input stream
Extracts archive to output directory or streams to output. Returns hash of extracted files or bytes written.
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/omnizip/pipe/stream_decompressor.rb', line 55 def decompress if @output decompress_to_stream elsif @output_dir decompress_to_directory else raise ArgumentError, "Either output_dir or output must be specified" end end |