File Coverage

blib/lib/Module/Install/Admin/Find.pm
Criterion Covered Total %
statement 14 52 26.9
branch 0 26 0.0
condition 0 6 0.0
subroutine 5 9 55.5
pod 0 4 0.0
total 19 97 19.5


line stmt bran cond sub pod time code
1             package Module::Install::Admin::Find;
2              
3 1     1   957 use strict;
  1         1  
  1         23  
4 1     1   4 use File::Find ();
  1         2  
  1         8  
5 1     1   8 use Module::Install::Base ();
  1         1  
  1         17  
6 1     1   4 use vars qw{$VERSION @ISA};
  1         1  
  1         46  
7             BEGIN {
8 1     1   1 $VERSION = '1.18';
9 1         523 @ISA = qw(Module::Install::Base);
10             }
11              
12             sub find_extensions {
13 0     0 0   my $self = shift;
14 0           $self->_top->find_extensions(@_);
15             }
16              
17             sub find_in_inc {
18 0     0 0   my ($self, $pkg) = @_;
19              
20 0 0         unless ($pkg =~ /\.pm$/) {
21 0           $pkg =~ s!::!/!g;
22 0           $pkg = "$pkg.pm";
23             }
24              
25 0           my @found;
26 0           foreach my $inc (@INC) {
27 0 0 0       next if $inc eq $self->_top->{prefix} or ref($inc);
28 0 0         push @found, "$inc/$pkg" if -f "$inc/$pkg";
29             }
30              
31 0 0         wantarray ? @found : $found[0];
32             }
33              
34             sub glob_in_inc {
35 0     0 0   my ($self, $pkg) = @_;
36              
37 0 0         unless ($pkg =~ /\.pm$/) {
38 0           $pkg =~ s!::!/!g;
39 0           $pkg = "$pkg.pm";
40             }
41              
42 0           my @found;
43 0           foreach my $inc (@INC) {
44 0 0 0       next if $inc eq $self->_top->{prefix} or ref($inc);
45             push @found, [ do {
46 0           my $p = $_;
47 0           $p =~ s!^\Q$inc\E/!!;
48 0           $p =~ s!/!::!g;
49 0           $p =~ s!\.pm\Z!!gi;
50 0           $p
51 0           }, $_ ] for grep -e, glob("$inc/$pkg");
52             }
53              
54 0 0         wantarray ? @found : $found[0];
55             }
56              
57             sub find_files {
58 0     0 0   my ($self, $file, $path) = @_;
59 0 0         $path = '' if not defined $path;
60 0 0         $file = "$path/$file" if length($path);
61 0 0         if (-f $file) {
    0          
62 0           return ($file);
63             }
64             elsif (-d $file) {
65 0           my @files = ();
66 0           local *DIR;
67 0 0         opendir(DIR, $file) or die "Can't opendir $file";
68 0           while (my $new_file = readdir(DIR)) {
69 0 0         next if $new_file =~ /^(\.|\.\.)$/;
70 0           push @files, $self->find_files($new_file, $file);
71             }
72 0           return @files;
73             }
74 0           return ();
75             }
76              
77             1;