Sha256: 5bc69c5cc422711691864f12e492a8f2bad9de2230510516cda2d381c08f1b4f

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

require 'zipruby'

if $VERBOSE
  warn <<EOW
[WARNING]Default OCF physical container adapter will become ArchiveZip, which uses archive-zip gem to extract contents from EPUB package, instead of current default Zipruby, which uses zipruby gem, in the near future.
You can try ArchiveZip adapter by:

1. gem install archive-zip
2. require 'epub/ocf/physical_container/archive_zip'
3. EPUB::OCF::PhysicalContainer.adapter = :ArchiveZip

If you find problems, please inform me via GitHub issues: https://github.com/KitaitiMakoto/epub-parser/issues
EOW
end

module EPUB
  class OCF
    class PhysicalContainer
      class Zipruby < self
        def open
          Zip::Archive.open @container_path do |archive|
            begin
              @archive = archive
              yield self
            ensure
              @archive = nil
            end
          end
        end

        def read(path_name)
          if @archive
            @archive.fopen(path_name) {|entry| entry.read}
          else
            open {|container| container.read(path_name)}
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
epub-parser-0.2.3 lib/epub/ocf/physical_container/zipruby.rb
epub-parser-0.2.2 lib/epub/ocf/physical_container/zipruby.rb
epub-parser-0.2.1 lib/epub/ocf/physical_container/zipruby.rb