RuleEngine/Rule/InputMatchesRegexp.pm

filter: Statementstmt 100% 29 / 29 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 97.6% 42 / 43 CC 5 SCAR 8.8
CC
5
Cov
97%
evaluate
4.0
new
2.0
BEGIN
1.0
CRAP 2.4
« RuleEngine/Data.pm ↑ Summary RuleEngine/InputHandler.pm »
1 package VS::RuleEngine::Rule::InputMatchesRegexp;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use VS::RuleEngine::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use base qw(VS::RuleEngine::Rule);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
11 4 my ($pkg, %args) = @_;
12
13 # Compile regexps
14 4 my %re;
15 4 ▶ while (my ($input, $re) = each %args) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %args) 6 4 10
16 6 $re{$input} = $re;
17 }
18 4 my $self = bless { %re }, $pkg;
19
20 4 return $self;
21 }
22  
23 4 ▶sub evaluate {
Subroutine evaluate: called CC=4 SCAR=13.9
Pod documented
24 4 my ($self, $input) = @_;
25
26 # If we have nothing to match aginst it's a no match
27 4 ▶ return KV_NO_MATCH unless %{$self};
Branch: 1 branch
BranchTrueFalseTotal
unless %{$self;} 0 4 4
28
29 # The order we evaulate each change in is not relevant
30 4 for my $key (keys %{$self}) {
31 5 my $v1 = $input->get($key);
32 5 my $re = $self->{$key};
33
34 5 ▶ if ($v1 !~ $re) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($v1 =~ /$re/) 2 3 5
35 2 return KV_NO_MATCH;
36 }
37 }
38
39 # All thresholds passed therefore we have a match
40 2 return KV_MATCH;
41 }
42  
43 2 1;
44 __END__
« RuleEngine/Data.pm ↑ Summary RuleEngine/InputHandler.pm »