Class: Docbook::Output::Pipeline
- Inherits:
-
Object
- Object
- Docbook::Output::Pipeline
- Defined in:
- lib/docbook/output/pipeline.rb
Overview
Composable data processing pipeline for DocBook XML.
Orchestrates steps that parse XML, generate TOC, numbering, index, transform to DocbookMirror JSON, attach metadata, generate lists, and resolve image paths. Returns a complete guide hash ready for consumption by any Format class.
Steps are pluggable — pass a custom step list to add, remove, or reorder processing stages without modifying this class.
Usage: guide = Pipeline.new(xml_path: "book.xml").process
# Custom pipeline with extra step steps = Pipeline::DEFAULT_STEPS.dup.insert(5, MyCustomStep) guide = Pipeline.new(xml_path: "book.xml", steps: steps).process
Constant Summary collapse
- DEFAULT_STEPS =
[ PipelineSteps::ParseXml, PipelineSteps::AssignIds, PipelineSteps::GenerateToc, PipelineSteps::GenerateNumbering, PipelineSteps::GenerateIndex, PipelineSteps::TransformMirror, PipelineSteps::AttachMetadata, PipelineSteps::GenerateLists, PipelineSteps::ResolveImages, ].freeze
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
-
#initialize(xml_path:, steps: DEFAULT_STEPS, image_search_dirs: [], image_strategy: :data_url, sort_glossary: false, title: "DocBook") ⇒ Pipeline
constructor
A new instance of Pipeline.
-
#process ⇒ Hash
Run the pipeline and return the complete guide hash.
Constructor Details
#initialize(xml_path:, steps: DEFAULT_STEPS, image_search_dirs: [], image_strategy: :data_url, sort_glossary: false, title: "DocBook") ⇒ Pipeline
Returns a new instance of Pipeline.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/docbook/output/pipeline.rb', line 46 def initialize(xml_path:, steps: DEFAULT_STEPS, image_search_dirs: [], image_strategy: :data_url, sort_glossary: false, title: "DocBook") @steps = steps @context = PipelineContext.new( xml_path: xml_path, image_search_dirs: Array(image_search_dirs), image_strategy: image_strategy, sort_glossary: sort_glossary, title: title, parsed: nil, ) end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
38 39 40 |
# File 'lib/docbook/output/pipeline.rb', line 38 def context @context end |
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
38 39 40 |
# File 'lib/docbook/output/pipeline.rb', line 38 def steps @steps end |
Instance Method Details
#process ⇒ Hash
Run the pipeline and return the complete guide hash.
61 62 63 64 65 66 |
# File 'lib/docbook/output/pipeline.rb', line 61 def process guide = {} @steps.reduce(guide) do |current_guide, step_class| step_class.new.call(current_guide, @context) end end |