epub-parser 0.4.0 → 0.4.1

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
  SHA256:
3
- metadata.gz: b8eeea7d5a67b4f9aaa7c71088837f4bb7156090c48e5411628e960de7b24233
4
- data.tar.gz: b4d0b181946da274c66927caea49cf59c62d5507cd9543dde59bf1d3deae43d8
3
+ metadata.gz: db9d1db7323d581efa9dd08265ed17adc0aff3c176ef87c783968c99dc8b14b2
4
+ data.tar.gz: c8eed1c594124b4bf9ba8bed18562840a9199c4e8dcac234e0cbc615601c16a5
5
5
  SHA512:
6
- metadata.gz: 3f9441b1dd0b6c4ac0d8acf04ff35fcdd0df4d3e880bb8a496e4a2e5127d99dc2ffc98927dd9d9907327cef08b7e8b76280f324cc1543ca38b7c80fe824fd8f1
7
- data.tar.gz: 158ac997006c5ee7967132c294d6f4183dbb4dc29927653dca49e05399c63793929910beb9cd2673d8a9ea5b5175adff5f45bc712097e8b5055cb1e69df9565e
6
+ metadata.gz: cb742185c933cfdbee595d9d777cef56a928933838e66d68383a1cdddb330b28ce514808ef292d1d90d5885957ff0cd2e8bd7905d0319b9e8f4548bb4c23fe17
7
+ data.tar.gz: 4fc71e9d5a20a1a8e1c610c8c0dd389639f4fe9ad01212944f5a11ab1e29be980bb296049d3f99228db9e595183911e13cb22c6a30e6437d5aca8f6ad71621cd
@@ -7,7 +7,7 @@ before_script:
7
7
 
8
8
  test:2.3:
9
9
  image: ruby:2.3
10
- script: bundle exec rake test
10
+ script: bundle exec rake test XML_BACKEND=REXML 2>/dev/null && bundle exec rake test XML_BACKEND=Oga 2>/dev/null && bundle exec rake test XML_BACKEND=Nokogiri
11
11
  except:
12
12
  - tags
13
13
  cache:
@@ -17,7 +17,7 @@ test:2.3:
17
17
 
18
18
  test:2.4:
19
19
  image: ruby:2.4
20
- script: bundle exec rake test
20
+ script: bundle exec rake test XML_BACKEND=REXML 2>/dev/null && bundle exec rake test XML_BACKEND=Oga 2>/dev/null && bundle exec rake test XML_BACKEND=Nokogiri
21
21
  except:
22
22
  - tags
23
23
  cache:
@@ -27,7 +27,7 @@ test:2.4:
27
27
 
28
28
  test:2.5:
29
29
  image: ruby:2.5
30
- script: bundle exec rake test
30
+ script: bundle exec rake test XML_BACKEND=REXML 2>/dev/null && bundle exec rake test XML_BACKEND=Oga 2>/dev/null && bundle exec rake test XML_BACKEND=Nokogiri
31
31
  except:
32
32
  - tags
33
33
  artifacts:
@@ -40,7 +40,7 @@ test:2.5:
40
40
 
41
41
  test:2.6:
42
42
  image: ruby:2.6
43
- script: bundle exec rake test
43
+ script: bundle exec rake test XML_BACKEND=REXML 2>/dev/null && bundle exec rake test XML_BACKEND=Oga 2>/dev/null && bundle exec rake test XML_BACKEND=Nokogiri
44
44
  except:
45
45
  - tags
46
46
  cache:
@@ -50,6 +50,7 @@ test:2.6:
50
50
 
51
51
  pages:
52
52
  stage: deploy
53
+ image: ruby:2.6
53
54
  dependencies:
54
55
  - test:2.6
55
56
  script:
@@ -1,5 +1,9 @@
1
1
  = CHANGELOG
2
2
 
3
+ == 0.4.1
4
+
5
+ * Add Oga backend for XML document
6
+
3
7
  == 0.4.0
