File Coverage

blib/lib/File/Share.pm
Criterion Covered Total %
statement 18 32 56.2
branch 0 2 0.0
condition 0 8 0.0
subroutine 6 10 60.0
pod 0 4 0.0
total 24 56 42.8


line stmt bran cond sub pod time code
1 1     1   1016 use strict; use warnings;
  1     1   2  
  1         32  
  1         4  
  1         1  
  1         53  
2             package File::Share;
3             our $VERSION = '0.25';
4              
5 1     1   14 use base 'Exporter';
  1         1  
  1         140  
6             our @EXPORT_OK = qw[
7             dist_dir
8             dist_file
9             module_dir
10             module_file
11             class_dir
12             class_file
13             ];
14             our %EXPORT_TAGS = (
15             all => [ @EXPORT_OK ],
16             ALL => [ @EXPORT_OK ],
17             );
18              
19 1     1   927 use File::ShareDir();
  1         7383  
  1         27  
20 1     1   8 use Cwd qw[abs_path];
  1         2  
  1         55  
21 1     1   5 use File::Spec();
  1         2  
  1         214  
22              
23             sub dist_dir {
24 0     0 0   my ($dist) = @_;
25 0           (my $inc = $dist) =~ s!(-|::)!/!g;
26 0           $inc .= '.pm';
27 0   0       my $path = $INC{$inc} || '';
28 0           $path =~ s/$inc$//;
29 0           $path = Cwd::realpath( File::Spec->catfile($path,'..') );
30 0 0 0       if ($path and
      0        
31             -d "$path/lib" and
32             -e "$path/share"
33             ) {
34 0           return abs_path "$path/share";
35             }
36             else {
37 0           return File::ShareDir::dist_dir($dist);
38             }
39             }
40              
41             sub dist_file {
42 0     0 0   my ($dist, $file) = @_;
43 0           my $dir = dist_dir($dist);
44 0           return File::Spec->catfile( $dir, $file );
45             }
46              
47             sub module_dir {
48 0     0 0   die "File::Share::module_dir not yet supported";
49             }
50              
51             sub module_file {
52 0     0 0   die "File::Share::module_file not yet supported";
53             }
54              
55             1;