module Softcover::Commands::Build

Public Instance Methods

all_formats(options={}) click to toggle source

Builds the book for all formats.

# File lib/softcover/commands/build.rb, line 19
def all_formats(options={})
  building_message('all formats', options)
  if custom?
    build_custom_formats!
  else
    Softcover::BUILD_ALL_FORMATS.each do |format|
      if format == 'mobi'
        building_message('EPUB & MOBI', options)
      else
        building_message(format.upcase, options)
      end
      builder_for(format).build!(options)
    end
  end
end
build_config() click to toggle source

Returns the filename for configuring `softcover build`.

# File lib/softcover/commands/build.rb, line 60
def build_config
  '.softcover-build'
end
build_custom_formats!() click to toggle source
# File lib/softcover/commands/build.rb, line 50
def build_custom_formats!
  execute custom_commands
end
builder_for(format) click to toggle source

Returns the builder for the given format.

# File lib/softcover/commands/build.rb, line 42
def builder_for(format)
  "Softcover::Builders::#{format.titleize}".constantize.new
end
custom?() click to toggle source
# File lib/softcover/commands/build.rb, line 46
def custom?
  File.exist?(build_config) && !custom_commands.empty?
end
custom_commands() click to toggle source

Returns custom commands (if any).

# File lib/softcover/commands/build.rb, line 55
def custom_commands
  commands(File.readlines(build_config).map(&:strip))
end
for_format(format, options={}) click to toggle source

Builds the book for the given format.

# File lib/softcover/commands/build.rb, line 9
def for_format(format, options={})
  raise 'Invalid format' unless Softcover::FORMATS.include?(format)
  building_message(format.upcase, options)
  builder_for(format).build!(options)
  if format == 'html' && !(options[:silent] || options[:quiet])
    puts "LaTeX-to-XML debug information output to log/tralics.log"
  end
end
preview(options={}) click to toggle source

Builds the book preview.

# File lib/softcover/commands/build.rb, line 36
def preview(options={})
  building_message('preview', options)
  builder_for('preview').build!
end

Private Instance Methods

building_message(format, options={}) click to toggle source

Shows a message when building a particular format.

# File lib/softcover/commands/build.rb, line 67
def building_message(format, options={})
  unless options[:silent] || options[:'find-overfull']
    puts "Building #{format}..."
  end
end