Class: Softcover::Builders::Mobi

Inherits:
Softcover::Builder show all
Includes:
EpubUtils, Utils
Defined in:
lib/softcover/builders/mobi.rb

Constant Summary

Constants included from Utils

Utils::UNITS

Instance Attribute Summary

Attributes inherited from Softcover::Builder

#built_files, #manifest

Instance Method Summary collapse

Methods included from EpubUtils

#content_opf_template, #cover?, #cover_img, #cover_img_path, #escape, #images_dir, #nav_html_template, #toc_ncx_template

Methods included from Utils

#add_highlight_class!, #article?, #as_size, #book_file_lines, #chapter_label, #commands, #current_book, #dependency_filename, #digest, #executable, #execute, #filename_or_default, #get_filename, #in_book_directory?, #language_labels, #linux?, #logged_in?, #master_content, #master_filename, #master_latex_header, #mkdir, #non_comment_lines, #os_x?, #path, #raw_lines, #reset_current_book!, #rm, #rm_r, #silence, #source, #template_dir, #tmpify, #unpublish_slug, #write_master_latex_file, #write_pygments_file

Methods inherited from Softcover::Builder

#clean!, #initialize

Constructor Details

This class inherits a constructor from Softcover::Builder

Instance Method Details

#build!(options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/softcover/builders/mobi.rb', line 7

def build!(options={})
  Softcover::Builders::Epub.new.build!(options)
  filename = mobi_filename(options)
  command  = mobi_command(filename, options)
  silent   = options[:silent] || Softcover.test?
  if options[:quiet] || silent
    silence { system(command) }
  else
    system(command)
  end
end

#mobi_command(filename, options = {}) ⇒ Object

Returns the command for making a MOBI, based on the options.



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/softcover/builders/mobi.rb', line 25

def mobi_command(filename, options={})
  silent = options[:silent] || Softcover.test?
  if options[:kindlegen]
    cmd = "#{kindlegen} ebooks/#{filename}.epub"
  else
    cmd = "#{calibre} ebooks/#{filename}.epub ebooks/#{filename}.mobi" +
          " #{calibre_options}"
  end
  puts cmd unless (options[:quiet] || silent)
  cmd
end

#mobi_filename(options = {}) ⇒ Object

Returns the filename of the MOBI (preview if necessary).



20
21
22
# File 'lib/softcover/builders/mobi.rb', line 20

def mobi_filename(options={})
  options[:preview] ? manifest.filename + '-preview' : manifest.filename
end