epub-parser 0.1.7.1 → 0.1.8

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: c1bc11e4506d0cb6d2631a97f894db7fd23d0bc6
4
- data.tar.gz: bb2243cee7a0113ff16ea513059505471aa2dfad
3
+ metadata.gz: 0e0b5095d398c04f70b55444777389325b51b34a
4
+ data.tar.gz: f34bca3b4e1f8840b4caa58b11ffc00b95855794
5
5
  SHA512:
6
- metadata.gz: ae1dab828812a9f9491af50b3f7c861082f7d4521b5f1a4ae7f4e224e2d6e33abeb574bb00bf989336be0e92b4cedc264aebf2a9cda786f6b978fdeda847c4f4
7
- data.tar.gz: 3b64876d7a077daf087d46799a30daa4e58acb6837d04474e713bc4e4e9bf083353c65638c25254cc3aebb8b9fdcc5e318cebd614e0eb29b2504b6c5da58b7c1
6
+ metadata.gz: bd4a31dca34f82fbc9eca34f53b3b5806c99cb91257c7efe97b1f1eca35edcf9beda7a38ee62eb3a43953587beab6283353fb94e9add1858acdb599750c32ee3
7
+ data.tar.gz: 719e99aad4b05a6f784e9c69f438f98319be7c330f70fb79531e41d1ec9b027893de4d01875f0ee3cca23a443606f744c6699c7e635159145bfeeeed07fd41f3
@@ -1,6 +1,13 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
+ 0.1.8
5
+ -----
6
+
7
+ * Explicity #close each zip member file that has been opened via #fopen(Thanks, [xunker][]!)
8
+
9
+ [xunker]: https://github.com/xunker
10
+
4
11
  0.1.7.1
5
12
  -------
6
13
 
@@ -110,6 +110,12 @@ If you find other gems, please tell me or request a pull request.
110
110
  RECENT CHANGES
111
111
  --------------
112
112
 
113
+ ### 0.1.8
114
+
115
+ * Explicity #close each zip member file that has been opened via #fopen(Thanks [xunker][]!)
116
+
117
+ [xunker]: https://github.com/xunker
118
+
113
119
  ### 0.1.7.1
114
120
 
115
121
  * Don't set encoding when content is not text
@@ -44,7 +44,7 @@ This book object can yield page by spine's order(spine defines the order to read
44
44
  book.each_page_on_spine do |page|
45
45
  file = page.href # => path/to/page/in/zip/archive
46
46
  html = Zip::Archive.open('/path/to/book.epub') {|zip|
47
- zip.fopen(file.to_s).read
47
+ zip.fopen(file.to_s) {|file| file.read}
48
48
  }
49
49
  end
50
50
 
@@ -25,8 +25,8 @@ module EPUB
25
25
  def parse
26
26
  EPUB::OCF::MODULES.each do |m|
27
27
  begin
28
- file = @zip.fopen(File.join(DIRECTORY, "#{m}.xml"))
29
- @ocf.__send__ "#{m}=", __send__("parse_#{m}", file.read)
28
+ data = @zip.fopen(File.join(DIRECTORY, "#{m}.xml")) {|file| file.read}
29
+ @ocf.__send__ "#{m}=", __send__("parse_#{m}", data)
30
30
  rescue Zip::Error
31
31
  end
32
32
  end
@@ -12,7 +12,8 @@ module EPUB
12
12
 
13
13
  class << self
14
14
  def parse(zip_archive, file)
15
- opf = zip_archive.fopen(Addressable::URI.unencode(file)).read
15
+ opf = zip_archive.fopen(Addressable::URI.unencode(file)) {|member| member.read}
16
+
16
17
  new(opf, file).parse
17
18
  end
18
19
  end
@@ -1,5 +1,5 @@
1
1
  module EPUB
2
2
  class Parser
3
- VERSION = "0.1.7.1"
3
+ VERSION = "0.1.8"
4
4
  end
5
5
  end
@@ -93,8 +93,9 @@ module EPUB
93
93
 
94
94
  def read
95
95
  raw_content = Zip::Archive.open(manifest.package.book.epub_file) {|zip|
96
- zip.fopen(entry_name).read
96
+ zip.fopen(entry_name) {|member| member.read}
97
97
  }
98
+
98
99
  unless media_type.start_with?('text/') or
99
100
  media_type.end_with?('xml') or
100
101
  ['application/json', 'application/javascript', 'application/ecmascript', 'application/xml-dtd'].include?(media_type)
@@ -27,7 +27,7 @@ class TestSearcher < Test::Unit::TestCase
27
27
  [[[:element, 2, {:name => 'spine', :id => nil}], [:itemref, 0, {:id => nil}], [:element, 1, {:name => 'body', :id => nil}], [:element, 0, {:name => 'div', :id => nil}], [:element, 0, {:name => 'nav', :id => 'idid'}], [:element, 0, {:name => 'hgroup', :id => nil}], [:element, 1, {:name => 'h1', :id => nil}], [:text, 0]], [[:character, 9]], [[:character, 16]]]
28
28
  ]),
29
29
  EPUB::Searcher::Publication.search(@package, 'Content')
30
- )
30
+ )
31
31
  end
32
32
 
33
33
  class TesetResult < self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epub-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7.1
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - KITAITI Makoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-20 00:00:00.000000000 Z
11
+ date: 2014-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake