Sha256: 38a1c119af2c433c7a825dd64a69826be15311214aa8a01729ffaf7afe5dd952

Contents?: true

Size: 1020 Bytes

Versions: 2

Compression:

Stored size: 1020 Bytes

Contents

require 'zipruby'

module EPUB
  class OCF
    class PhysicalContainer
      class Zipruby < self
        def open
          Zip::Archive.open @container_path do |archive|
            @monitor.synchronize do
              begin
                @archive = archive
                yield self
              rescue ::Zip::Error => error
                no_entry = NoEntry.new(error.message)
                no_entry.set_backtrace error.backtrace
                raise no_entry
              ensure
                @archive = nil
              end
            end
          end
        end

        def read(path_name)
          if @archive
            @archive.fopen(path_name) {|entry| entry.read}
          else
            open {|container| container.read(path_name)}
          end
        rescue ::Zip::Error => error
          no_entry = NoEntry.new(error.message)
          no_entry.set_backtrace error.backtrace
          raise no_entry
        ensure
          @archive = nil
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
epub-parser-0.2.7 lib/epub/ocf/physical_container/zipruby.rb
epub-parser-0.2.6 lib/epub/ocf/physical_container/zipruby.rb