Project

epzip

0.0
Low commit activity in last 3 years
A long-lived project that still receives updates
epzip is an EPUB packing tool. It's just only to do 'zip.'
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 2.3, < 4.0
 Project Readme

epzip

epzip (and epunzip) is an EPUB packing tool. It's just only doing 'zip' and 'unzip'. :)

Installation

$ gem install epzip

epzip requires Ruby 3.0 or later.

Usage

$ epzip <srcdir> [filename]

srcdir is the EPUB resource directory; it has mimetype, META-INF/container.xml, and other assets.

filename is the EPUB filename that will be created. If no filename is given, srcdir + ".epub" is used.

$ epunzip <filename> [targetdir]

filename is the EPUB filename that will be extracted.

targetdir is the EPUB resource directory to be extracted into. If no targetdir is given, the current directory is used.

You can also use it as a library:

require 'epzip'

Epzip.zip("book", "book.epub")
Epzip.unzip("book.epub", "book")
Epzip.unzip("book.epub", "book", overwrite: true) # replace existing files

Handling files from someone else

epzip and epunzip stop with an error, without writing anything, when:

  • srcdir contains a symbolic link to a file outside of it (epzip).
  • an entry would be extracted outside of targetdir, through a symbolic link that already exists in it, or over an existing file (epunzip).

epunzip does not limit the size or the number of the extracted files. If you extract EPUB files that you cannot trust, check them first; for example, sum up Zip::Entry#size of the entries with rubyzip.

Development

$ bundle install
$ bundle exec rake test

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright (c) 2010 Masayoshi Takahashi. See LICENSE for details.