class Aruba::CommandMonitor
The command monitor is part of the private API of Aruba
.
@private
Attributes
Public Class Methods
Source
# File lib/aruba/command_monitor.rb, line 47 def initialize(opts = {}) @registered_commands = [] @announcer = opts.fetch(:announcer) @last_command_stopped = DefaultLastCommandStopped.new @last_command_started = DefaultLastCommandStarted.new rescue KeyError => e raise ArgumentError, e.message end
Public Instance Methods
Source
# File lib/aruba/command_monitor.rb, line 118 def all_output all_stdout << all_stderr end
Get stderr and stdout of all commands
@return [String]
The stderr and stdout of all command which have run before
Source
# File lib/aruba/command_monitor.rb, line 108 def all_stderr registered_commands.each(&:stop) registered_commands.map(&:stderr).join end
Get stderr of all commands
@return [String]
The stderr of all command which have run before
Source
# File lib/aruba/command_monitor.rb, line 98 def all_stdout registered_commands.each(&:stop) registered_commands.map(&:stdout).join end
Get stdout of all commands
@return [String]
The stdout of all command which have run before
Source
# File lib/aruba/command_monitor.rb, line 87 def clear registered_commands.each(&:terminate) registered_commands.clear self end
Clear list of known commands
Source
# File lib/aruba/command_monitor.rb, line 77 def find(cmd) cmd = cmd.commandline if cmd.respond_to? :commandline command = registered_commands.reverse.find { |c| c.commandline == cmd } raise CommandNotFoundError, "No command named '#{cmd}' has been started" if command.nil? command end
Find command
@yield [Command]
This yields the found command
Source
# File lib/aruba/command_monitor.rb, line 61 def last_command_started=(cmd) @last_command_started = find(cmd) end
Set last command started
@param [String] cmd
The commandline of the command
Source
# File lib/aruba/command_monitor.rb, line 69 def last_command_stopped=(cmd) @last_command_stopped = find(cmd) end
Set last command stopped
@param [String] cmd
The commandline of the command
Source
# File lib/aruba/command_monitor.rb, line 123 def register_command(cmd) registered_commands << cmd self end
Register command to monitor