4
8
 
5
9
  * [REFACTORING]Make submodules for `XMLDocument::Refinements`
data/Gemfile CHANGED
@@ -1,6 +1,12 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
+ if ENV['EDGE_MAKER'] == '1'
5
+ group :development do
6
+ gem 'epub-maker', path: '../epub-maker'
7
+ end
8
+ end
9
+
4
10
  if RUBY_PLATFORM.match /darwin/
5
11
  gem 'terminal-notifier'
6
12
  end
@@ -174,6 +174,10 @@ If you find other gems, please tell me or request a pull request.
174
174
 
175
175
  == RECENT CHANGES
176
176
 
177
+ === 0.4.1
178
+
179
+ * Add Oga backend for XML document
180
+
177
181
  === 0.4.0
178
182
 
179
183
  * [BUG FIX]Make epub:type a Set
data/Rakefile CHANGED
@@ -5,8 +5,8 @@ require 'yard'
5
5
  require 'rdoc/task'
6
6
  require 'epub/parser/version'
7
7
  require 'archive/zip'
8
- require 'stringio'
9
8
  require 'epub/maker'
9
+ require "tmpdir"
10
10
 
11
11
  task :default => :test
12
12
  task :test => 'test:default'
@@ -14,30 +14,19 @@ task :test => 'test:default'
14
14
  namespace :test do
15
15
  task :default => [:build, :test]
16
16
 
17
- desc 'Run all tests'
18
- task :all => [:build, :test]
19
-
20
17
  desc 'Build test fixture EPUB file'
21
- task :build => :clean do
22
- input_dir = 'test/fixtures/book'
23
- EPUB::Maker.archive input_dir
24
- small_file = File.read("#{input_dir}/OPS/case-sensitive.xhtml")
25
- File.open "#{input_dir}.epub" do |archive_in|
26
- File.open "#{input_dir}.epub.tmp", "w" do |archive_out|
27
- Archive::Zip.open archive_in, :r do |z_in|
28
- Archive::Zip.open archive_out, :w do |z_out|
29
- z_in.each do |entry|
30
- z_out << entry
31
- end
32
- entry = Archive::Zip::Entry::File.new("OPS/CASE-SENSITIVE.xhtml")
33
- entry.file_data = StringIO.new(small_file.sub('small file name', 'LARGE FILE NAME'))
34
- z_out << entry
35
- end
36
- end
37
- end
18
+ task :build => [:clean, "test/fixtures/book.epub"]
19
+
20
+ file "test/fixtures/book.epub" => "test/fixtures/book" do |task|
21
+ EPUB::Maker.archive task.source
22
+ small_file = File.read("#{task.source}/OPS/case-sensitive.xhtml")
23
+ Dir.mktmpdir do |dir|
24
+ upcase_file_path = File.join(dir, "CASE-SENSITIVE.xhtml")
25
+ File.write upcase_file_path, small_file.sub('small file name', 'LARGE FILE NAME')
26
+ Archive::Zip.archive task.name, upcase_file_path, path_prefix: "OPS"
38
27
  end
39
- File.rename "#{input_dir}.epub.tmp", "#{input_dir}.epub"
40
28
  end
29
+ CLEAN.include "test/fixtures/book.epub"
41
30
 
42
31
  Rake::TestTask.new do |task|
43
32
  task.test_files = FileList['test/**/test_*.rb']
@@ -53,12 +42,14 @@ namespace :doc do
53
42
 
54
43
  YARD::Rake::YardocTask.new
55
44
  Rake::RDocTask.new do |rdoc|
56
- rdoc.rdoc_files = FileList['lib/**/*.rb']
57
- rdoc.rdoc_files.include 'README.adoc'
58
- rdoc.rdoc_files.include 'CHANGELOG.adoc'
59
- rdoc.rdoc_files.include 'MIT-LICENSE'
60
- rdoc.rdoc_files.include 'docs/**/*.adoc'
61
- rdoc.rdoc_files.include 'docs/**/*.md'
45
+ rdoc.rdoc_files.include %w[
46
+ lib/**/*.rb
47
+ README.adoc
48
+ CHANGELOG.adoc
49
+ MIT-LICENSE
50
+ docs/**/*.adoc
51
+ docs/**/*.md
52
+ ]
62
53
  end
