File Coverage

blib/lib/App/authkeymgr.pm
Criterion Covered Total %
statement 18 34 52.9
branch 0 16 0.0
condition 0 7 0.0
subroutine 6 8 75.0
pod 0 1 0.0
total 24 66 36.3


line stmt bran cond sub pod time code
1             package App::authkeymgr;
2             our $VERSION = '0.011';
3              
4 1     1   53622 use 5.10.1;
  1         5  
  1         207  
5 1     1   6 use strict;
  1         1  
  1         35  
6 1     1   5 use warnings;
  1         6  
  1         35  
7              
8 1     1   6 use Carp;
  1         2  
  1         240  
9              
10 1     1   5 use File::Find;
  1         2  
  1         60  
11 1     1   4 use File::Spec;
  1         2  
  1         505  
12              
13             sub findkeys {
14 0     0 0   my ($keydir, $exts, $nodeep) = @_;
15            
16 0 0         croak "findkeys called with no keydir"
17             unless defined $keydir;
18            
19 0 0         croak "findkeys called against non-directory $keydir"
20             unless -d $keydir;
21            
22 0 0 0       $exts = [ qw/pub pubkey/ ]
23             unless $exts and ref $exts eq 'ARRAY';
24              
25 0           my @found;
26 0 0         if ($nodeep) {
27 0 0         opendir(my $dirh, $keydir) || croak "opendir failed: $!";
28 0           while (my $maybekey = readdir($dirh)) {
29 0 0         next if index($maybekey, '.') == 0;
30 0   0       my $thisext = (split /\./, $maybekey)[-1] // next;
31 0 0         push(@found, File::Spec->catfile($keydir, $maybekey))
32             if $thisext ~~ @$exts;
33             }
34 0           closedir($dirh);
35             } else {
36             find(sub {
37 0   0 0     my $thisext = (split /\./)[-1] // return;
38 0 0         push(@found, $File::Find::name)
39             if $thisext ~~ @$exts;
40             },
41 0           $keydir
42             );
43             }
44            
45             return @found
46 0           }
47              
48              
49             1;
50             __END__