Class: Arrolio::ConfigDrivenPipeline
- Inherits:
-
Object
- Object
- Arrolio::ConfigDrivenPipeline
- Defined in:
- lib/arrolio/config_driven_pipeline.rb
Instance Attribute Summary collapse
-
#adapter_rules ⇒ Object
readonly
Returns the value of attribute adapter_rules.
-
#flavor_dir ⇒ Object
readonly
Returns the value of attribute flavor_dir.
-
#flow_rules ⇒ Object
readonly
Returns the value of attribute flow_rules.
-
#layout_spec ⇒ Object
readonly
Returns the value of attribute layout_spec.
-
#manifest ⇒ Object
readonly
Returns the value of attribute manifest.
-
#strict ⇒ Object
readonly
Returns the value of attribute strict.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(flavor_dir:, input_path: nil, extra_image_dirs: [], logo_path: nil, strict: false) ⇒ ConfigDrivenPipeline
constructor
A new instance of ConfigDrivenPipeline.
- #render(xml, io:, metadata: {}) ⇒ Object
Constructor Details
#initialize(flavor_dir:, input_path: nil, extra_image_dirs: [], logo_path: nil, strict: false) ⇒ ConfigDrivenPipeline
Returns a new instance of ConfigDrivenPipeline.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/arrolio/config_driven_pipeline.rb', line 21 def initialize(flavor_dir:, input_path: nil, extra_image_dirs: [], logo_path: nil, strict: false) @flavor_dir = File.(flavor_dir) @input_path = input_path @extra_image_dirs = Array(extra_image_dirs) @logo_path = logo_path @strict = strict @manifest = load_manifest @layout_spec = load_layout_spec @adapter_rules = load_yaml('adapter_rules.yml') @flow_rules = load_yaml('flow_rules.yml') end |
Instance Attribute Details
#adapter_rules ⇒ Object (readonly)
Returns the value of attribute adapter_rules.
7 8 9 |
# File 'lib/arrolio/config_driven_pipeline.rb', line 7 def adapter_rules @adapter_rules end |
#flavor_dir ⇒ Object (readonly)
Returns the value of attribute flavor_dir.
7 8 9 |
# File 'lib/arrolio/config_driven_pipeline.rb', line 7 def flavor_dir @flavor_dir end |
#flow_rules ⇒ Object (readonly)
Returns the value of attribute flow_rules.
7 8 9 |
# File 'lib/arrolio/config_driven_pipeline.rb', line 7 def flow_rules @flow_rules end |
#layout_spec ⇒ Object (readonly)
Returns the value of attribute layout_spec.
7 8 9 |
# File 'lib/arrolio/config_driven_pipeline.rb', line 7 def layout_spec @layout_spec end |
#manifest ⇒ Object (readonly)
Returns the value of attribute manifest.
7 8 9 |
# File 'lib/arrolio/config_driven_pipeline.rb', line 7 def manifest @manifest end |
#strict ⇒ Object (readonly)
Returns the value of attribute strict.
7 8 9 |
# File 'lib/arrolio/config_driven_pipeline.rb', line 7 def strict @strict end |
Class Method Details
.render(xml, io:, flavor_dir:, input_path: nil, extra_image_dirs: [], logo_path: nil, metadata: {}, strict: false) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/arrolio/config_driven_pipeline.rb', line 9 def self.render(xml, io:, flavor_dir:, input_path: nil, extra_image_dirs: [], logo_path: nil, metadata: {}, strict: false) new( flavor_dir: flavor_dir, input_path: input_path, extra_image_dirs: extra_image_dirs, logo_path: logo_path, strict: strict ).render(xml, io: io, metadata: ) end |
Instance Method Details
#render(xml, io:, metadata: {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/arrolio/config_driven_pipeline.rb', line 34 def render(xml, io:, metadata: {}) adapter = GenericAdapter.new(rules: @adapter_rules, layout_spec: @layout_spec) document = adapter.convert(xml) = document..merge(.transform_keys(&:to_sym)) register_fonts resolver = AssetResolver.from_input_path( @input_path, extra: @extra_image_dirs + [@flavor_dir] ) flowables = GenericFlowBuilder.new( layout_spec: @layout_spec, rules: @flow_rules, asset_resolver: resolver ).build(document) engine = Engine::Paged.new(layout_spec: @layout_spec, flowables: flowables) pages = engine.layout populate_toc(pages, engine.context) Renderer::Pdf.new.render( pages, io: io, logo_path: @logo_path, metadata: , font_paths: @layout_spec.font_paths, context: engine.context, layout_spec: @layout_spec ) end |