epzip 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '009a0b3b3a3634ddfbbbb46202c0c2feb057d6fefd32843adcbc1680961e2c95'
4
+ data.tar.gz: d98f754594382b1da8e395956fb0b8ef70d6dddd4ae759fc291cfcf918f4597c
5
+ SHA512:
6
+ metadata.gz: c1ba6145ffa9b3f88062da2125f331ac4842a78d706677ef6482ee82c1073b7ba0b6679ba7f35bc70583ff2486742ca61321530bd84c3a5be0c7bf8459cd43f9
7
+ data.tar.gz: 8c3dbcffbdcb720d9bf9896a624de78eda3a804125836558ad64287fed0733785ad841826df62e6958e1c4a1b94f935c6f6361bab1a6d194fdd88728d38b439d
data/CHANGELOG.md ADDED
@@ -0,0 +1,44 @@
1
+ # Changelog
2
+
3
+ ## 0.10.0 - 2026-11-20
4
+
5
+ - Support rubyzip 3.x in addition to 2.x (rubyzip 2.3 or later is now required).
6
+ - Never write an extra field on the `mimetype` entry. With rubyzip 3.x a Zip64
7
+ extra field was added, which EPUB (OCF) does not allow.
8
+ - Require Ruby 3.0 or later.
9
+ - Raise `Epzip::Error` instead of `ArgumentError` for archive entries that
10
+ would extract outside the target directory.
11
+ - `Epzip.unzip` and `epunzip` no longer overwrite existing files. Pass
12
+ `overwrite: true` to `Epzip.unzip` to replace them.
13
+ - `Epzip.unzip` and `epunzip` refuse to extract through a symbolic link that
14
+ already exists in the target directory.
15
+ - `Epzip.unzip` and `epunzip` check every entry before extracting, so a
16
+ rejected archive leaves nothing behind.
17
+ - `Epzip.zip` and `epzip` refuse a symbolic link to a file outside the source
18
+ directory. Links to files inside it are still followed.
19
+ - `Epzip.unzip` and `epunzip` also reject, before extracting, an archive whose
20
+ entries conflict with each other (a name used as both a file and a
21
+ directory) or with a file or directory that already exists in the target.
22
+ - `Epzip.unzip` and `epunzip` extract entries with non-ASCII names into a
23
+ target directory with non-ASCII characters in its path (it raised
24
+ `Encoding::CompatibilityError`), and raise `Epzip::Error` for an entry name
25
+ with a null byte, for a target directory below a file, and, with
26
+ `overwrite: true`, for a named pipe or a device in place of a file.
27
+ - `Epzip.zip` no longer changes the current directory of the process, and
28
+ raises `ArgumentError` when the source is not a directory.
29
+ - `Epzip.zip` and `epzip` name the default output `book.epub` for the source
30
+ `book/` (it was `book/.epub`), and do not pack an output file left in the
31
+ source directory by an earlier run into itself.
32
+ - Print an error message instead of a backtrace when the command-line tools
33
+ hit an invalid archive.
34
+ - Do not leave an empty target directory behind when the archive cannot be
35
+ opened.
36
+ - Move the executables from `bin/` to `exe/`, and stop shipping tests and CI
37
+ settings in the gem.
38
+ - Convert README to Markdown.
39
+
40
+ ## 0.9.0 - 2026-07-04
41
+
42
+ - Support current Ruby and rubyzip versions.
43
+ - Reject archive entries that would extract outside the target directory.
44
+ - Exit with a non-zero status when the command-line tools fail.
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # epzip
2
+
3
+ epzip (and epunzip) is an EPUB packing tool. It's just only doing 'zip' and 'unzip'. :)
4
+
5
+ ## Installation
6
+
7
+ ```console
8
+ $ gem install epzip
9
+ ```
10
+
11
+ epzip requires Ruby 3.0 or later.
12
+
13
+ ## Usage
14
+
15
+ ```console
16
+ $ epzip <srcdir> [filename]
17
+ ```
18
+
19
+ `srcdir` is the EPUB resource directory; it has mimetype, META-INF/container.xml,
20
+ and other assets.
21
+
22
+ `filename` is the EPUB filename that will be created. If no filename is given,
23
+ `srcdir` + ".epub" is used.
24
+
25
+ ```console
26
+ $ epunzip <filename> [targetdir]
27
+ ```
28
+
29
+ `filename` is the EPUB filename that will be extracted.
30
+
31
+ `targetdir` is the EPUB resource directory to be extracted into. If no targetdir
32
+ is given, the current directory is used.
33
+
34
+ You can also use it as a library:
35
+
36
+ ```ruby
37
+ require 'epzip'
38
+
39
+ Epzip.zip("book", "book.epub")
40
+ Epzip.unzip("book.epub", "book")
41
+ Epzip.unzip("book.epub", "book", overwrite: true) # replace existing files
42
+ ```
43
+
44
+ ## Handling files from someone else
45
+
46
+ epzip and epunzip stop with an error, without writing anything, when:
47
+
48
+ * `srcdir` contains a symbolic link to a file outside of it (epzip).
49
+ * an entry would be extracted outside of `targetdir`, through a symbolic link
50
+ that already exists in it, or over an existing file (epunzip).
51
+
52
+ epunzip does not limit the size or the number of the extracted files. If you
53
+ extract EPUB files that you cannot trust, check them first; for example, sum
54
+ up `Zip::Entry#size` of the entries with rubyzip.
55
+
56
+ ## Development
57
+
58
+ ```console
59
+ $ bundle install
60
+ $ bundle exec rake test
61
+ ```
62
+
63
+ ## Note on Patches/Pull Requests
64
+
65
+ * Fork the project.
66
+ * Make your feature addition or bug fix.
67
+ * Add tests for it. This is important so I don't break it in a
68
+ future version unintentionally.
69
+ * Commit, do not mess with rakefile, version, or history.
70
+ (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)
71
+ * Send me a pull request. Bonus points for topic branches.
72
+
73
+ ## Copyright
74
+
75
+ Copyright (c) 2010 Masayoshi Takahashi. See LICENSE for details.
data/exe/epunzip ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'epzip'
5
+
6
+ def error_and_exit(msg)
7
+ warn msg
8
+ exit 1
9
+ end
10
+
11
+ def usage
12
+ error_and_exit "usage: epunzip <filename> [targetdir]"
13
+ end
14
+
15
+ usage unless ARGV.size == 1 || ARGV.size == 2
16
+
17
+ file = ARGV.shift
18
+ unless File.exist?(file)
19
+ error_and_exit "No such file: #{file}"
20
+ end
21
+
22
+ dir = ARGV.shift
23
+ if dir && File.exist?(dir)
24
+ error_and_exit "Directory already exists: #{dir}"
25
+ end
26
+
27
+ begin
28
+ Epzip.unzip(file, dir)
29
+ rescue Epzip::Error, Zip::Error => e
30
+ error_and_exit e.message
31
+ end
data/exe/epzip ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'epzip'
5
+
6
+ def error_and_exit(msg)
7
+ warn msg
8
+ exit 1
9
+ end
10
+
11
+ def usage
12
+ error_and_exit "usage: epzip <srcdir> [filename]"
13
+ end
14
+
15
+ usage unless ARGV.size == 1 || ARGV.size == 2
16
+
17
+ dir = ARGV.shift
18
+ unless File.directory?(dir)
19
+ error_and_exit "No such directory: #{dir}"
20
+ end
21
+
22
+ file = ARGV.shift
23
+ if file && File.exist?(file)
24
+ error_and_exit "File already exists: #{file}"
25
+ end
26
+
27
+ begin
28
+ Epzip.zip(dir, file)
29
+ rescue Epzip::Error, Zip::Error => e
30
+ error_and_exit e.message
31
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Epzip
4
+ VERSION = "0.10.0"
5
+ end
data/lib/epzip.rb CHANGED
@@ -1,47 +1,242 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'zip'
1
4
  require 'fileutils'
