Sha256: 2cd9e553c20057813a135dd44095f2e287a34e6719d4cbf6e6cffa16400ec61a
Contents?: true
Size: 1.03 KB
Versions: 4
Compression:
Stored size: 1.03 KB
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 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 load_metadata_file Nokogiri::XML(zip_file.read(metadata_path)) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
epubinfo-0.4.3 | lib/epubinfo/parser.rb |
epubinfo-0.4.2 | lib/epubinfo/parser.rb |
epubinfo-0.4.1 | lib/epubinfo/parser.rb |
epubinfo-0.4.0 | lib/epubinfo/parser.rb |