63
54
  end
64
55
 
@@ -118,7 +118,7 @@ ret == book # => true; this API is not good I feel... Welcome suggestion!
118
118
 
119
119
  ==== Switching XML Library
120
120
 
121
- EPUB Parser uses https://www.nokogiri.org/[Nokogiri], a Ruby bindings for http://xmlsoft.org/[Libxml2] and http://xmlsoft.org/XSLT/[Libxslt] and more if you have already installed Nokogiri gem by RubyGems or Bundler. If Nokogiri is not available, it fallbacks to https://ruby-doc.org/stdlib-2.5.3/libdoc/rexml/rdoc/index.html[REXML], a standard-bundled library. You can also specify REXML explicitly:
121
+ EPUB Parser tries to load https://gitlab.com/yorickpeterse/oga[Oga] a fast XML parser at first. If Oga is not available, then it tries https://www.nokogiri.org/[Nokogiri], a Ruby bindings for http://xmlsoft.org/[Libxml2] and http://xmlsoft.org/XSLT/[Libxslt] and more. If both are not available, it fallbacks to https://ruby-doc.org/stdlib-2.5.3/libdoc/rexml/rdoc/index.html[REXML], a standard-bundled library. You can also specify REXML explicitly:
122
122
 
123
123
  ----
124
124
  EPUB::Parser::XMLDocument.backend = :REXML
@@ -40,7 +40,8 @@ Gem::Specification.new do |s|
40
40
  s.add_development_dependency 'pretty_backtrace'
41
41
  s.add_development_dependency 'epub-maker'
42
42
  s.add_development_dependency 'asciidoctor'
43
- s.add_development_dependency 'nokogiri', '>= 1.6.0', '< 1.9'
43
+ s.add_development_dependency 'nokogiri', '>= 1.6.0', '< 1.11'
44
+ s.add_development_dependency 'oga', '>= 2.16'
44
45
 
45
46
  s.add_runtime_dependency 'archive-zip'
46
47
  s.add_runtime_dependency 'addressable', '>= 2.3.5'
@@ -32,6 +32,12 @@ module EPUB
32
32
  @rexml ||= REXML::Document.new(raw_document)
33
33
  end
34
34
 
35
+ # @return [Oga::XML::Document] content as Oga::XML::Document object
36
+ def oga
37
+ require "oga"
38
+ @oga ||= Oga.parse_xml(raw_document)
39
+ end
40
+
35
41
  # @return [Nokogiri::XML::Document] content as Nokogiri::XML::Document object
36
42
  def nokogiri
37
43
  require 'nokogiri'
@@ -35,7 +35,7 @@ module EPUB
35
35
  end
36
36
  end
37
37
  next if index < @last_iterated_entry_index
38
- # We can force encoding UTF-8 becase EPUB spec allows only UTF-8 filenames
38
+ # We can force encoding UTF-8 because EPUB spec allows only UTF-8 filenames
39
39
  entry_path = entry.zip_path.force_encoding('UTF-8')
40
40
  @entries[entry_path] = index
41
41
  @last_iterated_entry_index = index
@@ -35,13 +35,13 @@ module EPUB
35
35
  content_document
36
36
  end
37
37
 
38
- # @param [XMLDocument, REXML::Document, Nokogiri::HTML::Document] document HTML document or element including nav
38
+ # @param [XMLDocument, REXML::Document, Oga::XML::Document, Nokogiri::HTML::Document] document HTML document or element including nav
39
39
  # @return [Array<EPUB::ContentDocument::Navigation::Nav>] navs array of Nav object
40
40
  def parse_navigations(document)
