Sha256: b6e057376c073d49ede62426364bc7d6f3150d053d46d606fbbdd4ef6ec8b20c
Contents?: true
Size: 1.26 KB
Versions: 3
Compression:
Stored size: 1.26 KB
Contents
module Rpub class Epub attr_reader :book, :styles def initialize(book, styles) @book, @styles = book, styles end def manifest_in(target) target.store_file 'mimetype', 'application/epub+zip' target.compress_file 'META-INF/container.xml', Container.new target.compress_file 'OEBPS/content.opf', Content.new(book) target.compress_file 'OEBPS/toc.ncx', Toc.new(book) target.compress_file 'OEBPS/styles.css', styles if book.has_cover? target.compress_file 'OEBPS/cover.html', Cover.new(book) target.compress_file File.join('OEBPS', book.cover_image), File.read(book.cover_image) end if book.has_toc? target.compress_file 'OEBPS/toc.html', toc { HtmlToc.new(book).render } end if book.has_fonts? book.fonts.each do |font| target.compress_file File.join('OEBPS', font), File.read(font) end end book.each do |chapter| target.compress_file File.join('OEBPS', chapter.filename), chapter.to_html end book.images.each do |image| target.compress_file File.join('OEBPS', image), File.read(image) end end private def toc @body = yield ERB.new(File.read(book.layout)).result(binding) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rpub-0.4.0 | lib/rpub/epub.rb |
rpub-0.3.0 | lib/rpub/epub.rb |
rpub-0.2.1 | lib/rpub/epub.rb |