| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package lib::root; |
|
2
|
2
|
|
|
2
|
|
652322
|
use strict; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
90
|
|
|
3
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
141
|
|
|
4
|
2
|
|
|
2
|
|
61683
|
use Path::Tiny; |
|
|
2
|
|
|
|
|
16511
|
|
|
|
2
|
|
|
|
|
155
|
|
|
5
|
2
|
|
|
2
|
|
14
|
use Cwd; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
1255
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = "0.10"; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $root; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub import |
|
12
|
|
|
|
|
|
|
{ |
|
13
|
8
|
|
|
8
|
|
22664
|
my ( $package, %args ) = @_; |
|
14
|
8
|
|
100
|
|
|
47
|
my $rootfile = $args{ rootfile } || '.libroot'; |
|
15
|
8
|
|
|
|
|
18
|
my $callback = $args{ callback }; |
|
16
|
8
|
|
|
|
|
17
|
my $perldir = $args{ perldir }; |
|
17
|
8
|
|
|
|
|
356
|
my $caller_file = Cwd::realpath( ( caller )[ 1 ] ); |
|
18
|
|
|
|
|
|
|
|
|
19
|
8
|
100
|
|
|
|
74
|
if ( $ENV{ LIBROOT_TEST_MODE } ) |
|
20
|
|
|
|
|
|
|
{ |
|
21
|
7
|
|
|
|
|
16
|
$caller_file = $args{ caller_file }; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
8
|
|
|
|
|
35
|
my $path = path( $caller_file )->parent; |
|
25
|
|
|
|
|
|
|
|
|
26
|
8
|
|
|
|
|
852
|
$path = $path->realpath->absolute; |
|
27
|
8
|
|
|
|
|
2373
|
my $found; |
|
28
|
|
|
|
|
|
|
my $lib_paths; |
|
29
|
|
|
|
|
|
|
|
|
30
|
8
|
|
|
|
|
22
|
my @children = grep { defined } ( $perldir, $rootfile ); |
|
|
16
|
|
|
|
|
47
|
|
|
31
|
8
|
|
66
|
|
|
45
|
while ( !$found && $path ne $path->rootdir ) |
|
32
|
|
|
|
|
|
|
{ |
|
33
|
26
|
100
|
66
|
|
|
2668
|
if ( -e $path->child( @children ) ) |
|
|
|
100
|
66
|
|
|
|
|
|
34
|
|
|
|
|
|
|
{ |
|
35
|
6
|
|
|
|
|
476
|
$found = $path->child( @children ); |
|
36
|
6
|
|
|
|
|
380
|
$lib_paths = $path->child( @children )->parent->child( '/*/lib' ); |
|
37
|
6
|
|
|
|
|
1091
|
last; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
elsif ( -e $path->child( $rootfile ) |
|
40
|
|
|
|
|
|
|
&& $perldir |
|
41
|
|
|
|
|
|
|
&& -d $path->child( $perldir ) ) |
|
42
|
|
|
|
|
|
|
{ |
|
43
|
1
|
|
|
|
|
279
|
$found = $path->child( $rootfile ); |
|
44
|
1
|
|
|
|
|
47
|
$lib_paths = $path->child( $perldir, '/*/lib' ); |
|
45
|
1
|
|
|
|
|
114
|
last; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
19
|
|
|
|
|
3023
|
$path = $path->parent; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
8
|
100
|
|
|
|
161
|
if ( $found ) |
|
52
|
|
|
|
|
|
|
{ |
|
53
|
7
|
|
|
|
|
24
|
$root = $found->parent; |
|
54
|
7
|
|
|
|
|
545
|
push @INC, glob $lib_paths; |
|
55
|
7
|
50
|
|
|
|
992
|
$callback->( $lib_paths, $found ) |
|
56
|
|
|
|
|
|
|
if $callback; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
else |
|
59
|
|
|
|
|
|
|
{ |
|
60
|
1
|
|
|
|
|
78
|
warn |
|
61
|
|
|
|
|
|
|
"lib::root error: Could not find rootfile [ $rootfile ]. lib::root loaded from [ $caller_file ]."; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub root |
|
66
|
|
|
|
|
|
|
{ |
|
67
|
7
|
|
|
7
|
1
|
7030
|
return $root; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub rootdir |
|
71
|
|
|
|
|
|
|
{ |
|
72
|
1
|
|
|
1
|
1
|
1085
|
return root(); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |