class Softcover::Builders::Mobi
Public Instance Methods
build!(options={})
click to toggle source
# 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={})
click to toggle source
Returns the command for making a MOBI, based on the options.
# File lib/softcover/builders/mobi.rb, line 25 def mobi_command(filename, options={}) silent = options[:silent] || Softcover.test? cmd = "#{calibre} ebooks/#{filename}.epub ebooks/#{filename}.mobi" + " #{calibre_options}" puts cmd unless (options[:quiet] || silent) cmd end
mobi_filename(options={})
click to toggle source
Returns the filename of the MOBI (preview if necessary).
# File lib/softcover/builders/mobi.rb, line 20 def mobi_filename(options={}) options[:preview] ? manifest.filename + '-preview' : manifest.filename end
Private Instance Methods
calibre()
click to toggle source
# File lib/softcover/builders/mobi.rb, line 35 def calibre @calibre ||= executable(dependency_filename(:calibre)) end
calibre_options()
click to toggle source
Returns the options for the Calibre `ebook-convert` CLI
.
# File lib/softcover/builders/mobi.rb, line 40 def calibre_options # Include both Mobipocket & KF8 formats. # Figuring this out took around two years. It really should be # the Calibre default. opts = ["--mobi-file-type both"] # Don't put pagebreaks in the detailed table of contents. opts << "--chapter /" if cover? # Add an explicit path to the cover image. # Figuring this out took several days. opts << "--cover #{cover_img_path}" # Get covers to work in Kindle desktop app. opts << "--share-not-sync" end opts.join(" ") end