Class: Txgh::Handlers::TgzStreamResponse
- Inherits:
-
StreamResponse
- Object
- StreamResponse
- Txgh::Handlers::TgzStreamResponse
- Defined in:
- lib/txgh/handlers/tgz_stream_response.rb
Constant Summary collapse
- PERMISSIONS =
0644
Instance Attribute Summary
Attributes inherited from StreamResponse
Instance Method Summary collapse
Methods inherited from StreamResponse
#error, #headers, #initialize, #streaming?
Constructor Details
This class inherits a constructor from Txgh::Handlers::StreamResponse
Instance Method Details
#file_extension ⇒ Object
28 29 30 |
# File 'lib/txgh/handlers/tgz_stream_response.rb', line 28 def file_extension '.tgz' end |
#write_to(stream) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/txgh/handlers/tgz_stream_response.rb', line 10 def write_to(stream) Zlib::GzipWriter.wrap(stream) do |gz| pipe = StringIO.new('', 'wb') tar = Gem::Package::TarWriter.new(pipe) enum.each do |file_name, contents| tar.add_file(file_name, PERMISSIONS) do |f| f.write(contents) end flush(tar, pipe, gz) stream.flush end flush(tar, pipe, gz) end end |