41
41
  document.each_element_by_xpath('/xhtml:html/xhtml:body//xhtml:nav', EPUB::NAMESPACES).collect {|elem| parse_navigation elem}
42
42
  end
43
43
 
44
- # @param [REXML::Element, Nokogiri::XML::Element] element nav element
44
+ # @param [REXML::Element, Oga::XML::Element, Nokogiri::XML::Element] element nav element
45
45
  # @return [EPUB::ContentDocument::Navigation::Nav] nav Nav object
46
46
  def parse_navigation(element)
47
47
  nav = EPUB::ContentDocument::Navigation::Navigation.new
@@ -56,7 +56,7 @@ module EPUB
56
56
  nav
57
57
  end
58
58
 
59
- # @param [REXML::Element, Nokogiri::XML::Element] element li element
59
+ # @param [REXML::Element, Oga::XML::Element, Nokogiri::XML::Element] element li element
60
60
  def parse_navigation_item(element)
61
61
  item = EPUB::ContentDocument::Navigation::Item.new
62
62
  a_or_span = element.each_element_by_xpath('./xhtml:a[1]|xhtml:span[1]', EPUB::NAMESPACES).first
@@ -90,7 +90,7 @@ module EPUB
90
90
 
91
91
  private
92
92
 
93
- # @param [REXML::Element, Nokogiri::XML::Element] element nav element
93
+ # @param [REXML::Element, Oga::XML::Element, Nokogiri::XML::Element] element nav element
94
94
  # @return [String] heading heading text
95
95
  def find_heading(element)
96
96
  heading = element.each_element_by_xpath('./xhtml:h1|xhtml:h2|xhtml:h3|xhtml:h4|xhtml:h5|xhtml:h6|xhtml:hgroup', EPUB::NAMESPACES).first
@@ -1,5 +1,5 @@
1
1
  module EPUB
2
2
  class Parser
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.1"
4
4
  end
5
5
  end
@@ -5,7 +5,10 @@ module EPUB
5
5
  attr_accessor :backend
6
6
 
7
7
  def new(xml)
8
- if backend == :Nokogiri
8
+ case backend
9
+ when :Oga
10
+ Oga.parse_xml(xml)
11
+ when :Nokogiri
9
12
  Nokogiri.XML(xml)
10
13
  else
11
14
  REXML::Document.new(xml)
@@ -16,10 +19,10 @@ module EPUB
16
19
  end
17
20
  end
18
21
 
19
- require "epub/parser/xml_document/refinements/rexml"
20
- begin
21
- require "epub/parser/xml_document/refinements/nokogiri"
22
- EPUB::Parser::XMLDocument.backend = :Nokogiri
23
- rescue LoadError
24
- EPUB::Parser::XMLDocument.backend = :REXML
22
+ %i[Nokogiri Oga REXML].each do |backend|
23
+ begin
24
+ require "epub/parser/xml_document/refinements/#{backend.downcase}"
25
+ EPUB::Parser::XMLDocument.backend ||= backend
26
+ rescue LoadError
27
+ end
25
28
  end
