Class: Polytrix::Executors::IOToLog

Inherits:
IO
  • Object
show all
Defined in:
lib/polytrix/executors/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/polytrix/executors/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/polytrix/executors/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