line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package VS::RuleEngine::Rule::InputMatchesRegexp; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1008
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use VS::RuleEngine::Constants; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
78
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use base qw(VS::RuleEngine::Rule); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
321
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
4
|
|
|
4
|
1
|
10
|
my ($pkg, %args) = @_; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Compile regexps |
14
|
4
|
|
|
|
|
9
|
my %re; |
15
|
4
|
|
|
|
|
14
|
while (my ($input, $re) = each %args) { |
16
|
6
|
|
|
|
|
22
|
$re{$input} = $re; |
17
|
|
|
|
|
|
|
} |
18
|
4
|
|
|
|
|
20
|
my $self = bless { %re }, $pkg; |
19
|
|
|
|
|
|
|
|
20
|
4
|
|
|
|
|
18
|
return $self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub evaluate { |
24
|
4
|
|
|
4
|
1
|
8
|
my ($self, $input) = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# If we have nothing to match aginst it's a no match |
27
|
4
|
50
|
|
|
|
5
|
return KV_NO_MATCH unless %{$self}; |
|
4
|
|
|
|
|
18
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# The order we evaulate each change in is not relevant |
30
|
4
|
|
|
|
|
7
|
for my $key (keys %{$self}) { |
|
4
|
|
|
|
|
13
|
|
31
|
5
|
|
|
|
|
14
|
my $v1 = $input->get($key); |
32
|
5
|
|
|
|
|
9
|
my $re = $self->{$key}; |
33
|
|
|
|
|
|
|
|
34
|
5
|
100
|
|
|
|
69
|
if ($v1 !~ $re) { |
35
|
2
|
|
|
|
|
16
|
return KV_NO_MATCH; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# All thresholds passed therefore we have a match |
40
|
2
|
|
|
|
|
7
|
return KV_MATCH; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
__END__ |