Class: MarkdownComposer::TransformRunner
- Inherits:
-
Object
- Object
- MarkdownComposer::TransformRunner
- Includes:
- ContentPlacement, FieldInterpolator, HeadingNumbering, ScopeResolver
- Defined in:
- lib/markdown_composer/transform_runner.rb,
lib/markdown_composer/transform_runner/scope_resolver.rb,
lib/markdown_composer/transform_runner/content_placement.rb,
lib/markdown_composer/transform_runner/heading_numbering.rb,
lib/markdown_composer/transform_runner/field_interpolator.rb
Defined Under Namespace
Modules: ContentPlacement, FieldInterpolator, HeadingNumbering, ScopeResolver
Instance Attribute Summary collapse
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
-
#diagnostics ⇒ Object
readonly
Returns the value of attribute diagnostics.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#path_prefix ⇒ Object
readonly
Returns the value of attribute path_prefix.
-
#stages ⇒ Object
readonly
Returns the value of attribute stages.
-
#transforms ⇒ Object
readonly
Returns the value of attribute transforms.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(buffer:, transforms:, output:, options:, diagnostics:, stages:, path_prefix: "transform") ⇒ TransformRunner
constructor
A new instance of TransformRunner.
Constructor Details
#initialize(buffer:, transforms:, output:, options:, diagnostics:, stages:, path_prefix: "transform") ⇒ TransformRunner
Returns a new instance of TransformRunner.
17 18 19 20 21 22 23 24 25 |
# File 'lib/markdown_composer/transform_runner.rb', line 17 def initialize(buffer:, transforms:, output:, options:, diagnostics:, stages:, path_prefix: "transform") @buffer = buffer @transforms = transforms @output = output @options = @diagnostics = diagnostics @stages = stages @path_prefix = path_prefix end |
Instance Attribute Details
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
15 16 17 |
# File 'lib/markdown_composer/transform_runner.rb', line 15 def buffer @buffer end |
#diagnostics ⇒ Object (readonly)
Returns the value of attribute diagnostics.
15 16 17 |
# File 'lib/markdown_composer/transform_runner.rb', line 15 def diagnostics @diagnostics end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
15 16 17 |
# File 'lib/markdown_composer/transform_runner.rb', line 15 def @options end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
15 16 17 |
# File 'lib/markdown_composer/transform_runner.rb', line 15 def output @output end |
#path_prefix ⇒ Object (readonly)
Returns the value of attribute path_prefix.
15 16 17 |
# File 'lib/markdown_composer/transform_runner.rb', line 15 def path_prefix @path_prefix end |
#stages ⇒ Object (readonly)
Returns the value of attribute stages.
15 16 17 |
# File 'lib/markdown_composer/transform_runner.rb', line 15 def stages @stages end |
#transforms ⇒ Object (readonly)
Returns the value of attribute transforms.
15 16 17 |
# File 'lib/markdown_composer/transform_runner.rb', line 15 def transforms @transforms end |
Instance Method Details
#call ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/markdown_composer/transform_runner.rb', line 27 def call transforms.each_with_index do |transform, index| path = "#{path_prefix}[#{index}]" before = buffer.markdown apply_transform(transform, path: path) diagnostics.warn("transform.noop", "#{transform["transform"]} made no changes", path: "#{path}.transform", details: { stage: "transformed_markdown" }) if before == buffer.markdown stages["transform_#{index + 1}"] = buffer.markdown if .fetch(:stages, false) end stages["transformed_markdown"] = buffer.markdown if .fetch(:stages, false) stages["final"] = output == "markdown" ? buffer.markdown : nil if .fetch(:stages, false) buffer end |