Class: Aruba::CommandMonitor
- Inherits:
-
Object
- Object
- Aruba::CommandMonitor
- Defined in:
- lib/aruba/platforms/command_monitor.rb
Overview
The command monitor is part of the private API of Aruba.
Defined Under Namespace
Classes: DefaultLastCommandStarted, DefaultLastCommandStopped
Instance Attribute Summary collapse
-
#last_command_started ⇒ Object
Returns the value of attribute last_command_started.
-
#last_command_stopped ⇒ Object
Returns the value of attribute last_command_stopped.
-
#registered_commands ⇒ Object
readonly
Returns the value of attribute registered_commands.
Instance Method Summary collapse
-
#all_output ⇒ String
Get stderr and stdout of all commands.
-
#all_stderr ⇒ String
Get stderr of all commands.
-
#all_stdout ⇒ String
Get stdout of all commands.
-
#clear ⇒ Object
Clear list of known commands.
-
#find(cmd) {|Command| ... } ⇒ Object
Find command.
-
#initialize(opts = {}) ⇒ CommandMonitor
constructor
A new instance of CommandMonitor.
-
#register_command(cmd) ⇒ Object
Register command to monitor.
Constructor Details
#initialize(opts = {}) ⇒ CommandMonitor
Returns a new instance of CommandMonitor.
45 46 47 48 49 50 51 52 53 |
# File 'lib/aruba/platforms/command_monitor.rb', line 45 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. end |
Instance Attribute Details
#last_command_started ⇒ Object
Returns the value of attribute last_command_started.
15 16 17 |
# File 'lib/aruba/platforms/command_monitor.rb', line 15 def last_command_started @last_command_started end |
#last_command_stopped ⇒ Object
Returns the value of attribute last_command_stopped.
15 16 17 |
# File 'lib/aruba/platforms/command_monitor.rb', line 15 def last_command_stopped @last_command_stopped end |
#registered_commands ⇒ Object (readonly)
Returns the value of attribute registered_commands.
15 16 17 |
# File 'lib/aruba/platforms/command_monitor.rb', line 15 def registered_commands @registered_commands end |
Instance Method Details
#all_output ⇒ String
Get stderr and stdout of all commands
116 117 118 |
# File 'lib/aruba/platforms/command_monitor.rb', line 116 def all_output all_stdout << all_stderr end |
#all_stderr ⇒ String
Get stderr of all commands
106 107 108 109 110 |
# File 'lib/aruba/platforms/command_monitor.rb', line 106 def all_stderr registered_commands.each(&:stop) registered_commands.each_with_object("") { |e, a| a << e.stderr } end |
#all_stdout ⇒ String
Get stdout of all commands
96 97 98 99 100 |
# File 'lib/aruba/platforms/command_monitor.rb', line 96 def all_stdout registered_commands.each(&:stop) registered_commands.each_with_object("") { |e, a| a << e.stdout } end |
#clear ⇒ Object
Clear list of known commands
85 86 87 88 89 90 |
# File 'lib/aruba/platforms/command_monitor.rb', line 85 def clear registered_commands.each(&:terminate) registered_commands.clear self end |
#find(cmd) {|Command| ... } ⇒ Object
Find command
75 76 77 78 79 80 81 82 |
# File 'lib/aruba/platforms/command_monitor.rb', line 75 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 |
#register_command(cmd) ⇒ Object
Register command to monitor
121 122 123 124 125 |
# File 'lib/aruba/platforms/command_monitor.rb', line 121 def register_command(cmd) registered_commands << cmd self end |