File Coverage

blib/lib/exact/me.pm
Criterion Covered Total %
statement 32 34 94.1
branch 6 8 75.0
condition 1 3 33.3
subroutine 8 8 100.0
pod 1 1 100.0
total 48 54 88.8


line stmt bran cond sub pod time code
1             package exact::me;
2             # ABSTRACT: Original program path locations extension for exact
3              
4 1     1   193637 use 5.014;
  1         8  
5 1     1   3 use exact;
  1         2  
  1         7  
6 1     1   461 use strict;
  1         2  
  1         15  
7 1     1   351 use FindBin;
  1         774  
  1         78  
8              
9             our $VERSION = '1.04'; # VERSION
10              
11             sub import {
12 1     1   8 my ( $self, $caller ) = @_;
13 1   33     3 $caller //= caller();
14              
15             {
16 1     1   6 no strict 'refs';
  1         1  
  1         313  
  1         2  
17 1 50       1 *{ $caller . '::me' } = \&me unless ( defined &{ $caller . '::me' } );
  1         4  
  1         6  
18             }
19             }
20              
21             sub me {
22 3     3 1 4561 my ($path) = @_;
23              
24 3 100       9 unless ($path) {
    100          
25 1         2 return $FindBin::Bin;
26             }
27 0         0 elsif ( index( $path, '.', 0 ) == 0 ) {
28 1         4 return $FindBin::Bin . '/' . $path;
29             }
30             else {
31 1         2 return _find_dir($path);
32             }
33              
34 0         0 return;
35             }
36              
37             sub _find_dir {
38 1     1   2 my ($suffix) = @_;
39              
40 1         5 my @search_path = split( '/', $FindBin::Bin );
41 1         3 while ( @search_path > 0 ) {
42 6         11 my $dir = join( '/', @search_path, $suffix );
43 6 50       117 return $dir if ( -d $dir );
44 6         17 pop @search_path;
45             }
46              
47 1         10 return;
48             }
49              
50             1;
51              
52             __END__