Class: Crosstest::Shell::IOToLog

Inherits:
IO
  • Object
show all
Defined in:
lib/crosstest/shell/mixlib_shellout_executor.rb

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ IOToLog

Returns a new instance of IOToLog


6
7
8
9
# File 'lib/crosstest/shell/mixlib_shellout_executor.rb', line 6

def initialize(logger)
  @logger = logger
  @buffer = ''
end

Instance Method Details

#write(string) ⇒ Object


11
12
13
14
15
16
17
18
19
20
# File 'lib/crosstest/shell/mixlib_shellout_executor.rb', line 11

def write(string)
  (@buffer + string).lines.each do |line|
    if line.end_with? "\n"
      @buffer = ''
      @logger.info(line.rstrip)
    else
      @buffer = line
    end
  end
end