epub-maker 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +7 -0
- data/README.markdown +5 -0
- data/Rakefile +2 -1
- data/epub-maker.gemspec +2 -1
- data/lib/epub/maker.rb +7 -2
- data/lib/epub/maker/ocf.rb +1 -1
- data/lib/epub/maker/ocf/physical_container.rb +7 -2
- data/lib/epub/maker/ocf/physical_container/archive_zip.rb +27 -4
- data/lib/epub/maker/ocf/physical_container/zipruby.rb +1 -1
- data/lib/epub/maker/publication.rb +2 -2
- data/lib/epub/maker/task.rb +3 -1
- data/lib/epub/maker/version.rb +1 -1
- data/test/test_maker_publication.rb +1 -1
- metadata +18 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6317049b8e2e449885ad8eb99584c4d50b926250
|
4
|
+
data.tar.gz: c5418890d270746471835b7bba2a83fc1ece45a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c897619e13826f2f3eab0d170bb499f3a55005b519f7892dba768825ea2bf62e9ffdd0340726ea033d7498ff88fea109f1517b4ea2e7c41008b3641aca578116
|
7
|
+
data.tar.gz: 80b88d8cbdf531bee5c5d8ce1f5352c85a69d449076711dea1882d3a4070073f1a5698e4a1d7d099f45dc184cc7fd3d5f347d7fdbd12ae35bf1d8857cbbd53d3
|
data/CHANGELOG.markdown
CHANGED
data/README.markdown
CHANGED
@@ -145,6 +145,11 @@ Todo
|
|
145
145
|
|
146
146
|
Recent Changes
|
147
147
|
--------------
|
148
|
+
### 0.0.4
|
149
|
+
* API change: #save -> #write for PhysicalContainer classes
|
150
|
+
* Bump required EPUB Parser version: 0.2.0 -> 0.2.6
|
151
|
+
* Deprecate `EPUB::OCF::PhysicalContainer.save`
|
152
|
+
|
148
153
|
### 0.0.3
|
149
154
|
* Bump up required Ruby version: >= 2.0.0 -> >= 2.1.0
|
150
155
|
|
data/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rake/testtask'
|
2
2
|
require 'rake/clean'
|
3
3
|
require 'yard'
|
4
|
-
require "
|
4
|
+
require "rubygems/tasks"
|
5
5
|
|
6
6
|
task :default => :test
|
7
7
|
|
@@ -9,3 +9,4 @@ CLEAN.include 'README.html'
|
|
9
9
|
|
10
10
|
Rake::TestTask.new
|
11
11
|
YARD::Rake::YardocTask.new
|
12
|
+
Gem::Tasks.new
|
data/epub-maker.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.require_paths = ["lib"]
|
21
21
|
gem.required_ruby_version = '>= 2.1.0'
|
22
22
|
|
23
|
-
gem.add_runtime_dependency 'epub-parser', '>= 0.2.
|
23
|
+
gem.add_runtime_dependency 'epub-parser', '>= 0.2.6'
|
24
24
|
gem.add_runtime_dependency 'pathname-common_prefix'
|
25
25
|
gem.add_runtime_dependency 'mimemagic'
|
26
26
|
gem.add_runtime_dependency 'ruby-uuid'
|
@@ -37,4 +37,5 @@ Gem::Specification.new do |gem|
|
|
37
37
|
gem.add_development_dependency 'pry'
|
38
38
|
gem.add_development_dependency 'pry-doc'
|
39
39
|
gem.add_development_dependency 'yard'
|
40
|
+
gem.add_development_dependency 'rubygems-tasks'
|
40
41
|
end
|
data/lib/epub/maker.rb
CHANGED
@@ -56,7 +56,9 @@ module EPUB
|
|
56
56
|
error.message,
|
57
57
|
"[#{self}]Working directory remained at: #{dir}"
|
58
58
|
].join($RS))
|
59
|
-
backtrace.unshift("#{__FILE__}:#{__LINE__}:in `rescue in #{__method__}'")
|
59
|
+
backtrace.unshift("#{__FILE__}:#{__LINE__}:in `rescue in #{__method__}'")
|
60
|
+
error.set_backtrace backtrace
|
61
|
+
raise error
|
60
62
|
end
|
61
63
|
end
|
62
64
|
end
|
@@ -71,10 +73,13 @@ module EPUB
|
|
71
73
|
end
|
72
74
|
|
73
75
|
def make_package
|
74
|
-
|
76
|
+
package = Publication::Package.new
|
77
|
+
package.book = self
|
75
78
|
package.make do |package|
|
76
79
|
yield package if block_given?
|
77
80
|
end
|
81
|
+
no_package_rootfile = rootfiles.find {|rf| rf.package.nil?}
|
82
|
+
no_package_rootfile.package = package if no_package_rootfile
|
78
83
|
package
|
79
84
|
end
|
80
85
|
|
data/lib/epub/maker/ocf.rb
CHANGED
@@ -12,7 +12,7 @@ module EPUB
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def save
|
15
|
-
book.container_adapter.
|
15
|
+
book.container_adapter.write book.epub_file, File.join(DIRECTORY, Container::FILE), self.container.to_xml if self.container
|
16
16
|
end
|
17
17
|
|
18
18
|
# @overload make_container
|
@@ -13,11 +13,16 @@ module EPUB
|
|
13
13
|
class OCF
|
14
14
|
class PhysicalContainer
|
15
15
|
class << self
|
16
|
-
def
|
16
|
+
def write(container_path, path_name, content)
|
17
17
|
open(container_path) {|container|
|
18
|
-
container.
|
18
|
+
container.write(path_name, content)
|
19
19
|
}
|
20
20
|
end
|
21
|
+
|
22
|
+
def save(container_path, path_name, content)
|
23
|
+
warn "EPUB::OCF::PhysicalContainer.#{__method__} is deprecated. Use .write instead"
|
24
|
+
write(container_path, path_name, content)
|
25
|
+
end
|
21
26
|
end
|
22
27
|
end
|
23
28
|
end
|
@@ -4,11 +4,34 @@ module EPUB
|
|
4
4
|
class OCF
|
5
5
|
class PhysicalContainer
|
6
6
|
class ArchiveZip < self
|
7
|
-
|
7
|
+
# @todo Write multiple files at once
|
8
|
+
def write(path_name, content)
|
8
9
|
::Dir.mktmpdir do |dir|
|
9
|
-
|
10
|
-
::File.
|
11
|
-
|
10
|
+
tmp_archive_path = ::File.join(dir, ::File.basename(@container_path) + '.tmp')
|
11
|
+
::File.open @container_path do |archive_in|
|
12
|
+
::File.open tmp_archive_path, 'w' do |archive_out|
|
13
|
+
archive_out.binmode
|
14
|
+
Archive::Zip.open archive_in, :r do |z_in|
|
15
|
+
Archive::Zip.open archive_out, :w do |z_out|
|
16
|
+
updated = false
|
17
|
+
z_in.each do |entry|
|
18
|
+
if entry.zip_path == path_name
|
19
|
+
entry.file_data = StringIO.new(content)
|
20
|
+
updated = true
|
21
|
+
end
|
22
|
+
z_out << entry
|
23
|
+
end
|
24
|
+
unless updated
|
25
|
+
entry = Archive::Zip::Entry::File.new(path_name)
|
26
|
+
entry.file_data = StringIO.new(content)
|
27
|
+
z_out << entry
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
::File.chmod 0666 & ~::File.umask, tmp_archive_path
|
34
|
+
::File.rename tmp_archive_path, @container_path
|
12
35
|
end
|
13
36
|
end
|
14
37
|
end
|
@@ -78,7 +78,7 @@ module EPUB
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def save
|
81
|
-
book.container_adapter.
|
81
|
+
book.container_adapter.write book.epub_file, book.rootfile_path, to_xml
|
82
82
|
end
|
83
83
|
|
84
84
|
module ContentModel
|
@@ -261,7 +261,7 @@ module EPUB
|
|
261
261
|
raise 'no content nor content_file'
|
262
262
|
end
|
263
263
|
book = manifest.package.book
|
264
|
-
book.container_adapter.
|
264
|
+
book.container_adapter.write book.epub_file, entry_name, content_to_save
|
265
265
|
end
|
266
266
|
|
267
267
|
# Save document into EPUB archive when block ended
|
data/lib/epub/maker/task.rb
CHANGED
@@ -59,6 +59,8 @@ module EPUB
|
|
59
59
|
|
60
60
|
if make_rootfiles
|
61
61
|
book.make_package do |package|
|
62
|
+
book.ocf.container.rootfile.package = package
|
63
|
+
|
62
64
|
package.dir = package_direction
|
63
65
|
|
64
66
|
package.make_metadata do |metadata|
|
@@ -109,7 +111,7 @@ module EPUB
|
|
109
111
|
else
|
110
112
|
raise 'No rootfile set' if @rootfiles.empty?
|
111
113
|
rf = rootfiles.first
|
112
|
-
book.package = EPUB::Parser::Publication.new(File.read(rf)
|
114
|
+
book.package = EPUB::Parser::Publication.new(File.read(rf)).parse
|
113
115
|
end
|
114
116
|
end
|
115
117
|
end
|
data/lib/epub/maker/version.rb
CHANGED
@@ -7,7 +7,7 @@ class TestMakerPublication < Test::Unit::TestCase
|
|
7
7
|
def setup
|
8
8
|
rootfile = 'OPS/ルートファイル.opf'
|
9
9
|
@opf = File.read(File.expand_path("../fixtures/book/#{rootfile}", __FILE__))
|
10
|
-
@package = EPUB::Parser::Publication.new(@opf
|
10
|
+
@package = EPUB::Parser::Publication.new(@opf).parse
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_to_xml_attribute
|
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.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KITAITI Makoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: epub-parser
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.2.
|
19
|
+
version: 0.2.6
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.2.
|
26
|
+
version: 0.2.6
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pathname-common_prefix
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -234,6 +234,20 @@ dependencies:
|
|
234
234
|
- - ">="
|
235
235
|
- !ruby/object:Gem::Version
|
236
236
|
version: '0'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: rubygems-tasks
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - ">="
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '0'
|
244
|
+
type: :development
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - ">="
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0'
|
237
251
|
description: This library supports making and editing EPUB books
|
238
252
|
email:
|
239
253
|
- KitaitiMakoto@gmail.com
|
@@ -317,4 +331,3 @@ test_files:
|
|
317
331
|
- test/test_maker_ocf.rb
|
318
332
|
- test/test_maker_publication.rb
|
319
333
|
- test/test_task.rb
|
320
|
-
has_rdoc:
|