line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package lib::relative::to::ParentContaining; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
1649
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
144
|
|
4
|
5
|
|
|
5
|
|
25
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
142
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
510
|
use parent 'lib::relative::to'; |
|
5
|
|
|
|
|
329
|
|
|
5
|
|
|
|
|
69
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
332
|
use File::Spec; |
|
5
|
|
|
|
|
19
|
|
|
5
|
|
|
|
|
161
|
|
9
|
5
|
|
|
5
|
|
26
|
use Cwd qw(abs_path); |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
1073
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub _find { |
12
|
4
|
|
|
4
|
|
12
|
my($class, $parent_contains, @args) = @_; |
13
|
4
|
|
|
|
|
8
|
my $caller = $lib::relative::to::called_from; |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
|
|
296
|
my $candidate = $class->parent_dir(abs_path($caller)); |
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
|
|
20
|
while($candidate) { |
18
|
12
|
|
|
|
|
62
|
my $target = File::Spec->catdir($candidate, $parent_contains); |
19
|
12
|
100
|
|
|
|
395
|
if(-e $target) { |
|
|
100
|
|
|
|
|
|
20
|
3
|
|
|
|
|
12
|
return map { File::Spec->catdir($candidate, $_) } @args |
|
3
|
|
|
|
|
41
|
|
21
|
|
|
|
|
|
|
} elsif($candidate eq $class->parent_dir($candidate)) { |
22
|
1
|
|
|
|
|
14
|
die(__PACKAGE__ . ": Couldn't _find $parent_contains in any parent directory of $caller\n"); |
23
|
|
|
|
|
|
|
} else { |
24
|
8
|
|
|
|
|
26
|
$candidate = $class->parent_dir($candidate); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
1; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 NAME |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
lib::relative::to:ParentContaining: |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 SYNOPSIS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
use lib::relative::to |
38
|
|
|
|
|
|
|
ParentContaining => 'MANIFEST', qw(lib t/lib); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 DESCRIPTION |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
A plugin for L for finding a parent (or grandparent, or ...) directory which contains some particular file or directory and then adding some directories under it to C<@INC>. It is a fatal error to not find a suitable parent directory. |