blib/lib/rlib.pm

filter: Statementstmt 88.8% 32 / 36 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod n/a totaltotal 88.4% 46 / 52 CC 5 SCAR 10.3
CC
5
Cov
89%
_dirs
5.1
unimport
2.0
BEGIN
1.0
CRAP 2.8
↑ Summary
1 package rlib;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use vars qw($VERSION @ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use lib ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use File::Basename qw(dirname);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 $VERSION = "0.02";
10 1 @ISA = qw(lib);
11  
12 4 ▶sub _dirs {
Subroutine _dirs: called CC=5 SCAR=16.3
13 4 my($pkg,$file) = (caller(1))[0,1];
14 4 ▶ my @rel = @_ ? @_ : qw(../lib lib);
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 1 3 4
15 4 my $dir;
16  
17 # if called from package main then assume we were called
18 # by a script not a module
19  
20 4 ▶ if($pkg eq 'main') {
Branch: 1 branch
BranchTrueFalseTotal
if ($pkg eq 'main') { } 2 2 4
21 2 require FindBin;
22 # hide "used only once" warning
23 2 $dir = ($FindBin::Bin,$FindBin::Bin)[0];
24 }
25 else {
26 2 require Cwd;
27 2 $dir = Cwd::abs_path(dirname($file));
28 }
29  
30 # If we were called by a package then traverse upwards
31 # to root of lib
32  
33 4 ▶ while($pkg =~ /::/g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pkg =~ /::/g) 1 4 5
34 1 $dir = dirname($dir);
35 }
36  
37 4 ▶ if($^O eq 'VMS') {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "VMS") 0 4 4
38 0 require VMS::Filespec;
39 0 @rel = map { VMS::Filespec::unixify($_) } @rel;
40 }
41  
42 4 map { File::Spec->catdir($dir,$_) } @rel;
43 }
44  
45 4 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
46 4 shift->SUPER::import( _dirs(@_) );
47 }
48  
49 0 ▶sub unimport {
Subroutine unimport: not called CC=1 SCAR=6.9
50 0 shift->SUPER::unimport( _dirs(@_) );
51 }
52  
53 1 1;
54  
55 __END__
↑ Summary