lib/epubinfo/parser.rb in epubinfo-0.3.6 vs lib/epubinfo/parser.rb in epubinfo-0.4.0

- old
+ new

@@ -14,30 +14,32 @@ def drm_protected? @drm_protected ||= !!zip_file.find_entry('META-INF/rights.xml') end - private - def zip_file begin @zip_file ||= Zip::ZipFile.open(@path) rescue Zip::ZipError => e raise NotAnEPUBFileError.new(e) end end + def metadata_path + @metadata_path ||= begin + root_document.remove_namespaces! + root_document.css('container rootfiles rootfile:first-child').attribute('full-path').content + end + end + + private + def root_document begin @root_document ||= Nokogiri::XML(zip_file.read('META-INF/container.xml')) rescue => e raise NotAnEPUBFileError.new(e) end - end - - def metadata_path - root_document.remove_namespaces! - root_document.css('container rootfiles rootfile:first-child').attribute('full-path').content end def load_metadata_file Nokogiri::XML(zip_file.read(metadata_path)) end