line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::Karmasphere::Parser::Score::Base; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
65
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
51
|
|
5
|
2
|
|
|
2
|
|
10
|
use base 'Mail::Karmasphere::Parser::Base'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
693
|
|
6
|
2
|
|
|
2
|
|
4969
|
use Text::CSV; |
|
2
|
|
|
|
|
44133
|
|
|
2
|
|
|
|
|
19
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
1
|
|
|
1
|
0
|
1321
|
my $class = shift; |
10
|
1
|
50
|
|
|
|
7
|
my $self = ($#_ == 0) ? { %{ (shift) } } : { @_ }; |
|
0
|
|
|
|
|
0
|
|
11
|
1
|
|
|
|
|
3
|
my $type = $self->{Type}; |
12
|
1
|
50
|
|
|
|
6
|
unless ($type) { |
13
|
1
|
|
|
|
|
3
|
$type = lc $class; |
14
|
1
|
|
|
|
|
8
|
$type =~ s/.*:://; |
15
|
|
|
|
|
|
|
} |
16
|
1
|
50
|
|
|
|
6
|
$self->{Streams} = [ $type ] unless $self->{Streams}; |
17
|
1
|
|
|
|
|
11
|
$self = $class->SUPER::new($self); |
18
|
1
|
|
|
|
|
4
|
return $self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _value { |
22
|
5
|
|
|
5
|
|
9
|
my $text = shift; |
23
|
5
|
100
|
|
|
|
70
|
return 1000 unless defined $text; |
24
|
4
|
100
|
|
|
|
15
|
return 1000 unless $text =~ /\S/; |
25
|
3
|
|
|
|
|
18
|
return 0+ $text; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _parse { |
29
|
5
|
|
|
5
|
|
7
|
my $self = shift; |
30
|
5
|
|
|
|
|
7
|
LINE: for (;;) { |
31
|
10
|
|
|
|
|
102
|
my $line = $self->fh->getline; |
32
|
10
|
50
|
|
|
|
390
|
return undef unless $line; |
33
|
10
|
100
|
|
|
|
36
|
next if $line =~ /^#/; |
34
|
5
|
50
|
|
|
|
18
|
next unless $line =~ /\S/; |
35
|
5
|
|
|
|
|
10
|
chomp($line); |
36
|
5
|
|
|
|
|
29
|
my $csv = new Text::CSV(); |
37
|
5
|
50
|
|
|
|
370
|
unless ($csv->parse($line)) { |
38
|
0
|
|
|
|
|
0
|
warn "Failed to parse CSV line $line"; |
39
|
0
|
|
|
|
|
0
|
next LINE; |
40
|
|
|
|
|
|
|
} |
41
|
5
|
|
|
|
|
1177
|
my @fields = $csv->fields(); |
42
|
|
|
|
|
|
|
# guess_identity_type does validation, and |
43
|
|
|
|
|
|
|
# the wrapper checks that the record type matches |
44
|
|
|
|
|
|
|
# the stream type, so no further validation is required |
45
|
|
|
|
|
|
|
# here. XXX It would be faster to fix the type here from |
46
|
|
|
|
|
|
|
# $type, and do a single regex to check it. |
47
|
5
|
|
|
|
|
42
|
return new Mail::Karmasphere::Parser::Record( |
48
|
|
|
|
|
|
|
s => 0, |
49
|
|
|
|
|
|
|
i => $fields[0], |
50
|
|
|
|
|
|
|
v => _value($fields[1]), |
51
|
|
|
|
|
|
|
d => $fields[2], |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |