16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/logtool/parser.rb', line 16
def self.parse_blocks(file_path)
blocks = []
block = nil
open_log(file_path) do |fh|
fh.read.split("\n").each do |line|
if line =~ Block.head
blocks << block if block
block = Block.new
block.method = $1
block.ip = $2
block.text = line + "\n"
elsif line =~ Block.head_2_3
blocks << block if block
block = Block.new
block.method = $2
block.ip = $1
block.text = line + "\n"
elsif block and line =~ Block.tail
block.response = $1
block.time = $2
block.text += line + "\n"
block.freeze
elsif block and line =~ Block.asset_tail
block.response = $1
block.time = $2
block.text += line + "\n"
block.freeze
else
block.text += line + "\n" if block and !block.frozen?
end
end
end
return blocks
end
|