Sha256: 833551035936ec9d07e7a3566da62d53c6590cb9edbc24a61b1fb0718767960a
Contents?: true
Size: 973 Bytes
Versions: 1
Compression:
Stored size: 973 Bytes
Contents
module EPUBInfo class Parser attr_accessor :path, :metadata_document def self.parse(path) epubinfo = EPUBInfo::Parser.new epubinfo.path = path epubinfo end def metadata_document @metadata_document ||= load_metadata_file end 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 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.css('container rootfiles rootfile:first-child').attribute('full-path').content end def load_metadata_file Nokogiri::XML(zip_file.read(metadata_path)) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
epubinfo-0.3.4 | lib/epubinfo/parser.rb |