Class: SwarmSDK::Configuration::Translator

Inherits:
Object
  • Object
show all
Defined in:
lib/swarm_sdk/configuration/translator.rb

Overview

Translates parsed configuration to Swarm/Workflow using DSL builders

This class is responsible for:

  • Creating the appropriate builder (Swarm::Builder or Workflow::Builder)
  • Translating parsed configuration into DSL method calls
  • Building the final Swarm or Workflow instance

Receives a parsed Configuration::Parser and converts it to runtime objects.

Instance Method Summary collapse

Constructor Details

#initialize(parser) ⇒ Translator

Returns a new instance of Translator.



14
15
16
# File 'lib/swarm_sdk/configuration/translator.rb', line 14

def initialize(parser)
  @parser = parser
end

Instance Method Details

#to_swarm(allow_filesystem_tools: nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/swarm_sdk/configuration/translator.rb', line 18

def to_swarm(allow_filesystem_tools: nil)
  builder = create_builder(allow_filesystem_tools)

  translate_common_config(builder)
  translate_type_specific_config(builder)
  translate_agents(builder)
  translate_hooks(builder)

  builder.build_swarm
end