Class: Sakusei::Builder
- Inherits:
-
Object
- Object
- Sakusei::Builder
- Defined in:
- lib/sakusei/builder.rb
Instance Attribute Summary collapse
-
#source_dir ⇒ Object
readonly
Returns the value of attribute source_dir.
-
#source_file ⇒ Object
readonly
Returns the value of attribute source_file.
Instance Method Summary collapse
- #build ⇒ Object
-
#build_html ⇒ Object
Run the full pipeline up to (but not including) PDF conversion, then render the processed markdown to a styled HTML string via md-to-pdf –as-html.
-
#initialize(source_file, options = {}) ⇒ Builder
constructor
A new instance of Builder.
-
#resolved_input_files ⇒ Object
Files that contributed to the most recent build (source + @include partials).
Constructor Details
#initialize(source_file, options = {}) ⇒ Builder
Returns a new instance of Builder.
14 15 16 17 18 19 |
# File 'lib/sakusei/builder.rb', line 14 def initialize(source_file, = {}) @source_file = File.(source_file) @options = @source_dir = File.dirname(@source_file) @file_resolver = nil end |
Instance Attribute Details
#source_dir ⇒ Object (readonly)
Returns the value of attribute source_dir.
21 22 23 |
# File 'lib/sakusei/builder.rb', line 21 def source_dir @source_dir end |
#source_file ⇒ Object (readonly)
Returns the value of attribute source_file.
21 22 23 |
# File 'lib/sakusei/builder.rb', line 21 def source_file @source_file end |
Instance Method Details
#build ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/sakusei/builder.rb', line 31 def build style_pack, processed_content = build_processed_content $stderr.puts "[sakusei] converting to PDF..." output_path = generate_output_path convert_to_pdf(processed_content, output_path, style_pack) $stderr.puts "[sakusei] written: #{output_path}" output_path end |
#build_html ⇒ Object
Run the full pipeline up to (but not including) PDF conversion, then render the processed markdown to a styled HTML string via md-to-pdf –as-html. Returns [html_string, style_pack].
43 44 45 46 47 |
# File 'lib/sakusei/builder.rb', line 43 def build_html style_pack, processed_content = build_processed_content html = HtmlConverter.new(processed_content, style_pack, @options.merge(source_dir: @source_dir)).convert [html, style_pack] end |
#resolved_input_files ⇒ Object
Files that contributed to the most recent build (source + @include partials). Populated after #build, #build_html, or #build_processed_content runs.
25 26 27 28 29 |
# File 'lib/sakusei/builder.rb', line 25 def resolved_input_files files = [@source_file] files.concat(@file_resolver.resolved_files.to_a) if @file_resolver files.uniq end |