Class: BaseParser
- Inherits:
-
Object
show all
- Defined in:
- lib/base_parser.rb
Instance Method Summary
collapse
Constructor Details
#initialize(output, timestamp) ⇒ BaseParser
Returns a new instance of BaseParser.
7
8
9
|
# File 'lib/base_parser.rb', line 7
def initialize(output, timestamp)
@oh = OutputHelper.new(output, timestamp)
end
|
Instance Method Details
#convert(curfile, lines) ⇒ Object
61
62
|
# File 'lib/base_parser.rb', line 61
def convert(curfile, lines)
end
|
#isduplicate(msgid) ⇒ Object
64
65
66
67
68
69
70
|
# File 'lib/base_parser.rb', line 64
def isduplicate(msgid)
return false unless msgid and msgid.length > 0
return true if @prevmsgid and msgid == @prevmsgid
@prevmsgid = msgid
return false
end
|
#parse ⇒ Object
30
31
32
33
|
# File 'lib/base_parser.rb', line 30
def parse
summary = parse_with_summary
puts summary
end
|
#parse_with_summary ⇒ Object
35
36
|
# File 'lib/base_parser.rb', line 35
def parse_with_summary
end
|
#parsegrep(grep) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/base_parser.rb', line 38
def parsegrep(grep)
lines = []
curfile = nil
File.foreach(grep) do |line|
curfile = @oh.getfile(line) unless curfile
next unless curfile
if line != "--\n" and !line.start_with?(curfile)
convert curfile, lines
curfile = @oh.getfile(line)
lines = []
end
lines << line
end
if curfile and lines.length > 0
convert curfile, lines
else
puts "$grep is empty or malformated."
end
end
|
#shouldabsent(*exts) ⇒ Object
23
24
25
26
27
28
|
# File 'lib/base_parser.rb', line 23
def shouldabsent(*exts)
exts.each do |ext|
path = @oh.getmout(ext)
raise "#{path} already exists." if File.exist?(path)
end
end
|
#shouldexist(*exts) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/base_parser.rb', line 11
def shouldexist(*exts)
paths = []
exts.each do |ext|
path = @oh.getmout(ext)
raise "Can't find #{path}" unless File.exist?(path)
paths << path
end
return paths[0] if paths.length == 1
paths
end
|