class Bcome::Registry::Command::External
Public Instance Methods
construct_full_command(node, arguments)
click to toggle source
# File lib/objects/registry/command/external.rb, line 17 def construct_full_command(node, arguments) substituted_command = construct_substituted_command(arguments) namespaced_command = namespace_command(node, substituted_command) namespaced_command end
construct_substituted_command(arguments)
click to toggle source
# File lib/objects/registry/command/external.rb, line 23 def construct_substituted_command(arguments) substituted_command = local_command.dup merged_arguments = process_arguments(arguments) local_command_substitutions.each do |substitution| substitute_with = merged_arguments[substitution.to_sym] if substitute_with.nil? error_message_suffix = "- missing '#{substitution}' from command '#{local_command}'" raise Bcome::Exception::MissingArgumentForRegistryCommand, error_message_suffix end substitute_with = if [TrueClass, FalseClass].include?(substitute_with.class) substitute_with ? 'true' : 'false' else substitute_with end substituted_command.gsub!("%#{substitution}%", substitute_with) end substituted_command end
do_pretty_print()
click to toggle source
Calls superclass method
# File lib/objects/registry/command/external.rb, line 56 def do_pretty_print menu_str = super + "\n\s\s\s\slocal command:\s".resource_key + local_command.resource_value menu_str += "\n\s\s\s\sdefaults:\s".resource_key + defaults.inspect.resource_value menu_str + "\n\n" end
execute(node, arguments)
click to toggle source
In which the bcome context is passed to an external call
# File lib/objects/registry/command/external.rb, line 7 def execute(node, arguments) full_command = construct_full_command(node, arguments) begin puts "\n(external) > #{full_command}".bc_blue + "\n\n" system(full_command) rescue Interrupt puts "\nExiting gracefully from interrupt\n".warning end end
expected_keys()
click to toggle source
Calls superclass method
Bcome::Registry::Command::Base#expected_keys
# File lib/objects/registry/command/external.rb, line 52 def expected_keys super + [:local_command] end
local_command_substitutions()
click to toggle source
# File lib/objects/registry/command/external.rb, line 48 def local_command_substitutions local_command.scan(/%([^%]*)%/).flatten.uniq end
namespace_command(node, command)
click to toggle source
# File lib/objects/registry/command/external.rb, line 44 def namespace_command(node, command) "bcome_context=\"#{node.keyed_namespace}\" #{command}" end