Module: Softcover::Commands::Build

Extended by:
Build
Includes:
Output, Utils
Included in:
Build
Defined in:
lib/softcover/commands/build.rb

Constant Summary

Constants included from Utils

Utils::UNITS

Instance Method Summary collapse

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, #first_path, #get_filename, #html_extension, #in_book_directory?, #language_labels, #linux?, #logged_in?, #master_content, #master_filename, #master_latex_header, #mkdir, #non_comment_lines, #os_x?, #path, #polytexnic_html, #raw_lines, #reset_current_book!, #rm, #rm_r, #silence, #silence_stream, #source, #template_dir, #tmpify, #unpublish_slug, #write_master_latex_file, #write_pygments_file

Methods included from Output

should_output?, silence!, silent?, #system, unsilence!

Instance Method Details

#all_formats(options = {}) ⇒ Object

Builds the book for all formats.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# 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_configObject

Returns the filename for configuring ‘softcover build`.



60
61
62
# File 'lib/softcover/commands/build.rb', line 60

def build_config
  '.softcover-build'
end

#build_custom_formats!Object



50
51
52
# File 'lib/softcover/commands/build.rb', line 50

def build_custom_formats!
  execute custom_commands
end

#builder_for(format) ⇒ Object

Returns the builder for the given format.



42
43
44
# File 'lib/softcover/commands/build.rb', line 42

def builder_for(format)
  "Softcover::Builders::#{format.titleize}".constantize.new
end

#custom?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/softcover/commands/build.rb', line 46

def custom?
  File.exist?(build_config) && !custom_commands.empty?
end

#custom_commandsObject

Returns custom commands (if any).



55
56
57
# File 'lib/softcover/commands/build.rb', line 55

def custom_commands
  commands(File.readlines(build_config).map(&:strip))
end

#for_format(format, options = {}) ⇒ Object

Builds the book for the given format.



9
10
11
12
13
14
15
16
# 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 = {}) ⇒ Object

Builds the book preview.



36
37
38
39
# File 'lib/softcover/commands/build.rb', line 36

def preview(options={})
  building_message('preview', options)
  builder_for('preview').build!
end