epub-maker 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c40def444773cc73f4a412792312c708d34fc45
4
- data.tar.gz: 2a731fbf57f36c9c978707b49d8c060d4086f80b
3
+ metadata.gz: dd80bab3836300bb946438407d0cd8c931557277
4
+ data.tar.gz: 7430a5c2e9680f0f93a9c7e2f7f1fb7339bef339
5
5
  SHA512:
6
- metadata.gz: 715949ee62b509a9eade435df0d6823d85892ee1ad7f99ff949089abb02386d62cbfcd4a549a4c4e0b615ed1f59681cdcdc6e8794bdf0c8eacb52f3076940948
7
- data.tar.gz: e7825b5df371b8bf4da010fa72e8099491fe25f2cfe50f291b36acd8a8087fd80e1d56c33531d8a4b9709faec721fadc3d514508274c831e8a61e17b1b08fb26
6
+ metadata.gz: b6a2af0f44dcfa9ee4f934ddb4b7a32b99c06aafe9a812e72409e447292325811d2d5e123a13b92006bc588454e886d33575fa047a25763f08e338ce9a6a2f02
7
+ data.tar.gz: 8ab6ec574eec7d760130e67285bd0264656b36e979dd00ecffac80cbd1d6105c48bb42d1221357c49caee524d14dcead69babba27f0ce42d1413852758cf72bf
@@ -0,0 +1,22 @@
1
+ before_script:
2
+ - ruby -v
3
+ - which ruby
4
+ - gem install bundler --no-document
5
+ - bundle install --jobs=$(nproc) --path=deps
6
+
7
+ cache:
8
+ paths:
9
+ - deps/
10
+
11
+ test:2.2:
12
+ image: ruby:2.2
13
+ script:
14
+ - bundle exec rake test
15
+
16
+ test:2.3:
17
+ image: ruby:2.3
18
+ script: bundle exec rake test
19
+
20
+ test:2.4:
21
+ image: ruby:2.4
22
+ script: bundle exec rake test
@@ -1,3 +1,9 @@
1
+ 0.0.6
2
+ -----
3
+
4
+ * Add `epub-archive` command
5
+ * Add `EPUB::Maker.archive` method
6
+
1
7
  0.0.5
2
8
  -----
3
9
 
data/Gemfile CHANGED
@@ -7,3 +7,7 @@ if ENV['EDGE_PARSER'] == '1'
7
7
  end
8
8
 
9
9
  gemspec
