Class: TRMNLP::TransformPipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/trmnlp/transform_pipeline.rb

Overview

Pipes assembled merge_variables through src/transform.py,rb,php,js when a serverless runtime is configured. Mirrors the hosted transform behavior: the transform receives the data (including the trmnl namespace) on stdin and its stdout JSON replaces the data. Failure modes surface via #error (rendered in the preview UI), not raised.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config:, paths:, reporter: Reporter.new) ⇒ TransformPipeline

Returns a new instance of TransformPipeline.



18
19
20
21
22
# File 'lib/trmnlp/transform_pipeline.rb', line 18

def initialize(config:, paths:, reporter: Reporter.new)
  @config = config
  @paths = paths
  @reporter = reporter
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



16
17
18
# File 'lib/trmnlp/transform_pipeline.rb', line 16

def error
  @error
end

Instance Method Details

#call(data) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/trmnlp/transform_pipeline.rb', line 24

def call(data)
  @error = nil
  transform_path, inferred_language = paths.transform_file
  return data unless transform_path && client

  run(transform_path, inferred_language, data)
end

#reset!Object



32
# File 'lib/trmnlp/transform_pipeline.rb', line 32

def reset! = @client = nil