line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
375482
|
use strict; |
|
4
|
|
|
|
|
34
|
|
|
4
|
|
|
|
|
127
|
|
2
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
195
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package ful; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
21
|
use Cwd; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
238
|
|
9
|
4
|
|
|
4
|
|
33
|
use File::Spec; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
2348
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $cursor; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $FS = 'File::Spec'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $crum = undef; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub import { |
18
|
13
|
|
|
13
|
|
6116
|
my $me = shift; |
19
|
|
|
|
|
|
|
|
20
|
13
|
|
|
|
|
47
|
my @user = caller(); |
21
|
13
|
|
|
|
|
282
|
my $used_me = $user[1]; |
22
|
|
|
|
|
|
|
|
23
|
13
|
|
|
|
|
461
|
$cursor = Cwd::abs_path($used_me); |
24
|
|
|
|
|
|
|
|
25
|
13
|
|
|
|
|
39
|
my %args = (); |
26
|
13
|
|
|
|
|
22
|
my @libdirs = ('lib'); |
27
|
|
|
|
|
|
|
|
28
|
13
|
100
|
100
|
|
|
132
|
if (@_ && ref($_[0]) eq 'HASH') { |
|
|
100
|
|
|
|
|
|
29
|
9
|
|
|
|
|
15
|
%args = %{$_[0]}; |
|
9
|
|
|
|
|
38
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
elsif(@_) { |
32
|
2
|
|
|
|
|
6
|
@libdirs = @_; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
13
|
100
|
|
|
|
46
|
@libdirs = @{$args{libdirs}} if ref($args{libdirs}) eq 'ARRAY'; |
|
2
|
|
|
|
|
14
|
|
36
|
|
|
|
|
|
|
|
37
|
13
|
100
|
100
|
|
|
103
|
if (my $file = $args{file} // $args{target_file} // $args{target}) { |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
38
|
4
|
|
100
|
|
|
9
|
$me->_ascend until $me->_is_file($file) or $me->_heaven; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
elsif (my $dir = $args{dir} // $args{has_dir} // $args{child_dir}) { |
41
|
3
|
|
66
|
|
|
8
|
$me->_ascend until $me->_is_dir($dir) or $me->_heaven; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
elsif ($args{git}) { |
44
|
1
|
|
|
|
|
3
|
my @gitparts = qw(.git config); |
45
|
1
|
|
66
|
|
|
3
|
$me->_ascend until $me->_is_file(@gitparts) or $me->_heaven; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
else { |
48
|
5
|
|
|
|
|
16
|
while (!$me->_heaven) { |
49
|
18
|
100
|
|
|
|
41
|
last if scalar @libdirs == grep { $me->_is_dir($_) } @libdirs; |
|
32
|
|
|
|
|
79
|
|
50
|
15
|
|
|
|
|
49
|
$me->_ascend; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
13
|
100
|
|
|
|
48
|
return if $me->_heaven; |
55
|
7
|
|
|
|
|
16
|
$crum = $me->_comb($cursor); |
56
|
7
|
|
|
|
|
23
|
unshift @INC => $me->_comb($cursor, $_) for @libdirs; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
31
|
|
|
31
|
|
71
|
sub _is_file { -f shift->_comb($cursor, @_) } |
60
|
41
|
|
|
41
|
|
73
|
sub _is_dir { -d shift->_comb($cursor, @_) } |
61
|
88
|
|
|
88
|
|
6761
|
sub _comb { $FS->catfile(@_[1..$#_]) } |
62
|
|
|
|
|
|
|
|
63
|
47
|
|
|
47
|
|
767
|
sub _ascend { $cursor = $FS->catdir(($FS->splitpath($cursor))[0..1]) } |
64
|
69
|
|
|
69
|
|
462
|
sub _heaven { $cursor eq $FS->rootdir } |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |