Sha256: d6a7b5fc34e5d4cafc191065acd58cdd4dd1137ff11dc7035ceb034c6c86e5e3

Contents?: true

Size: 969 Bytes

Versions: 9

Compression:

Stored size: 969 Bytes

Contents

module Softcover
  module Builders
    class Mobi < Builder

      def build!(options={})
        Softcover::Builders::Epub.new.build!(options)
        filename  = manifest.filename
        filename += '-preview' if options[:preview]
        command = "#{kindlegen} ebooks/#{filename}.epub"
        # Because of the way kindlegen uses tempfiles, testing for the
        # actual generation of the MOBI causes an error, so in tests
        # we just return the command.
        if options[:quiet] || options[:silent]
          silence { Softcover.test? ? command : system(command) }
        else
          Softcover.test? ? command : system(command)
        end
      end

      private

        def kindlegen
          filename = `which kindlegen`.chomp
          url = 'http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211'
          message  = "Install kindlegen (#{url})"
          @kindlegen ||= executable(filename, message)
        end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
softcover-0.6.7 lib/softcover/builders/mobi.rb
softcover-0.6.6 lib/softcover/builders/mobi.rb
softcover-0.6.5 lib/softcover/builders/mobi.rb
softcover-0.6.4 lib/softcover/builders/mobi.rb
softcover-0.6.3 lib/softcover/builders/mobi.rb
softcover-0.6.2 lib/softcover/builders/mobi.rb
softcover-0.6.1 lib/softcover/builders/mobi.rb
softcover-0.6.0 lib/softcover/builders/mobi.rb
softcover-0.5.0 lib/softcover/builders/mobi.rb