Sha256: 6be49ca6471055587360897dcebe36bd15cc34cd79dbf7ca35f7fa8310fdd7fa

Contents?: true

Size: 1.52 KB

Versions: 11

Compression:

Stored size: 1.52 KB

Contents

require 'zip/zip' #dep

__END__

module Zip
  class ZipOutputStream
    def initialize(fileName)
      super()
      if fileName.is_a?(String) && !fileName.empty?
        @fileName = fileName
        @outputStream = File.new(@fileName, "wb")
      else
        @outputStream = fileName
        @fileName = ''
      end
      @entrySet = ZipEntrySet.new
      @compressor = NullCompressor.instance
      @closed = false
      @currentEntry = nil
      @comment = nil
    end
  end

  class ZipFile < ZipCentralDirectory
    def initialize(stream, create = nil)
      super()
      @name = stream.is_a?(String) ? stream : ''
      @comment = ""
      if stream.is_a?(String) && File.exists?(stream)
        File.open(name, "rb") { |f| read_from_stream(f) }
      elsif (create)
        @entrySet = ZipEntrySet.new
      elsif !stream.is_a?(String) && !create && !stream.respond_to(:path)
        # do nothing here
      elsif !stream.is_a?(String) && !create
        File.open(stream.path, "rb") { |f| read_from_stream(f) }
      else
        raise ZipError, "File #{stream} not found"
      end
      @create = create
      @storedEntries = @entrySet.dup

      @restore_ownership = false
      @restore_permissions = false
      @restore_times = true
    end

    def on_success_replace arg
      if arg.is_a?(String) && !arg.empty?
        tmpfile = get_tempfile
        tmpFilename = tmpfile.path
        tmpfile.close
        if yield tmpFilename
          File.rename(tmpFilename, name)
        end
      else
        yield arg
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 6 rubygems

Version Path
conciergelive-simple_xlsx_writer-0.5.4 lib/simple_xlsx/monkey_patches_for_true_zip_stream.rb
set_simple_xlsx_writer-0.5.4 lib/simple_xlsx/monkey_patches_for_true_zip_stream.rb
axlsx-1.0.7 lib/axlsx/util/monkey_patches_for_true_zip_stream.rb~
axlsx-1.0.6 lib/axlsx/util/monkey_patches_for_true_zip_stream.rb~
axlsx-1.0.5 lib/axlsx/util/monkey_patches_for_true_zip_stream.rb~
axlsx-1.0.4 lib/axlsx/util/monkey_patches_for_true_zip_stream.rb~
axlsx-1.0.3 lib/axlsx/util/monkey_patches_for_true_zip_stream.rb~
axlsx-1.0.1 lib/axlsx/util/monkey_patches_for_true_zip_stream.rb~
backstop-simple_xlsx_writer-0.5.4 lib/simple_xlsx/monkey_patches_for_true_zip_stream.rb
dbortz-simple_xlsx_writer-0.5.3 lib/simple_xlsx/monkey_patches_for_true_zip_stream.rb
simple_xlsx_writer-0.5.3 lib/simple_xlsx/monkey_patches_for_true_zip_stream.rb