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.400002';
3 1     1   606 use Moo::Role;
  1         3  
  1         6  
4              
5             # see if any regexp in the arrayref match the response
6             sub find_match {
7 0     0 0   my ($self, $text, $matches) = @_;
8 0 0         $matches = ((ref $matches eq ref qr//) ? [$matches] : $matches);
9             return unless
10 0 0         (scalar grep {ref $_ eq ref qr//} @$matches) == scalar @$matches;
  0            
11              
12 1     1   414 use List::Util 'first';
  1         2  
  1         130  
13 0     0     return first { $text =~ $_ } @$matches;
  0            
14             }
15              
16             =pod
17              
18             =for Pod::Coverage find_match
19              
20             =cut
21              
22             1;