Class: EpubForge::Builder::Epub
- Inherits:
-
EpubForge::Builder
- Object
- EpubForge::Builder
- EpubForge::Builder::Epub
- Defined in:
- lib/epubforge/builder/epub.rb
Constant Summary
Constants included from EpubForge::Builder
FONT_FILE_EXTENSION, IMAGE_FILE_EXTENSIONS, MEDIA_TYPES, PAGE_FILE_EXTENSIONS
Instance Method Summary collapse
-
#build ⇒ Object
zips up contents.
- #clean ⇒ Object
- #package(epub_filename) ⇒ Object
Instance Method Details
#build ⇒ Object
zips up contents
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/epubforge/builder/epub.rb', line 15 def build FunWith::Files::DirectoryBuilder.create( @scratch_dir ) do |build| build.file( "mimetype", mimetype ) build.dir( "META-INF" ) do build.file("container.xml", container) end build.dir( "OEBPS" ) do build.file( "toc.ncx", toc ) build.file( "content.opf", content_opf ) build.dir( "Text" ) do @sections.each do |section| content = section.html content = wrap_page( content, section.section_id ) unless section.source_format == :xhtml build.file( section.dest_filename, content ) end end unless @images.fwf_blank? build.dir "Images" do for img in @images build.copy( img.filename ) end end end unless @stylesheets.fwf_blank? build.dir "Styles" do for sheet in @stylesheets build.file( sheet.name, sheet.contents ) end end end unless @fonts.fwf_blank? build.dir "Fonts" do for font in @fonts build.copy( font.filename ) end end end end end end |
#clean ⇒ Object
10 11 12 |
# File 'lib/epubforge/builder/epub.rb', line 10 def clean # do nothing? Remove scratch dir? end |
#package(epub_filename) ⇒ Object
4 5 6 7 8 |
# File 'lib/epubforge/builder/epub.rb', line 4 def package( epub_filename ) epub_filename = epub_filename.fwf_filepath. FileUtils.rm( epub_filename ) if epub_filename.exist? `cd #{@scratch_dir} && zip -Xr #{epub_filename.to_s.epf_backhashed_filename} mimetype META-INF OEBPS` end |