File Coverage

blib/lib/rlib.pm
Criterion Covered Total %
statement 29 33 87.8
branch 5 6 83.3
condition n/a
subroutine 7 8 87.5
pod n/a
total 41 47 87.2


line stmt bran cond sub pod time code
1             package rlib;
2              
3 1     1   2977 use strict;
  1         3  
  1         47  
4 1     1   7 use vars qw($VERSION @ISA);
  1         2  
  1         64  
5 1     1   934 use lib ();
  1         849  
  1         27  
6 1     1   6 use File::Basename qw(dirname);
  1         2  
  1         256  
7 1     1   5 use File::Spec;
  1         2  
  1         312  
8              
9             $VERSION = "0.02";
10             @ISA = qw(lib);
11              
12             sub _dirs {
13 4     4   18 my($pkg,$file) = (caller(1))[0,1];
14 4 100       16 my @rel = @_ ? @_ : qw(../lib lib);
15 4         5 my $dir;
16              
17             # if called from package main then assume we were called
18             # by a script not a module
19              
20 4 100       10 if($pkg eq 'main') {
21 2         11 require FindBin;
22             # hide "used only once" warning
23 2         4 $dir = ($FindBin::Bin,$FindBin::Bin)[0];
24             }
25             else {
26 2         10 require Cwd;
27 2         132 $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         18 while($pkg =~ /::/g) {
34 1         32 $dir = dirname($dir);
35             }
36              
37 4 50       13 if($^O eq 'VMS') {
38 0         0 require VMS::Filespec;
39 0         0 @rel = map { VMS::Filespec::unixify($_) } @rel;
  0         0  
40             }
41              
42 4         8 map { File::Spec->catdir($dir,$_) } @rel;
  7         60  
43             }
44              
45             sub import {
46 4     4   1074 shift->SUPER::import( _dirs(@_) );
47             }
48              
49             sub unimport {
50 0     0     shift->SUPER::unimport( _dirs(@_) );
51             }
52              
53             1;
54              
55             __END__