Class: Klue::Langcraft::DSL::KlueRunner
- Inherits:
-
Object
- Object
- Klue::Langcraft::DSL::KlueRunner
- Defined in:
- lib/klue/langcraft/dsl/klue_runner.rb
Overview
KlueRunner handles the processing of DSL input data It manages the execution of various processors and the output of processed data
Instance Attribute Summary collapse
-
#interpreter ⇒ Object
readonly
Returns the value of attribute interpreter.
-
#pipeline ⇒ Object
readonly
Returns the value of attribute pipeline.
-
#webhook ⇒ Object
readonly
Returns the value of attribute webhook.
Instance Method Summary collapse
-
#initialize ⇒ KlueRunner
constructor
A new instance of KlueRunner.
-
#run(input: nil, input_file: nil, basic_output_file: nil, enhanced_output_file: nil, webhook_url: nil, log_level: :none) ⇒ Object
Run the KlueRunner with the given input data.
Constructor Details
#initialize ⇒ KlueRunner
Returns a new instance of KlueRunner.
11 12 13 14 15 |
# File 'lib/klue/langcraft/dsl/klue_runner.rb', line 11 def initialize @interpreter = Klue::Langcraft::DSL::Interpreter.new @pipeline = Klue::Langcraft::DSL::ProcessDataPipeline.new(Klue::Langcraft::DSL::ProcessMatcher.new) @webhook = Klue::Langcraft::DSL::Webhook.new end |
Instance Attribute Details
#interpreter ⇒ Object (readonly)
Returns the value of attribute interpreter.
9 10 11 |
# File 'lib/klue/langcraft/dsl/klue_runner.rb', line 9 def interpreter @interpreter end |
#pipeline ⇒ Object (readonly)
Returns the value of attribute pipeline.
9 10 11 |
# File 'lib/klue/langcraft/dsl/klue_runner.rb', line 9 def pipeline @pipeline end |
#webhook ⇒ Object (readonly)
Returns the value of attribute webhook.
9 10 11 |
# File 'lib/klue/langcraft/dsl/klue_runner.rb', line 9 def webhook @webhook end |
Instance Method Details
#run(input: nil, input_file: nil, basic_output_file: nil, enhanced_output_file: nil, webhook_url: nil, log_level: :none) ⇒ Object
Run the KlueRunner with the given input data
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 50 51 |
# File 'lib/klue/langcraft/dsl/klue_runner.rb', line 22 def run( input: nil, input_file: nil, basic_output_file: nil, enhanced_output_file: nil, webhook_url: nil, log_level: :none ) @log_level = log_level log_info('Processing input') data = interpreter.process(input: input, input_file: input_file, output_file: basic_output_file) log_detailed('Interpreter output:', data) log_info('Executing pipeline - enhance') enhanced_data = pipeline.execute(data) log_detailed('Enhanced output:', enhanced_data) if enhanced_output_file log_info("Writing enhanced output to file: #{enhanced_output_file}") @pipeline.write_output(enhanced_data, enhanced_output_file) end if webhook_url log_info("Delivering data to webhook: #{webhook_url}") @webhook.deliver(webhook_url, enhanced_data) end log_info('Processing complete') end |