Class: Ace::Support::Nav::Organisms::CommandDelegator
- Inherits:
-
Object
- Object
- Ace::Support::Nav::Organisms::CommandDelegator
- Defined in:
- lib/ace/support/nav/organisms/command_delegator.rb
Overview
Handles command delegation for cmd-type protocols Executes external commands based on protocol configuration templates
Instance Method Summary collapse
-
#delegate(uri_string, options = {}) ⇒ Integer
Delegate a URI to an external command.
-
#initialize(config_loader: nil) ⇒ CommandDelegator
constructor
A new instance of CommandDelegator.
Constructor Details
#initialize(config_loader: nil) ⇒ CommandDelegator
Returns a new instance of CommandDelegator.
13 14 15 |
# File 'lib/ace/support/nav/organisms/command_delegator.rb', line 13 def initialize(config_loader: nil) @config_loader = config_loader || Molecules::ConfigLoader.new end |
Instance Method Details
#delegate(uri_string, options = {}) ⇒ Integer
Delegate a URI to an external command
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ace/support/nav/organisms/command_delegator.rb', line 21 def delegate(uri_string, = {}) # Parse the URI to extract protocol and reference protocol, reference = parse_uri(uri_string) # Load protocol configuration protocol_config = @config_loader.load_protocol_config(protocol) # Verify this is a cmd-type protocol unless protocol_config["type"] == "cmd" raise ArgumentError, "Protocol #{protocol} is not a cmd-type protocol" end # Get command template command_template = protocol_config["command_template"] unless command_template raise ArgumentError, "Protocol #{protocol} missing command_template" end # Build the command command_parts = build_command(command_template, reference, , protocol_config) # Execute the command execute_command(command_parts) end |