Module: Softcover::Commands::Build
Constant Summary
Constants included from Utils
Instance Method Summary collapse
-
#all_formats(options = {}) ⇒ Object
Builds the book for all formats.
-
#build_config ⇒ Object
Returns the filename for configuring ‘softcover build`.
- #build_custom_formats! ⇒ Object
-
#builder_for(format) ⇒ Object
Returns the builder for the given format.
- #custom? ⇒ Boolean
-
#custom_commands ⇒ Object
Returns custom commands (if any).
-
#for_format(format, options = {}) ⇒ Object
Builds the book for the given format.
-
#preview(options = {}) ⇒ Object
Builds the book preview.
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(={}) ('all formats', ) if custom? build_custom_formats! else Softcover::BUILD_ALL_FORMATS.each do |format| if format == 'mobi' ('EPUB & MOBI', ) else (format.upcase, ) end builder_for(format).build!() end end end |
#build_config ⇒ Object
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
46 47 48 |
# File 'lib/softcover/commands/build.rb', line 46 def custom? File.exist?(build_config) && !custom_commands.empty? end |
#custom_commands ⇒ Object
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, ={}) raise 'Invalid format' unless Softcover::FORMATS.include?(format) (format.upcase, ) builder_for(format).build!() if format == 'html' && !([:silent] || [: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(={}) ('preview', ) builder_for('preview').build! end |