Class: SwarmCLI::ConfigLoader
- Inherits:
-
Object
- Object
- SwarmCLI::ConfigLoader
- Defined in:
- lib/swarm_cli/config_loader.rb
Overview
ConfigLoader handles loading swarm configurations from both YAML and Ruby DSL files.
Supports:
- YAML files (.yml, .yaml) - loaded via SwarmSDK.load_file
- Ruby DSL files (.rb) - executed and expected to return a SwarmSDK::Swarm or SwarmSDK::Workflow instance
Class Method Summary collapse
-
.load(path) ⇒ SwarmSDK::Swarm, SwarmSDK::Workflow
Load a swarm configuration from file (YAML or Ruby DSL).
Class Method Details
.load(path) ⇒ SwarmSDK::Swarm, SwarmSDK::Workflow
Load a swarm configuration from file (YAML or Ruby DSL)
Detects file type by extension:
- .yml, .yaml -> Load as YAML using SwarmSDK.load_file
- .rb -> Execute as Ruby DSL and expect SwarmSDK::Swarm or SwarmSDK::Workflow instance
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/swarm_cli/config_loader.rb', line 27 def load(path) path = Pathname.new(path). unless path.exist? raise ConfigurationError, "Configuration file not found: #{path}" end case path.extname.downcase when ".yml", ".yaml" load_yaml(path) when ".rb" load_ruby_dsl(path) else raise ConfigurationError, "Unsupported configuration file format: #{path.extname}. " \ "Supported formats: .yml, .yaml (YAML), .rb (Ruby DSL)" end end |