10
+
11
+ if RUBY_PLATFORM.match /darwin/
12
+ gem 'terminal-notifier'
13
+ end
@@ -131,9 +131,30 @@ For APIs of parsed EPUB book, see [EPUB Parser's documentation][epub-parser-doc]
131
131
  task.bindings = {'application/x-demo-slideshow' => "#{DIR}/OPS/impl.xhtml"}
132
132
  end
133
133
 
134
+ ### epub-archive command
135
+
136
+ `epub-archive` command archives given directory as an EPUB file like [epzip][] gem but doesn't require zip command.
137
+
138
+ % ls path/to
139
+ book
140
+ % epub-archie path/to/book
141
+ % ls path/to
142
+ book
143
+ book.epub
144
+
145
+ You can specify target file path.
146
+
147
+ % epub-archive source/dir/book target/dir/book.epub
148
+ % ls source/dir
149
+ book
150
+ % ls target/dir
151
+ book.epub
152
+
153
+ [epzip]: https://github.com/takahashim/epzip
154
+
134
155
  Requirements
135
156
  ------------
136
- * Ruby 2.1 or later
157
+ * Ruby 2.2 or later
137
158
  * C compiler to build Nokogiri gems
138
159
 
139
160
  Todo
@@ -145,6 +166,11 @@ Todo
145
166
 
146
167
  Recent Changes
147
168
  --------------
169
+ ### 0.0.6
170
+
171
+ * Add `epub-archive` command
172
+ * Add `EPUB::Maker.archive` method
173
+
148
174
  ### 0.0.5
149
175
 
150
176
  * Fix bug to modify `dc:rights` to `dc:right`
@@ -0,0 +1,14 @@
1
+ require "English"
2
+ require "epub/maker"
3
+
4
+ def main(argv)
5
+ source_dir = argv.shift
6
+ raise "source directory not specified" unless source_dir
7
+
8
+ EPUB::Maker.archive(source_dir, argv.shift)
9
+ rescue => error
10
+ $stderr.puts error
11
+ abort "Usage: #{$PROGRAM_NAME} SOURCE_DIR [EPUB_FILE]"
12
+ end
13
+
14
+ main(ARGV)
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.email = ["KitaitiMakoto@gmail.com"]
11
11
  gem.description = %q{This library supports making and editing EPUB books}
12
12
  gem.summary = %q{EPUB Maker}
13
- gem.homepage = ""
13
+ gem.homepage = "http://www.rubydoc.info/gems/epub-maker"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
16
16
  gem.files.delete '"test/fixtures/book/OPS/\343\203\253\343\203\274\343\203\210\343\203\225\343\202\241\343\202\244\343\203\253.opf"'
@@ -21,7 +21,6 @@ Gem::Specification.new do |gem|
21
21
  gem.required_ruby_version = '>= 2.1.0'
22
22
 
23
23
  gem.add_runtime_dependency 'epub-parser', '>= 0.2.6'
24
- gem.add_runtime_dependency 'pathname-common_prefix'
25
24
  gem.add_runtime_dependency 'mimemagic'
26
25
  gem.add_runtime_dependency 'ruby-uuid'
27
26
  gem.add_runtime_dependency 'archive-zip'
@@ -31,8 +30,7 @@ Gem::Specification.new do |gem|
31
30
  gem.add_development_dependency 'zipruby'
32
31
  gem.add_development_dependency 'test-unit'
33
32
  gem.add_development_dependency 'test-unit-notify'
34
- gem.add_development_dependency 'epubcheck'
35
- gem.add_development_dependency 'epzip'
33
+ gem.add_development_dependency 'epubcheck-ruby'
36
34
  gem.add_development_dependency 'simplecov'
37
35
  gem.add_development_dependency 'pry'
38
36
  gem.add_development_dependency 'pry-doc'
@@ -1,6 +1,5 @@
1
1
  require 'English'
2
2
  require 'pathname'
3
- require 'pathname/common_prefix'
4
3
  require 'fileutils'
5
4
  require 'tmpdir'
6
5
  require 'time'
@@ -60,6 +59,46 @@ module EPUB
60
59
  error.set_backtrace backtrace
61
60
  raise error
62
61
  end
62
+
63
+ # Substance of +epub-archive+ command
64
+ # @param source_file [Pathname, String]
65
+ # @param epub_file [Pathname, String, nil]
66
+ # @return [Pathname] Path to generated EPUB file
67
+ # @raise [RuntimeError] if directory +source_dir+ doesn't exist
68
+ # @raise [Archive::Zip::Error] if something goes wrong around ZIP archive manipulation
69
+ # @todo Accept usage that +epub-archive path/to/boo .+ generates ./book.epub
70
+ # @todo Abstract ZIP library
71
+ # @todo Accept compression method option
72
+ # @todo Accept compression level option
73
+ def archive(source_dir, epub_file = nil)
74
+ source_dir = Pathname(source_dir)
75
+ raise "source directory #{source_dir} not exist" unless source_dir.exist?
76
+
77
+ epub_file ||= source_dir.sub_ext(".epub")
78
+ epub_file = Pathname(epub_file)
79
+
80
+ Pathname.mktmpdir do |dir|
81
+ temp_dest = dir/epub_file.basename
82
+ temp_container = dir/source_dir.basename
83
+
84
+ temp_container.mkdir
85
+ mimetype = temp_container/"mimetype"
86
+ mimetype.write EPUB::MediaType::EPUB
87
+ Archive::Zip.open temp_dest.to_path, :w do |archive|
88
+ file = Archive::Zip::Entry.from_file(mimetype.to_path, compression_codec: Archive::Zip::Codec::Store)
89
+ archive.add_entry file
90
+ end
91
+ mimetype.delete
92
+ temp_container.delete
93
+
94
+ FileUtils.cp_r source_dir, temp_container
95
+ mimetype.delete if mimetype.exist?
96
+ Archive::Zip.archive temp_dest.to_path, temp_container.to_path + "/.", directories: false
97
+ temp_dest.rename epub_file
98
+ end
99
+
100
+ epub_file
101
+ end
63
102
  end
64
103
  end
65
104
 
@@ -1,5 +1,5 @@
1
1
  module EPUB
2
2
  module Maker
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
@@ -8,11 +8,17 @@ require 'test/unit/notify'
8
8
  require 'open3'
9
9
  require 'shellwords'
10
10
  require 'pry'
11
+ require 'epubcheck/ruby/cli'
11
12
  class Test::Unit::TestCase
12
13
  def assert_valid_epub(file)
13
- jar = File.join(ENV['GEM_HOME'], 'gems', 'epubcheck-3.0.0', 'lib', 'epubcheck-3.0', 'epubcheck-3.0.jar')
14
- stderr, status = Open3.capture2e "java -jar #{jar.shellescape} #{file.shellescape}"
15
- assert_true (status.exitstatus == 0 or stderr !~ /^ERROR: /), stderr
14
+ if ENV["GITLAB_CI"]
15
+ warn "Validating EPUB file loosly by EPUB::Parser.parse instead of EpubCheck"
16
+ assert_nothing_raised do
17
+ EPUB::Parser.parse file
18
+ end
19
+ else
20
+ assert_true Epubcheck::Ruby::CLI.new.execute(file)
21
+ end
16
22
  end
17
23
  end
18
24
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
@@ -1,18 +1,16 @@
1
1
  require_relative 'helper'
2
2
  require 'epub/maker'
3
- require 'epzip'
4
3
 
5
4
  class TestImplaceEditing < Test::Unit::TestCase
6
5
  def setup
7
6
  @assets_dir = Pathname(__dir__)/'fixtures'/'book'
8
7
  @dir = Pathname.mktmpdir('epub-maker-test')
9
8
  @file = @dir/'book.epub'
10
- Epzip.zip @assets_dir.to_s, @file.to_path
9
+ EPUB::Maker.archive @assets_dir, @file
11
10
  @book = EPUB::Parser.parse(@file)
12
11
  end
13
12
 
14
13
  def teardown
15
- (@assets_dir/'mimetype').rmtree
16
14
  @dir.remove_entry_secure if @dir.exist?
17
15
  end
18
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epub-maker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - KITAITI Makoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-06 00:00:00.000000000 Z
11
+ date: 2017-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: epub-parser
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.2.6
27
- - !ruby/object:Gem::Dependency
28
- name: pathname-common_prefix
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: mimemagic
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -151,21 +137,7 @@ dependencies:
151
137
  - !ruby/object:Gem::Version
152
138
  version: '0'
153
139
  - !ruby/object:Gem::Dependency
154
- name: epubcheck
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
- - !ruby/object:Gem::Dependency
168
- name: epzip
140
+ name: epubcheck-ruby
169
141
  requirement: !ruby/object:Gem::Requirement
170
142
  requirements:
171
143
  - - ">="
@@ -251,16 +223,19 @@ dependencies:
251
223
  description: This library supports making and editing EPUB books
252
224
  email:
253
225
  - KitaitiMakoto@gmail.com
254
- executables: []
226
+ executables:
227
+ - epub-archive
255
228
  extensions: []
256
229
  extra_rdoc_files: []
257
230
  files:
258
231
  - ".gitignore"
232
+ - ".gitlab-ci.yml"
259
233
  - CHANGELOG.markdown
260
234
  - Gemfile
261
235
  - LICENSE.txt
262
236
  - README.markdown
263
237
  - Rakefile
238
+ - bin/epub-archive
264
239
  - epub-maker.gemspec
265
240
  - lib/epub/maker.rb
266
241
  - lib/epub/maker/content_document.rb
@@ -289,7 +264,7 @@ files:
289
264
  - test/test_maker_ocf.rb
290
265
  - test/test_maker_publication.rb
291
266
  - test/test_task.rb
292
- homepage: ''
267
+ homepage: http://www.rubydoc.info/gems/epub-maker
293
268
  licenses: []
294
269
  metadata: {}
295
270
  post_install_message:
@@ -308,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
308
283
  version: '0'
309
284
  requirements: []
310
285
  rubyforge_project:
311
- rubygems_version: 2.6.8
286
+ rubygems_version: 2.6.13
312
287
  signing_key:
313
288
  specification_version: 4
314
289
  summary: EPUB Maker