class EPUB::Parser::OCF
Constants
- DIRECTORY
Public Class Methods
new(container)
click to toggle source
# File lib/epub/parser/ocf.rb, line 21 def initialize(container) @container = container @ocf = EPUB::OCF.new end
parse(container)
click to toggle source
# File lib/epub/parser/ocf.rb, line 16 def parse(container) new(container).parse end
Public Instance Methods
parse()
click to toggle source
# File lib/epub/parser/ocf.rb, line 26 def parse EPUB::OCF::MODULES.each do |m| begin data = @container.read(File.join(DIRECTORY, "#{m}.xml")) @ocf.__send__ "#{m}=", __send__("parse_#{m}", data) rescue EPUB::OCF::PhysicalContainer::NoEntry end end @ocf end
parse_container(xml)
click to toggle source
# File lib/epub/parser/ocf.rb, line 38 def parse_container(xml) container = EPUB::OCF::Container.new doc = XMLDocument.new(xml) doc.each_element_by_xpath "/ocf:container/ocf:rootfiles/ocf:rootfile", EPUB::NAMESPACES do |elem| rootfile = EPUB::OCF::Container::Rootfile.new rootfile.full_path = Addressable::URI.parse(elem.attribute_with_prefix('full-path')) rootfile.media_type = elem.attribute_with_prefix('media-type') container.rootfiles << rootfile end container end
parse_encryption(content)
click to toggle source
# File lib/epub/parser/ocf.rb, line 51 def parse_encryption(content) encryption = EPUB::OCF::Encryption.new encryption.content = content encryption end
parse_manifest(content)
click to toggle source
# File lib/epub/parser/ocf.rb, line 57 def parse_manifest(content) warn "Not implemented: #{self.class}##{__method__}" if $VERBOSE end
parse_metadata(content)
click to toggle source
Calls superclass method
EPUB::Parser::Metadata#parse_metadata
# File lib/epub/parser/ocf.rb, line 61 def parse_metadata(content) doc = XMLDocument.new(content) unless multiple_rendition_metadata?(doc) warn "Not implemented: #{self.class}##{__method__}" if $VERBOSE metadata = EPUB::OCF::UnknownFormatMetadata.new metadata.content = content return metadata end super(doc.root, doc.root.attribute_with_prefix('unique-identifier'), 'metadata') end
parse_rights(content)
click to toggle source
# File lib/epub/parser/ocf.rb, line 72 def parse_rights(content) warn "Not implemented: #{self.class}##{__method__}" if $VERBOSE end
parse_signatures(content)
click to toggle source
# File lib/epub/parser/ocf.rb, line 76 def parse_signatures(content) warn "Not implemented: #{self.class}##{__method__}" if $VERBOSE end
Private Instance Methods
multiple_rendition_metadata?(doc)
click to toggle source
# File lib/epub/parser/ocf.rb, line 82 def multiple_rendition_metadata?(doc) doc.root && doc.root.name == 'metadata' && doc.root.namespaces['xmlns'] == EPUB::NAMESPACES['metadata'] end