Class: Ikaros::Command
- Inherits:
-
Object
- Object
- Ikaros::Command
- Defined in:
- lib/ikaros/command.rb
Instance Method Summary collapse
-
#initialize(command, options = {}) ⇒ Command
constructor
A new instance of Command.
- #run ⇒ Object
Constructor Details
#initialize(command, options = {}) ⇒ Command
Returns a new instance of Command.
5 6 7 8 |
# File 'lib/ikaros/command.rb', line 5 def initialize(command, ={}) @command = command @options = end |
Instance Method Details
#run ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ikaros/command.rb', line 10 def run logger.debug @command result = '' Open3.popen3(@command) do |stdin, stdout, stderr, wait_thr| while line = stdout.gets result = "#{result}#{line}" logger.debug line logger.info line if output? end unless wait_thr.value.success? raise Error::CommandError.new stderr.gets(nil) end end result.chomp end |