Class: EpubTools::CompileBook
- Inherits:
-
Object
- Object
- EpubTools::CompileBook
- Includes:
- Loggable
- Defined in:
- lib/epub_tools/compile_book.rb
Overview
Orchestrates extraction, splitting, validation, and packaging of book EPUBs
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Book author.
-
#build_dir ⇒ Object
readonly
Optional working directory for intermediate files.
-
#cover_image ⇒ Object
readonly
Optional path to the cover image.
-
#output_file ⇒ Object
readonly
Filename for the final epub.
-
#source_dir ⇒ Object
readonly
Path of the input epubs.
-
#title ⇒ Object
readonly
Book title.
-
#verbose ⇒ Object
readonly
Whether to print progress to STDOUT.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ CompileBook
constructor
Initializes the class.
-
#run ⇒ Object
Run the full compile workflow.
Methods included from Loggable
Constructor Details
#initialize(options = {}) ⇒ CompileBook
Initializes the class
38 39 40 41 42 43 44 45 46 |
# File 'lib/epub_tools/compile_book.rb', line 38 def initialize( = {}) @title = .fetch(:title) @author = .fetch(:author) @source_dir = .fetch(:source_dir) @cover_image = [:cover_image] @output_file = [:output_file] || default_output_file @build_dir = [:build_dir] || File.join(Dir.pwd, '.epub_tools_build') @verbose = [:verbose] || false end |
Instance Attribute Details
#author ⇒ Object (readonly)
Book author
17 18 19 |
# File 'lib/epub_tools/compile_book.rb', line 17 def @author end |
#build_dir ⇒ Object (readonly)
Optional working directory for intermediate files
25 26 27 |
# File 'lib/epub_tools/compile_book.rb', line 25 def build_dir @build_dir end |
#cover_image ⇒ Object (readonly)
Optional path to the cover image
21 22 23 |
# File 'lib/epub_tools/compile_book.rb', line 21 def cover_image @cover_image end |
#output_file ⇒ Object (readonly)
Filename for the final epub
23 24 25 |
# File 'lib/epub_tools/compile_book.rb', line 23 def output_file @output_file end |
#source_dir ⇒ Object (readonly)
Path of the input epubs
19 20 21 |
# File 'lib/epub_tools/compile_book.rb', line 19 def source_dir @source_dir end |
#title ⇒ Object (readonly)
Book title
15 16 17 |
# File 'lib/epub_tools/compile_book.rb', line 15 def title @title end |
#verbose ⇒ Object (readonly)
Whether to print progress to STDOUT
27 28 29 |
# File 'lib/epub_tools/compile_book.rb', line 27 def verbose @verbose end |
Instance Method Details
#run ⇒ Object
Run the full compile workflow
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/epub_tools/compile_book.rb', line 49 def run clean_build_dir prepare_dirs extract_xhtmls split_xhtmls validate_sequence initialize_epub add_chapters pack_epub log "Done. Output EPUB: #{File.(output_file)}" clean_build_dir end |