class ActionCommand::LogParser

reads from a stream containing log statements, and returns LogMessage entries for them.

Public Class Methods

new(stream, sequence = nil) click to toggle source

Create a new log parser for an IO subclass

# File lib/action_command/log_parser.rb, line 69
def initialize(stream, sequence = nil)
  @stream = stream
  @sequence = sequence
end

Public Instance Methods

eof?() click to toggle source

Check if we have reached the end of the stream.

# File lib/action_command/log_parser.rb, line 75
def eof?
  return @stream.eof?
end
next(msg) click to toggle source

Populates a message from the next line in the

# File lib/action_command/log_parser.rb, line 80
def next(msg)
  # be tolerant of the fact that there might be other
  # stuff in the log file.
  next_line do |input, line|
    if input.key?('sequence')
      msg.populate(line, input) unless @sequence && @sequence != input['sequence']
      return true
    end
  end
  return false
end

Private Instance Methods

next_line() { |input, line| ... } click to toggle source
# File lib/action_command/log_parser.rb, line 94
def next_line
  until @stream.eof?
    line = @stream.readline
    line.scan(/--\s+:\s+({.*})/) do |item|
      input = JSON.parse(item[0])
      yield input, line
    end
  end
end