@@ -0,0 +1,77 @@
1
+ require "oga"
2
+
3
+ module EPUB
4
+ class Parser
5
+ class XMLDocument
6
+ module Refinements
7
+ module Oga
8
+ [::Oga::XML::Document, ::Oga::XML::Node].each do |klass|
9
+ refine klass do
10
+ [
11
+ [:document, ::Oga::XML::Document],
12
+ [:element, ::Oga::XML::Element],
13
+ [:text, ::Oga::XML::Text]
14
+ ].each do |(type, klass)|
15
+ define_method "#{type}?" do
16
+ kind_of? klass
17
+ end
18
+ end
19
+
20
+ def root
21
+ # Couldn't use find(&:element?) for Rubies under 2.6
22
+ root_node.children.find {|child| child.element?}
23
+ end
24
+
25
+ def elements
26
+ # Couldn't use find(&:element?) for Rubies under 2.6
27
+ children.select {|child| child.element?}
28
+ end
29
+
30
+ # Need for Rubies under 2.6
31
+ def respond_to?(name, include_all = false)
32
+ [:root, :elements].include?(name) || super
33
+ end
34
+
35
+ def each_element_by_xpath(xpath, namespaces = nil, &block)
36
+ xpath(xpath, namespaces: namespaces).each &block
37
+ end
38
+ end
39
+ end
40
+
41
+ refine ::Oga::XML::Element do
42
+ def attribute_with_prefix(name, prefix = nil)
43
+ name = prefix ? "#{prefix}:#{name}" : name
44
+ get(name)
45
+ end
46
+
47
+ def each_element(xpath = nil, &block)
48
+ each_node do |node|
49
+ throw :skip_children unless node.kind_of?(::Oga::XML::Element)
50
+ block.call node
51
+ end
52
+ end
53
+
54
+ def namespace_uri
55
+ namespace&.uri
56
+ end
57
+
58
+ alias original_namespaces namespaces
59
+ def namespaces
60
+ original_namespaces.each_with_object({}) {|(name, namespace), nss|
61
+ nss[name] = namespace.uri
62
+ }
63
+ end
64
+
65
+ alias content text
66
+ end
67
+
68
+ refine ::Oga::XML::Text do
69
+ alias content text
70
+ end
71
+ end
72
+
73
+ include Oga
74
+ end
75
+ end
76
+ end
77
+ end
@@ -42,7 +42,7 @@ module EPUB
42
42
 
43
43
  # @todo: Refactoring
44
44
  # @return [Array<Hash>] An array of rearch results. Each result is composed of:
45
- # * +:element+: [REXML::Element, Nokogiri::XML::ELement] Found element
45
+ # * +:element+: [REXML::Element, Oga::XML::Element, Nokogiri::XML::ELement] Found element
46
46
  # * +:itemref+: [EPUB::Publication::Package::Spine::Itemref] Itemref that element's document belongs to
47
47
  # * +:location+: [EPUB::CFI::Location] CFI that indicates the element
48
48
  # * +:package+: [EPUB::Publication::Package] Package that the element belongs to
@@ -9,7 +9,7 @@ module EPUB
9
9
  ALGORITHMS = {}
10
10
 
11
11
  class << self
12
- # @param element [REXML::Element, REXML::Document, Nokogiri::XML::Element, Nokogiri::XML::Document]
12
+ # @param element [REXML::Element, REXML::Document, Oga::XML::ELement, Oga::XML::Document, Nokogiri::XML::Element, Nokogiri::XML::Document]
13
13
  # @param word [String]
14
14
  # @return [Array<Result>]
15
15
  def search_text(element, word)
@@ -23,7 +23,7 @@ module EPUB
23
23
  end
24
24
 
25
25
  class Restricted < self
26
- # @param element [REXML::Element, Nokogiri::XML::Element]
26
+ # @param element [REXML::Element, Oga::XML::Element, Nokogiri::XML::Element]
27
27
  # @return [Array<Result>]
28
28
  def search_text(word, element=nil)
29
29
  results = []
@@ -15,3 +15,6 @@ if ENV["PRETTY_BACKTRACE"]
15
15
  end
16
16
 
17
17
  require 'epub/parser'
18
+ if ENV["XML_BACKEND"]
19
+ EPUB::Parser::XMLDocument.backend = ENV["XML_BACKEND"].to_sym
20
+ end
@@ -4,7 +4,7 @@ require File.expand_path 'helper', File.dirname(__FILE__)
4
4
  class TestParserPublication < Test::Unit::TestCase
5
5
  def setup
6
6
  opf = File.read("test/fixtures/book/OPS/ルートファイル.opf")
7
- @opf = Nokogiri.XML(opf)
7
+ @opf = EPUB::Parser::XMLDocument.new(opf)
8
8
  @parser = EPUB::Parser::Publication.new(opf)
