Class: Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/gl_tail/parser.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ Parser

Returns a new instance of Parser.



12
13
14
# File 'lib/gl_tail/parser.rb', line 12

def initialize( source )
  @source = source
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



10
11
12
# File 'lib/gl_tail/parser.rb', line 10

def source
  @source
end

Class Method Details

.inherited(klass) ⇒ Object



21
22
23
24
25
26
# File 'lib/gl_tail/parser.rb', line 21

def self::inherited( klass )
  parser_name = klass.to_s.sub( /Parser$/, '' ).downcase.intern

  @registry ||= {}
  @registry[ parser_name ] = klass
end

.registryObject



28
29
30
# File 'lib/gl_tail/parser.rb', line 28

def self::registry
  return @registry
end

Instance Method Details

#add_activity(opts = {}) ⇒ Object

dsl-ish helper methods so the parsers don’t call server.add_* anymore. That seems magical now that server isn’t be explicitly passed anymore.



39
40
41
# File 'lib/gl_tail/parser.rb', line 39

def add_activity( opts = {} )
  @source.add_activity( opts )
end

#add_event(opts = {}) ⇒ Object



43
44
45
# File 'lib/gl_tail/parser.rb', line 43

def add_event( opts = {} )
  @source.add_event( opts )
end

#parse(line) ⇒ Object

Raises:

  • (NotImplementedError)


32
33
34
35
# File 'lib/gl_tail/parser.rb', line 32

def parse( line )
  raise NotImplementedError,
    "Concrete parsers must implement parse()"
end

#serverObject

DEPRECATED?



17
18
19
# File 'lib/gl_tail/parser.rb', line 17

def server
  @source
end