Class: Zipline::OutputStream
- Inherits:
-
Zip::OutputStream
- Object
- Zip::OutputStream
- Zipline::OutputStream
- Defined in:
- lib/ext/zipline/output_stream.rb
Instance Method Summary collapse
-
#current_entry ⇒ Object
helper to deal with difference between rubyzip 1.0 and 1.1.
-
#finalize_current_entry ⇒ Object
just reset state, no rewinding required.
-
#initialize(io) ⇒ OutputStream
constructor
we need to be able to hand out own custom output in order to stream to browser.
- #put_next_entry(entry_name, size) ⇒ Object
- #stream ⇒ Object
-
#update_local_headers ⇒ Object
never need to do this because we set correct sizes up front.
- #write_local_footer(entry) ⇒ Object
Constructor Details
#initialize(io) ⇒ OutputStream
we need to be able to hand out own custom output in order to stream to browser
14 15 16 17 18 19 |
# File 'lib/ext/zipline/output_stream.rb', line 14 def initialize(io) # Create an io stream thing super StringIO.new, true # Overwrite it with my own @output_stream = io end |
Instance Method Details
#current_entry ⇒ Object
helper to deal with difference between rubyzip 1.0 and 1.1
58 59 60 |
# File 'lib/ext/zipline/output_stream.rb', line 58 def current_entry @currentEntry || @current_entry end |
#finalize_current_entry ⇒ Object
just reset state, no rewinding required
40 41 42 43 44 45 46 |
# File 'lib/ext/zipline/output_stream.rb', line 40 def finalize_current_entry if current_entry entry = current_entry super (entry) end end |
#put_next_entry(entry_name, size) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ext/zipline/output_stream.rb', line 25 def put_next_entry(entry_name, size) new_entry = Zip::Entry.new(@file_name, entry_name) #THIS IS THE MAGIC, tells zip to look after data for size, crc new_entry.gp_flags = new_entry.gp_flags | 0x0008 super(new_entry) # Uncompressed size in the local file header must be zero when bit 3 # of the general purpose flags is set, so set the size after the header # has been written. new_entry.size = size end |
#stream ⇒ Object
21 22 23 |
# File 'lib/ext/zipline/output_stream.rb', line 21 def stream @output_stream end |
#update_local_headers ⇒ Object
never need to do this because we set correct sizes up front
53 54 55 |
# File 'lib/ext/zipline/output_stream.rb', line 53 def update_local_headers nil end |
#write_local_footer(entry) ⇒ Object
48 49 50 |
# File 'lib/ext/zipline/output_stream.rb', line 48 def (entry) @output_stream << [ 0x08074b50, entry.crc, entry.compressed_size, entry.size].pack('VVVV') end |