9
9
  @package = @parser.parse_package(@opf)
10
10
  end
@@ -6,77 +6,81 @@ class TestParserXMLDocument < Test::Unit::TestCase
6
6
  @container = File.read("test/fixtures/book/META-INF/container.xml")
7
7
  @opf = File.read("test/fixtures/book/OPS/ルートファイル.opf")
8
8
  @nav = File.read("test/fixtures/book/OPS/nav.xhtml")
9
+ @backends = [:REXML, :Nokogiri, :Oga]
9
10
  end
10
11
 
11
12
  def test_parse_container
12
- EPUB::Parser::XMLDocument.backend = :REXML
13
- rexml_container = EPUB::Parser::OCF.new(nil).parse_container(@container)
14
- EPUB::Parser::XMLDocument.backend = :Nokogiri
15
- nokogiri_container = EPUB::Parser::OCF.new(nil).parse_container(@container)
16
-
17
- assert_equal rexml_container.rootfiles.length, nokogiri_container.rootfiles.length
18
- rexml_container.rootfiles.each do |rootfile|
19
- rf = nokogiri_container.rootfiles.find {|rf| rf.full_path == rootfile.full_path}
20
- assert_equal rootfile.full_path, rf.full_path
21
- assert_equal rootfile.media_type, rf.media_type
13
+ assert_equal_results @backends do
14
+ container = EPUB::Parser::OCF.new(nil).parse_container(@container)
15
+ [
16
+ container.rootfiles.length,
17
+ container.rootfiles.collect {|rootfile|
18
+ [rootfile.full_path, rootfile.media_type]
19
+ }
20
+ ]
22
21
  end
23
22
  end
24
23
 
25
24
  def test_parse_package_document
26
- EPUB::Parser::XMLDocument.backend = :REXML
27
- rexml_package = EPUB::Parser::Publication.new(@opf).parse
28
- EPUB::Parser::XMLDocument.backend = :Nokogiri
29
- nokogiri_package = EPUB::Parser::Publication.new(@opf).parse
25
+ assert_equal_results @backends do
26
+ result = []
30
27
 
31
- %i[version prefix xml_lang dir id].each do |attr|
32
- assert_equal rexml_package.send(attr), nokogiri_package.send(attr)
33
- end
28
+ package = EPUB::Parser::Publication.new(@opf).parse
34
29
 
35
- EPUB::Metadata::DC_ELEMS.each do |attr|
36
- rexml_attr = rexml_package.metadata.send(attr)
37
- nokogiri_attr = nokogiri_package.metadata.send(attr)
30
+ result << %i[version prefix xml_lang dir id].collect {|attr| package.send(attr)}
38
31
 
39
- assert_equal rexml_attr.length, nokogiri_attr.length
32
+ result << EPUB::Metadata::DC_ELEMS.collect {|attr|
33
+ attr = package.metadata.send(attr)
34
+ [
35
+ attr.length,
36
+ attr.collect {|model|
37
+ %i[content id lang dir].collect {|a| model.send(a)}
38
+ }
39
+ ]
40
+ }
40
41
 
41
- rexml_attr.each_with_index do |model, index|
42
- %i[content id lang dir].each do |a|
43
- assert_equal model.send(a), nokogiri_attr[index].send(a)
44
- end
45
- end
46
- end
42
+ result << package.metadata.metas.collect {|meta|
43
+ %i[property id scheme content name meta_content].collect {|attr| meta.send(attr)}
44
+ }
47
45
 
48
- rexml_package.metadata.metas.each_with_index do |meta, index|
49
- %i[property id scheme content name meta_content].each do |attr|
50
- assert_equal meta.send(attr), nokogiri_package.metadata.metas[index].send(attr)
51
- end
52
- end
46
+ result << package.metadata.links.collect {|link|
47
+ %i[href rel id media_type].collect {|attr| link.send(attr)}
48
+ }
53
49
 
