Class: DocBook::Epub
- Inherits:
-
Object
- Object
- DocBook::Epub
- Defined in:
- lib/docbook.rb
Constant Summary collapse
- CHECKER =
"epubcheck"- STYLESHEET =
File.(File.join(File.dirname(__FILE__), '..', '..', "docbook.xsl"))
- CALLOUT_PATH =
File.join('images', 'callouts')
- CALLOUT_FULL_PATH =
File.(File.join(File.dirname(__FILE__), '..', '..', '..', CALLOUT_PATH))
- CALLOUT_LIMIT =
15- CALLOUT_EXT =
".png"- XSLT_PROCESSOR =
"xsltproc"- OUTPUT_DIR =
".epubtmp#{Time.now.to_f.to_s}"- MIMETYPE =
"application/epub+zip"- META_DIR =
"META-INF"- OEBPS_DIR =
"OEBPS"- ZIPPER =
"zip"
Instance Attribute Summary collapse
-
#output_dir ⇒ Object
readonly
Returns the value of attribute output_dir.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(docbook_file, output_dir = OUTPUT_DIR, css_file = nil, customization_layer = nil, embedded_fonts = []) ⇒ Epub
constructor
A new instance of Epub.
- #render_to_file(output_file, verbose = false) ⇒ Object
Constructor Details
#initialize(docbook_file, output_dir = OUTPUT_DIR, css_file = nil, customization_layer = nil, embedded_fonts = []) ⇒ Epub
Returns a new instance of Epub.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/docbook.rb', line 22 def initialize(docbook_file, output_dir=OUTPUT_DIR, css_file=nil, customization_layer=nil, =[]) @docbook_file = docbook_file @output_dir = output_dir @meta_dir = File.join(@output_dir, META_DIR) @oebps_dir = File.join(@output_dir, OEBPS_DIR) @css_file = css_file ? File.(css_file) : css_file @embedded_fonts = @to_delete = [] if customization_layer @stylesheet = File.(customization_layer) else @stylesheet = STYLESHEET end unless File.exist?(@docbook_file) raise ArgumentError.new("File #{@docbook_file} does not exist") end end |
Instance Attribute Details
#output_dir ⇒ Object (readonly)
Returns the value of attribute output_dir.
20 21 22 |
# File 'lib/docbook.rb', line 20 def output_dir @output_dir end |
Class Method Details
.invalid?(file) ⇒ Boolean
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/docbook.rb', line 48 def self.invalid?(file) # Obnoxiously, we can't just check for a non-zero output... cmd = %Q(#{CHECKER} "#{file}") output = `#{cmd} 2>&1` if $?.to_i == 0 return false else STDERR.puts output if $DEBUG return output end end |
Instance Method Details
#render_to_file(output_file, verbose = false) ⇒ Object
42 43 44 45 46 |
# File 'lib/docbook.rb', line 42 def render_to_file(output_file, verbose=false) render_to_epub(output_file, verbose) bundle_epub(output_file, verbose) cleanup_files(@to_delete) end |