Sha256: f78eeb26176061696889237b394f148e7e75a2fb73b22c18b8c7c5a7ee3a316c

Contents?: true

Size: 1.14 KB

Versions: 16

Compression:

Stored size: 1.14 KB

Contents

module Zip
  class ZipStreamableStream < DelegateClass(ZipEntry) #nodoc:all
    def initialize(entry)
      super(entry)
      @tempFile = Tempfile.new(::File.basename(name), ::File.dirname(zipfile))
      @tempFile.binmode
    end

    def get_output_stream
      if block_given?
        begin
          yield(@tempFile)
        ensure
          @tempFile.close
        end
      else
        @tempFile
      end
    end

    def get_input_stream
      if ! @tempFile.closed?
        raise StandardError, "cannot open entry for reading while its open for writing - #{name}"
      end
      @tempFile.open # reopens tempfile from top
      @tempFile.binmode
      if block_given?
        begin
          yield(@tempFile)
        ensure
          @tempFile.close
        end
      else
        @tempFile
      end
    end
    
    def write_to_zip_output_stream(aZipOutputStream)
      aZipOutputStream.put_next_entry(self)
      get_input_stream { |is| IOExtras.copy_stream(aZipOutputStream, is) } 
    end
  end
end

# Copyright (C) 2002, 2003 Thomas Sondergaard
# rubyzip is free software; you can redistribute it and/or
# modify it under the terms of the ruby license.

Version data entries

16 entries across 16 versions & 4 rubygems

Version Path
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/rubyzip-0.9.9/lib/zip/zip_streamable_stream.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/rubyzip-0.9.8/lib/zip/zip_streamable_stream.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/rubyzip-0.9.8/lib/zip/zip_streamable_stream.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/rubyzip-0.9.8/lib/zip/zip_streamable_stream.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/rubyzip-0.9.8/lib/zip/zip_streamable_stream.rb
rubyzip-0.9.9 lib/zip/zip_streamable_stream.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/rubyzip-0.9.8/lib/zip/zip_streamable_stream.rb
rubyzip-0.9.8 lib/zip/zip_streamable_stream.rb
rubyzip-0.9.7 lib/zip/zip_streamable_stream.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/rubyzip-0.9.6.1/lib/zip/zip_streamable_stream.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/rubyzip-0.9.6.1/lib/zip/zip_streamable_stream.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/rubyzip-0.9.6.1/lib/zip/zip_streamable_stream.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/rubyzip-0.9.6.1/lib/zip/zip_streamable_stream.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/rubyzip-0.9.6.1/lib/zip/zip_streamable_stream.rb
rubyzip-0.9.6.1 lib/zip/zip_streamable_stream.rb
mezza-rubyzip-0.9.4.1 lib/zip/zip_streamable_stream.rb