File Coverage

blib/lib/Net/CLI/Interact/Role/FindMatch.pm
Criterion Covered Total %
statement 6 12 50.0
branch 0 4 0.0
condition n/a
subroutine 2 4 50.0
pod 0 1 0.0
total 8 21 38.1


line stmt bran cond sub pod time code
1             package Net::CLI::Interact::Role::FindMatch;
2             { $Net::CLI::Interact::Role::FindMatch::VERSION = '2.400000' }
3              
4 1     1   652 use Moo::Role;
  1         3  
  1         6  
5              
6             # see if any regexp in the arrayref match the response
7             sub find_match {
8 0     0 0   my ($self, $text, $matches) = @_;
9 0 0         $matches = ((ref $matches eq ref qr//) ? [$matches] : $matches);
10             return undef unless
11 0 0         (scalar grep {ref $_ eq ref qr//} @$matches) == scalar @$matches;
  0            
12              
13 1     1   470 use List::Util 'first';
  1         3  
  1         172  
14 0     0     return first { $text =~ $_ } @$matches;
  0            
15             }
16              
17             1;