DDG/Block/Regexp.pm

filter: Statementstmt 100% 32 / 32 Branchbran 66.6% 4 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 3 / 3 Podpod 50.0% 1 / 2 totaltotal 85.4% 41 / 48 CC 10 SCAR 18.3
CC
10
Cov
90%
request
8.1
parse_trigger
3.0
BEGIN
1.0
CRAP 6.3
« DDG/Meta/ShareDir.pm ↑ Summary DDG/Test/Spice.pm »
1 package DDG::Block::Regexp;
2 7 our $AUTHORITY = 'cpan:DDG';
3 # ABSTRACT: Block implementation to handle regexp based plugins
4 7 $DDG::Block::Regexp::VERSION = '1017';
5 9 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 with qw( DDG::Block );
7  
8  
9 sub parse_trigger {
10 3 ▶ my ( $self, $triggers ) = @_;
Subroutine parse_trigger: called CC=3 SCAR=11.0
Pod documented
11 3 for my $key (keys %{$triggers}) {
12 my @triggers = map {
13 5 ▶ ref $_ eq 'Regexp' ? $_ : qr{$_};
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'Regexp' ? : 5 0 5
14 3 } @{$triggers->{$key}};
15 3 $triggers->{$key} = \@triggers;
16 }
17 3 return $triggers;
18 }
19  
20 sub request {
21 21 ▶ my ( $self, $request ) = @_;
Subroutine request: called CC=8 SCAR=20.9
Pod undocumented
22 21 my @results;
23 21 for (@{$self->plugin_objs}) {
24 22 my $triggers = $_->[0];
25 22 my $plugin = $_->[1];
26 22 for my $trigger (@{$triggers}) {
27 22 for my $attr (keys %{$trigger}) {
28 22 for (@{$trigger->{$attr}}) {
29 23 ▶ if ( my @matches = $request->$attr =~ m/$_/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@matches) = $request->$attr =~ /$_/i) { } 4 19 23
30 4 push @results, $self->handle_request_matches($plugin,$request,@matches);
31 4 ▶ return @results if $self->return_one && @results;
Branch: 1 branch
BranchTrueFalseTotal
if $self->return_one and @results 4 0 4
Condition33%1/3
$self->return_one and @results
!ll&&!rl&&r
004
MC/DC0%0/2
$self->return_one and @results
$self->return_one @results
Truth table33%1/3
A and B
A= $self->return_oneB= @results
ABresult
0X0
100
111
32 } else {
33 19 $self->trace("No match with",ref $plugin);
34 }
35 }
36 }
37 }
38 }
39 17 return @results;
40 }
41  
42 7 1;
43  
44 __END__
« DDG/Meta/ShareDir.pm ↑ Summary DDG/Test/Spice.pm »