2
- require 'tmpdir'
5
+ require_relative 'epzip/version'
6
+
3
7
  class Epzip
8
+ class Error < StandardError; end
9
+
4
10
  MIMETYPE_FILENAME = 'mimetype'
11
+ MIMETYPE_CONTENT = 'application/epub+zip'
5
12
 
6
- @@zip_cmd_path = 'zip'
7
- @@unzip_cmd_path = 'unzip'
8
-
9
- def self.zip_cmd_path=(cmd); @@zip_cmd_path = cmd end
10
- def self.zip_cmd_path; @@zip_cmd_path end
11
- def self.unzip_cmd_path=(cmd); @@unzip_cmd_path = cmd end
12
- def self.unzip_cmd_path; @@unzip_cmd_path end
13
-
13
+ # Packs the directory +epubdir+ into +epubfile+ (default: epubdir + ".epub").
14
+ #
15
+ # Raises Epzip::Error if +epubdir+ contains a symbolic link to a file outside
16
+ # of it, so that packing a directory someone else prepared cannot pull in
17
+ # unrelated files.
14
18
  def self.zip(epubdir, epubfile = nil)
15
- if !File.exists? epubdir
16
- raise ArgumentError, "No such directory -- #{epubdir}"
19
+ Packer.new(epubdir, epubfile).pack
20
+ end
21
+
22
+ # Extracts +epubfile+ into +epubdir+ (default: the current directory).
23
+ #
24
+ # Every entry is checked before anything is written. Epzip::Error is raised,
25
+ # and nothing is extracted, if an entry would be written outside of
26
+ # +epubdir+, through a symbolic link that already exists in it, or over an
27
+ # existing file. Pass <tt>overwrite: true</tt> to replace existing files.
28
+ def self.unzip(epubfile, epubdir = nil, overwrite: false)
29
+ Unpacker.new(epubfile, epubdir, overwrite: overwrite).unpack
30
+ end
31
+
32
+ class Packer # :nodoc:
33
+ # File::ALT_SEPARATOR is the backslash on Windows, and nil elsewhere.
34
+ TRAILING_SEPARATORS = /[#{Regexp.escape([File::SEPARATOR, File::ALT_SEPARATOR].join)}]+\z/
35
+
36
+ def initialize(epubdir, epubfile)
37
+ unless File.directory?(epubdir)
38
+ raise ArgumentError, "No such directory -- #{epubdir}"
39
+ end
40
+
41
+ @epubdir = epubdir
42
+ # "book/" must become "book.epub", not "book/.epub".
43
+ @epubfile = epubfile || epubdir.to_s.sub(TRAILING_SEPARATORS, "") + ".epub"
17
44
  end
18
45
 
19
- epubfile ||= epubdir+".epub"
20
-
21
- Dir.mktmpdir do |tmpdir|
22
- tmpfile = "#{tmpdir}/tmp.epub"
46
+ def pack
47
+ # List the files before creating the output, so that a rejected source
48
+ # directory does not leave a partial EPUB behind.
49
+ paths = source_paths
23
50
 
24
- Dir.chdir(epubdir) do
25
- File.open(MIMETYPE_FILENAME, "w") do |f|
26
- f.write("application/epub+zip")
51
+ Zip::OutputStream.open(@epubfile) do |zos|
52
+ # The mimetype entry must come first and be stored uncompressed.
53
+ zos.put_next_entry(mimetype_entry, nil, nil, Zip::Entry::STORED)
54
+ zos << MIMETYPE_CONTENT
55
+
56
+ paths.each do |path|
57
+ zos.put_next_entry(path)
58
+ zos << File.binread(File.join(@epubdir, path))
27
59
  end
28
- system("#{@@zip_cmd_path} -0X #{tmpfile} #{MIMETYPE_FILENAME}")
29
- system("#{@@zip_cmd_path} -Xr9D #{tmpfile} * -x #{MIMETYPE_FILENAME}")
30
60
  end
31
61
 
32
- FileUtils.cp(tmpfile, epubfile)
62
+ @epubfile
33
63
  end
34
- epubfile
35
- end
36
64
 
37
- def self.unzip(epubfile, epubdir = nil)
38
- if epubdir
39
- FileUtils.mkdir_p(epubdir)
40
- else
41
- epubdir = Dir.pwd
65
+ private
66
+
67
+ # Returns the files to pack, as paths relative to the source directory.
68
+ def source_paths
69
+ root = File.realpath(@epubdir)
70
+ # Only a root directory ends with a separator.
71
+ prefix = root.end_with?(File::SEPARATOR) ? root : root + File::SEPARATOR
72
+ # An EPUB left in the source directory by an earlier run is about to be
73
+ # replaced, so it cannot be packed into itself.
74
+ output = File.realpath(@epubfile) if File.exist?(@epubfile)
75
+
76
+ Dir.glob("**/*", base: @epubdir).select do |path|
77
+ next false if path == MIMETYPE_FILENAME
78
+
79
+ file = File.join(@epubdir, path)
80
+ # File.file? follows symbolic links, and so would reading the file.
81
+ next false unless File.file?(file)
82
+
83
+ realpath = File.realpath(file)
84
+ unless realpath.start_with?(prefix)
85
+ raise Error, "Symbolic link to outside of the source directory -- #{path}"
86
+ end
87
+
88
+ realpath != output
89
+ end
42
90
  end
43
91
 
44
- system("#{@@unzip_cmd_path} #{epubfile} -d #{epubdir}")
92
+ # EPUB (OCF) forbids an extra field on the mimetype entry. rubyzip 3.x adds
93
+ # a Zip64 placeholder to every streamed entry whose size is not yet known,
94
+ # so declare the size up front.
95
+ def mimetype_entry
96
+ entry = Zip::Entry.new(@epubfile, MIMETYPE_FILENAME)
97
+ entry.compression_method = Zip::Entry::STORED
98
+ entry.size = MIMETYPE_CONTENT.bytesize
99
+ entry
100
+ end
45
101
  end
102
+ private_constant :Packer
103
+
104
+ class Unpacker # :nodoc:
105
+ # Zip::Entry#extract takes the destination path in rubyzip 2.x, and an
106
+ # entry path relative to +destination_directory+ in rubyzip 3.x.
107
+ RUBYZIP_V3_EXTRACT = Zip::Entry.instance_method(:extract).parameters
108
+ .any? { |_, name| name == :destination_directory }
109
+
110
+ def initialize(epubfile, epubdir, overwrite:)
111
+ @epubfile = epubfile
112
+ @epubdir = epubdir || Dir.pwd
113
+ @root = File.expand_path(@epubdir)
114
+ # Only a root directory ends with a separator.
115
+ @prefix = @root.end_with?(File::SEPARATOR) ? @root : @root + File::SEPARATOR
116
+ @overwrite = overwrite
117
+ end
118
+
119
+ def unpack
120
+ Zip::File.open(@epubfile) do |zip|
121
+ check_root
122
+ # A directory entry usually ends with a separator, but may also be
123
+ # marked as a directory by its attributes alone.
124
+ files = zip.reject { |entry| entry.name_is_directory? || entry.directory? }
125
+ targets = files.map { |entry| [entry, target_path(entry)] }
126
+ check_conflicts(targets)
127
+
128
+ # Create the target only once the archive has been opened and checked,
129
+ # so that a rejected file does not leave an empty directory behind.
130
+ FileUtils.mkdir_p(@root)
131
+ targets.each do |entry, filepath|
132
+ FileUtils.mkdir_p(File.dirname(filepath))
133
+ extract(entry, filepath)
134
+ end
135
+ end
136
+
137
+ @epubdir
138
+ end
139
+
140
+ private
46
141
 
142
+ # Raises Epzip::Error if the target directory cannot be created or used,
143
+ # because something else (or a dangling symbolic link) has its name or
144
+ # the name of one of the directories leading to it.
145
+ def check_root
146
+ # The target directory itself, or the closest thing that exists above it.
147
+ path = @root
148
+ until File.exist?(path) || File.symlink?(path)
149
+ parent = File.dirname(path)
150
+ break if parent == path
151
+
152
+ path = parent
153
+ end
154
+ return if File.directory?(path)
155
+
156
+ raise Error, "Not a directory -- #{path}"
157
+ end
158
+
159
+ # Returns the path +entry+ is to be extracted to, or raises Epzip::Error if
160
+ # it must not be extracted.
161
+ def target_path(entry)
162
+ # rubyzip returns the name as a binary string, which cannot be joined to
163
+ # a target directory with non-ASCII characters in its path.
164
+ name = entry.name.dup.force_encoding(@root.encoding)
165
+ filepath = begin
166
+ File.expand_path(File.join(@root, name))
167
+ rescue ArgumentError # a null byte in the name
168
+ raise Error, "Illegal entry name -- #{entry.name.inspect}"
169
+ end
170
+ # Guard against Zip Slip: reject entries that would escape the target
171
+ # directory instead of relying on rubyzip, which either skips its own
172
+ # check (2.x, explicit destination path) or only warns (3.x).
173
+ unless filepath.start_with?(@prefix)
174
+ raise Error, "Illegal entry name -- #{entry.name}"
175
+ end
176
+
177
+ # The check above only looks at the path as a string. A symbolic link
178
+ # below the target directory could still lead the write elsewhere.
179
+ path = filepath
180
+ until path == @root
181
+ if File.symlink?(path)
182
+ raise Error, "Symbolic link in the target directory -- #{path}"
183
+ end
184
+ # A directory is needed here, and a file cannot be replaced by one.
185
+ if path != filepath && File.exist?(path) && !File.directory?(path)
186
+ raise Error, "Not a directory -- #{path}"
187
+ end
188
+
189
+ path = File.dirname(path)
190
+ end
191
+
192
+ # A directory cannot be replaced by a file, even when overwriting.
193
+ if File.directory?(filepath)
194
+ raise Error, "Directory already exists -- #{filepath}"
195
+ elsif File.exist?(filepath)
196
+ raise Error, "File already exists -- #{filepath}" unless @overwrite
197
+ # Writing to a named pipe or a device would not replace it.
198
+ raise Error, "Not a regular file -- #{filepath}" unless File.file?(filepath)
199
+ end
200
+
201
+ filepath
202
+ end
203
+
204
+ # Raises Epzip::Error if the entries cannot all be extracted: two of them
205
+ # go to the same path, or one is a file where another needs a directory.
206
+ # Such an archive would otherwise fail halfway through the extraction.
207
+ def check_conflicts(targets)
208
+ entries = {}
209
+ targets.each do |entry, filepath|
210
+ if entries.key?(filepath)
211
+ raise Error, "Duplicate entry -- #{entry.name}"
212
+ end
213
+
214
+ entries[filepath] = entry
215
+ end
216
+
217
+ targets.each do |_entry, filepath|
218
+ dir = File.dirname(filepath)
219
+ until dir == @root
220
+ if entries.key?(dir)
221
+ raise Error, "Entry is both a file and a directory -- #{entries[dir].name}"
222
+ end
223
+
224
+ dir = File.dirname(dir)
225
+ end
226
+ end
227
+ end
228
+
229
+ # The block tells rubyzip whether it may replace an existing file.
230
+ def extract(entry, filepath)
231
+ if RUBYZIP_V3_EXTRACT
232
+ # The checked path, relative to the target directory, and not the
233
+ # binary entry name: rubyzip joins it to the directory again.
234
+ relative = filepath.delete_prefix(@prefix)
235
+ entry.extract(relative, destination_directory: @root) { @overwrite }
236
+ else
237
+ entry.extract(filepath) { @overwrite }
238
+ end
239
+ end
240
+ end
241
+ private_constant :Unpacker
47
242
  end
metadata CHANGED
@@ -1,92 +1,69 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: epzip
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 8
8
- - 0
9
- version: 0.8.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.10.0
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Masayoshi Takahashi
13
- autorequire:
14
- bindir: bin
8
+ bindir: exe
15
9
  cert_chain: []
16
-
17
- date: 2010-10-06 00:00:00 +09:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
21
13
  name: rubyzip
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
26
16
  - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- - 9
31
- - 4
32
- version: 0.9.4
17
+ - !ruby/object:Gem::Version
18
+ version: '2.3'
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '4.0'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- description: epzip is EPUB packing tool. It's just only to do 'zip.'
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '2.3'
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '4.0'
32
+ description: epzip is an EPUB packing tool. It's just only to do 'zip.'
36
33
  email: takahashimm@gmail.com
37
- executables:
34
+ executables:
38
35
  - epunzip
39
36
  - epzip
40
37
  extensions: []
41
-
42
- extra_rdoc_files:
43
- - LICENSE
44
- - README.rdoc
45
- files:
46
- - .document
47
- - .gitignore
38
+ extra_rdoc_files: []
39
+ files:
40
+ - CHANGELOG.md
48
41
  - LICENSE
49
- - README.rdoc
50
- - Rakefile
51
- - VERSION
52
- - bin/epunzip
53
- - bin/epzip
54
- - epzip.gemspec
42
+ - README.md
43
+ - exe/epunzip
44
+ - exe/epzip
55
45
  - lib/epzip.rb
56
- - test/helper.rb
57
- - test/test_epzip.rb
58
- has_rdoc: true
59
- homepage: http://github.com/takahashim/epzip
60
- licenses: []
61
-
62
- post_install_message:
63
- rdoc_options:
64
- - --charset=UTF-8
65
- require_paths:
46
+ - lib/epzip/version.rb
47
+ homepage: https://github.com/takahashim/epzip
48
+ licenses:
49
+ - MIT
50
+ metadata:
51
+ changelog_uri: https://github.com/takahashim/epzip/blob/master/CHANGELOG.md
52
+ rdoc_options: []
53
+ require_paths:
66
54
  - lib
67
- required_ruby_version: !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
70
57
  - - ">="
71
- - !ruby/object:Gem::Version
72
- segments:
73
- - 0
74
- version: "0"
75
- required_rubygems_version: !ruby/object:Gem::Requirement
76
- none: false
77
- requirements:
58
+ - !ruby/object:Gem::Version
59
+ version: '3.0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
78
62
  - - ">="
79
- - !ruby/object:Gem::Version
80
- segments:
81
- - 0
82
- version: "0"
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
83
65
  requirements: []
84
-
85
- rubyforge_project:
86
- rubygems_version: 1.3.7
87
- signing_key:
88
- specification_version: 3
66
+ rubygems_version: 3.6.9
67
+ specification_version: 4
89
68
  summary: simple EPUB packing tool
90
- test_files:
91
- - test/helper.rb
92
- - test/test_epzip.rb
69
+ test_files: []
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
data/README.rdoc DELETED
@@ -1,36 +0,0 @@
1
- = epzip
2
-
3
- epzip(eunzip) is EPUB packing tool. It's just only doing 'zip' and 'unzip'. :)
4
-
5
- == usage
6
-
7
- $ epzip <srcdir> [filename]
8
-
9
- 'srcdir' is EPUB resource directory; it has mimetype, META-INF/container.xml,
10
- and other assets.
11
-
12
- 'filename' is EPUB filename that will be created. If no filename,
13
- dir + ".epub" is used.
14
-
15
- $ epunzip <filename> [targetdir]
16
-
17
- 'filename' is EPUB filename that will be extracted.
18
-
19
- 'targetdir' is EPUB resource directory to be extracted into. If no targetdir,
20
- current directory is used.
21
-
22
-
23
-
24
- == Note on Patches/Pull Requests
25
-
26
- * Fork the project.
27
- * Make your feature addition or bug fix.
28
- * Add tests for it. This is important so I don't break it in a
29
- future version unintentionally.
30
- * Commit, do not mess with rakefile, version, or history.
31
- (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)
32
- * Send me a pull request. Bonus points for topic branches.
33
-
34
- == Copyright
35
-
36
- Copyright (c) 2010 Masayoshi Takahashi. See LICENSE for details.
data/Rakefile DELETED
@@ -1,55 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "epzip"
8
- gem.summary = %Q{simple EPUB packing tool}
9
- gem.description = %Q{epzip is EPUB packing tool. It's just only to do 'zip.'}
10
- gem.email = "takahashimm@gmail.com"
11
- gem.homepage = "http://github.com/takahashim/epzip"
12
- gem.authors = ["Masayoshi Takahashi"]
13
-
14
- gem.add_dependency('rubyzip', '>= 0.9.4')
15
-
16
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
- end
18
- Jeweler::GemcutterTasks.new
19
- rescue LoadError
20
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
- end
22
-
23
- require 'rake/testtask'
24
- Rake::TestTask.new(:test) do |test|
25
- test.libs << 'lib' << 'test'
26
- test.pattern = 'test/**/test_*.rb'
27
- test.verbose = true
28
- end
29
-
30
- begin
31
- require 'rcov/rcovtask'
32
- Rcov::RcovTask.new do |test|
33
- test.libs << 'test'
34
- test.pattern = 'test/**/test_*.rb'
35
- test.verbose = true
36
- end
37
- rescue LoadError
38
- task :rcov do
39
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
40
- end
41
- end
42
-
43
- task :test => :check_dependencies
44
-
45
- task :default => :test
46
-
47
- require 'rake/rdoctask'
48
- Rake::RDocTask.new do |rdoc|
49
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
50
-
51
- rdoc.rdoc_dir = 'rdoc'
52
- rdoc.title = "epzip #{version}"
53
- rdoc.rdoc_files.include('README*')
54
- rdoc.rdoc_files.include('lib/**/*.rb')
55
- end
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.8.0
data/bin/epunzip DELETED
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require 'rubygems'
5
- require 'epzip'
6
-
7
- def error_and_exit(msg)
8
- STDERR.puts msg
9
- exit
10
- end
11
-
12
- def usage()
13
- error_and_exit "usage: epunzip <filename> [targetdir]"
14
- end
15
-
16
- if !(ARGV.size == 1 or ARGV.size == 2)
17
- usage
18
- end
19
-
20
- file = ARGV.shift
21
- if !File.exists? file
22
- error_and_exit "No such file: #{file}"
23
- end
24
-
25
- dir = ARGV.shift
26
- if dir and File.exists? dir
27
- error_and_exit "Directory already exists: #{dir}"
28
- end
29
-
30
- Epzip.unzip(file, dir)
data/bin/epzip DELETED
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require 'rubygems'
5
- require 'epzip'
6
-
7
- def error_and_exit(msg)
8
- STDERR.puts msg
9
- exit
10
- end
11
-
12
- def usage()
13
- error_and_exit "usage: epzip <srcdir> [filename]"
14
- end
15
-
16
- if !(ARGV.size == 1 or ARGV.size == 2)
17
- usage
18
- end
19
-
20
- dir = ARGV.shift
21
- if !File.exists? dir
22
- error_and_exit "No such directory: #{dir}"
23
- end
24
-
25
- file = ARGV.shift
26
- if file and File.exists? file
27
- error_and_exit "File already exists: #{file}"
28
- end
29
-
30
- Epzip.zip(dir, file)
data/epzip.gemspec DELETED
@@ -1,57 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{epzip}
8
- s.version = "0.8.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Masayoshi Takahashi"]
12
- s.date = %q{2010-10-06}
13
- s.description = %q{epzip is EPUB packing tool. It's just only to do 'zip.'}
14
- s.email = %q{takahashimm@gmail.com}
15
- s.executables = ["epunzip", "epzip"]
16
- s.extra_rdoc_files = [
17
- "LICENSE",
18
- "README.rdoc"
19
- ]
20
- s.files = [
21
- ".document",
22
- ".gitignore",
23
- "LICENSE",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "bin/epunzip",
28
- "bin/epzip",
29
- "epzip.gemspec",
30
- "lib/epzip.rb",
31
- "test/helper.rb",
32
- "test/test_epzip.rb"
33
- ]
34
- s.homepage = %q{http://github.com/takahashim/epzip}
35
- s.rdoc_options = ["--charset=UTF-8"]
36
- s.require_paths = ["lib"]
37
- s.rubygems_version = %q{1.3.7}
38
- s.summary = %q{simple EPUB packing tool}
39
- s.test_files = [
40
- "test/helper.rb",
41
- "test/test_epzip.rb"
42
- ]
43
-
44
- if s.respond_to? :specification_version then
45
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
- s.specification_version = 3
47
-
48
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
- s.add_runtime_dependency(%q<rubyzip>, [">= 0.9.4"])
50
- else
51
- s.add_dependency(%q<rubyzip>, [">= 0.9.4"])
52
- end
53
- else
54
- s.add_dependency(%q<rubyzip>, [">= 0.9.4"])
55
- end
56
- end
57
-
data/test/helper.rb DELETED
@@ -1,9 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
-
4
- $LOAD_PATH.unshift(File.dirname(__FILE__))
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- require 'epzip'
7
-
8
- class Test::Unit::TestCase
9
- end
data/test/test_epzip.rb DELETED
@@ -1,9 +0,0 @@
1
- require 'helper'
2
-
3
- class TestEpzip < Test::Unit::TestCase
4
- def test_zip_should_use_existed_dir
5
- assert_raise ArgumentError do
6
- Epzip.zip("unknown_dir")
7
- end
8
- end
9
- end