Class: Sakusei::Builder
- Inherits:
-
Object
- Object
- Sakusei::Builder
- Defined in:
- lib/sakusei/builder.rb
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(source_file, options = {}) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(source_file, options = {}) ⇒ Builder
Returns a new instance of Builder.
13 14 15 16 17 |
# File 'lib/sakusei/builder.rb', line 13 def initialize(source_file, = {}) @source_file = File.(source_file) @options = @source_dir = File.dirname(@source_file) end |
Instance Method Details
#build ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/sakusei/builder.rb', line 19 def build # 1. Discover and load style pack $stderr.puts "[sakusei] discovering style pack..." style_pack = discover_style_pack $stderr.puts "[sakusei] style pack: #{style_pack.name} (#{style_pack.path})" # 2. Resolve and concatenate file references $stderr.puts "[sakusei] resolving file includes..." resolved_content = resolve_files # 3. Process ERB templates $stderr.puts "[sakusei] processing ERB..." processed_content = process_erb(resolved_content) # 3.5. Expand shorthand syntax (e.g. ::break:: → page-break div) processed_content = (processed_content) # 4. Process Vue components (if available) processed_content = process_vue(processed_content, style_pack) # 4.5 Wrap h2/h3 headings with their following block to prevent orphaned headings processed_content = wrap_headings(processed_content) # 5. Convert to PDF $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 |