Class: ActionCommand::LogParser

Inherits:
Object
  • Object
show all
Defined in:
lib/action_command/log_parser.rb

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(stream, sequence = nil) ⇒ LogParser

Create a new log parser for an IO subclass



69
70
71
72
# File 'lib/action_command/log_parser.rb', line 69

def initialize(stream, sequence = nil)
  @stream = stream
  @sequence = sequence
end

Instance Method Details

#eof?Boolean

Check if we have reached the end of the stream.

Returns:

  • (Boolean)


75
76
77
# File 'lib/action_command/log_parser.rb', line 75

def eof?
  return @stream.eof?
end

#next(msg) ⇒ Object

Populates a message from the next line in the



80
81
82
83
84
85
86
87
88
89
90
# 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