File Coverage

blib/lib/require/relative.pm
Criterion Covered Total %
statement 16 16 100.0
branch 2 4 50.0
condition n/a
subroutine 4 4 100.0
pod n/a
total 22 24 91.6


line stmt bran cond sub pod time code
1              
2 2     2   942 use strict;
  2         10  
  2         60  
3 2     2   10 use warnings;
  2         3  
  2         84  
4              
5             package require::relative;
6             $require::relative::VERSION = '1.0.0';
7 2     2   1680 use Path::Tiny ();
  2         32448  
  2         299  
8              
9             sub import {
10 2     2   24 my ($class, @paths) = @_;
11 2         8 my ($package, $file) = (caller)[0, 1];
12              
13 2 50       80 my $dir = -e $file
14             ? Path::Tiny->new ($file)->absolute->parent
15             : Path::Tiny->cwd
16             ;
17              
18 2         488 for my $path (@paths) {
19 2         8 my $real_path = Path::Tiny->new ($path)->absolute ($dir);
20              
21 2         239 eval "package $package; require q[$real_path];";
22 2 50       299 die if $@;
23             }
24             }
25              
26             1;
27              
28             __END__