blib/lib/require/relative.pm

filter: Statementstmt 100% 18 / 18 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 92.3% 24 / 26 CC 4 SCAR 10.2
CC
4
Cov
91%
import
4.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.8
↑ Summary
1  
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package require::relative;
6 2 $require::relative::VERSION = '1.0.1';
7 2 ▶use Path::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶sub import {
Subroutine import: called CC=4 SCAR=14.1
10 2 my ($class, @paths) = @_;
11 2 my ($package, $file) = (caller)[0, 1];
12  
13 2 ▶ my $dir = -e $file
Branch: 1 branch
BranchTrueFalseTotal
-e $file ? : 2 0 2
14 ? Path::Tiny->new ($file)->absolute->parent
15 : Path::Tiny->cwd
16 ;
17  
18 2 for my $path (@paths) {
19 2 my $real_path = Path::Tiny->new ($path)->absolute ($dir);
20  
21 2 eval "package $package; require q[$real_path];";
22 2 ▶ die if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 2 2
23 }
24 }
25  
26 2 1;
27  
28 __END__
↑ Summary