DDG/Block/Regexp.pm

filter: Statementstmt 100% 15 / 15 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod 100% 1 / 1 totaltotal 95.0% 19 / 20 SCAR 11.0
CC
3
Cov
94%
parse_trigger
3.0
BEGIN
1.0
CRAP 3.0
« DDG/ZeroClickInfo/Spice/Data.pm ↑ Summary DDG/HasShareDir.pm »
1 package DDG::Block::Regexp;
2 9 our $AUTHORITY = 'cpan:DDG';
3 # ABSTRACT: Block implementation to handle regexp based plugins
4 9 $DDG::Block::Regexp::VERSION = '1016';
5 9 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 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 my ( $self, $request ) = @_;
22 my @results;
23 for (@{$self->plugin_objs}) {
24 my $triggers = $_->[0];
25 my $plugin = $_->[1];
26 for my $trigger (@{$triggers}) {
27 for my $attr (keys %{$trigger}) {
28 for (@{$trigger->{$attr}}) {
29 if ( my @matches = $request->$attr =~ m/$_/ ) {
30 push @results, $self->handle_request_matches($plugin,$request,@matches);
31 return @results if $self->return_one && @results;
32 } else {
33 $self->trace("No match with",ref $plugin);
34 }
35 }
36 }
37 }
38 }
39 return @results;
40 }
41  
42 9 1;
43  
44 __END__
« DDG/ZeroClickInfo/Spice/Data.pm ↑ Summary DDG/HasShareDir.pm »