54
- rexml_package.metadata.links.each_with_index do |link, index|
55
- %i[href rel id media_type].each do |attr|
56
- assert_equal link.send(attr), nokogiri_package.metadata.links[index].send(attr)
57
- end
50
+ result
58
51
  end
59
52
  end
60
53
 
61
54
  def test_parse_navigation
62
- EPUB::Parser::XMLDocument.backend = :REXML
63
- rexml_nav = EPUB::Parser.parse("test/fixtures/book.epub").nav.content_document
64
- EPUB::Parser::XMLDocument.backend = :Nokogiri
65
- nokogiri_nav = EPUB::Parser.parse("test/fixtures/book.epub").nav.content_document
66
-
67
- assert_equal rexml_nav.navigations.length, nokogiri_nav.navigations.length
68
-
69
- rexml_nav.navigations.each_with_index do |item, index|
70
- nokogiri_item = nokogiri_nav.navigations[index]
71
- %i[text content_document type].each do |attr|
72
- assert_equal item.send(attr), nokogiri_item.send(attr)
73
- end
74
-
75
- item.items.each_with_index do |i, index2|
76
- %i[text content_document].each do |attr|
77
- assert_equal i.send(attr), nokogiri_item.items[index2].send(attr)
78
- end
79
- end
55
+ assert_equal_results @backends do
56
+ result = []
57
+
58
+ nav = EPUB::Parser.parse("test/fixtures/book.epub").nav.content_document
59
+
60
+ result << nav.navigations.length
61
+
62
+ result << nav.navigations.collect {|item|
63
+ %i[text content_document type].collect {|attr| item.send(attr)}
64
+
65
+ item.items.collect {|i|
66
+ %i[text content_document].collect {|attr| i.send(attr)}
67
+ }
68
+ }
69
+
70
+ result
71
+ end
72
+ end
73
+
74
+ private
75
+
76
+ def assert_equal_results(backends)
77
+ results = backends.collect {|backend|
78
+ EPUB::Parser::XMLDocument.backend = backend
79
+ yield
80
+ }
81
+ expected = results.shift
82
+ results.each do |actual|
83
+ assert_equal expected, actual
80
84
  end
81
85
  end
82
86
  end
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.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - KITAITI Makoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-13 00:00:00.000000000 Z
11
+ date: 2019-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -229,7 +229,7 @@ dependencies:
229
229
  version: 1.6.0
230
230
  - - "<"
231
231
  - !ruby/object:Gem::Version
232
- version: '1.9'
232
+ version: '1.11'
233
233
  type: :development
234
234
  prerelease: false
235
235
  version_requirements: !ruby/object:Gem::Requirement
@@ -239,7 +239,21 @@ dependencies:
239
239
  version: 1.6.0
240
240
  - - "<"
241
241
  - !ruby/object:Gem::Version
242
- version: '1.9'
242
+ version: '1.11'
243
+ - !ruby/object:Gem::Dependency
244
+ name: oga
245
+ requirement: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - ">="
248
+ - !ruby/object:Gem::Version
249
+ version: '2.16'
250
+ type: :development
251
+ prerelease: false
252
+ version_requirements: !ruby/object:Gem::Requirement
253
+ requirements:
254
+ - - ">="
255
+ - !ruby/object:Gem::Version
256
+ version: '2.16'
243
257
  - !ruby/object:Gem::Dependency
244
258
  name: archive-zip
245
259
  requirement: !ruby/object:Gem::Requirement
@@ -365,6 +379,7 @@ files:
365
379
  - lib/epub/parser/version.rb
366
380
  - lib/epub/parser/xml_document.rb
367
381
  - lib/epub/parser/xml_document/refinements/nokogiri.rb
382
+ - lib/epub/parser/xml_document/refinements/oga.rb
368
383
  - lib/epub/parser/xml_document/refinements/rexml.rb
369
384
  - lib/epub/publication.rb
370
385
  - lib/epub/publication/fixed_layout.rb