| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package File::ShareDir::Dist; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
70271
|
use strict; |
|
|
2
|
|
|
|
|
16
|
|
|
|
2
|
|
|
|
|
58
|
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
15
|
|
|
|
2
|
|
|
|
|
59
|
|
|
5
|
2
|
|
|
2
|
|
36
|
use 5.008001; |
|
|
2
|
|
|
|
|
7
|
|
|
6
|
2
|
|
|
2
|
|
12
|
use base qw( Exporter ); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
254
|
|
|
7
|
2
|
|
|
2
|
|
11
|
use File::Spec; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
1379
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT_OK = qw( dist_share dist_config ); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Locate per-dist shared files |
|
12
|
|
|
|
|
|
|
our $VERSION = '0.07'; # VERSION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# TODO: Works with PAR |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our %over; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub dist_share ($) |
|
20
|
|
|
|
|
|
|
{ |
|
21
|
14
|
|
|
14
|
1
|
35503
|
my($dist_name) = @_; |
|
22
|
|
|
|
|
|
|
|
|
23
|
14
|
|
|
|
|
37
|
$dist_name =~ s/::/-/g; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
local $over{$1} = $2 |
|
26
|
14
|
100
|
66
|
|
|
68
|
if defined $ENV{PERL_FILE_SHAREDIR_DIST} && $ENV{PERL_FILE_SHAREDIR_DIST} =~ /^(.*?)=(.*)$/; |
|
27
|
|
|
|
|
|
|
|
|
28
|
14
|
100
|
|
|
|
102
|
return File::Spec->rel2abs($over{$dist_name}) if $over{$dist_name}; |
|
29
|
|
|
|
|
|
|
|
|
30
|
11
|
|
|
|
|
38
|
my @pm = split /-/, $dist_name; |
|
31
|
11
|
|
|
|
|
20
|
$pm[-1] .= ".pm"; |
|
32
|
|
|
|
|
|
|
|
|
33
|
11
|
|
|
|
|
23
|
foreach my $inc (@INC) |
|
34
|
|
|
|
|
|
|
{ |
|
35
|
12
|
|
|
|
|
94
|
my $pm = File::Spec->catfile( $inc, @pm ); |
|
36
|
12
|
100
|
|
|
|
271
|
if(-f $pm) |
|
37
|
|
|
|
|
|
|
{ |
|
38
|
7
|
|
|
|
|
61
|
my $share = File::Spec->catdir( $inc, qw( auto share dist ), $dist_name ); |
|
39
|
7
|
100
|
|
|
|
158
|
if(-d $share) |
|
40
|
|
|
|
|
|
|
{ |
|
41
|
5
|
|
|
|
|
71
|
return File::Spec->rel2abs($share); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
2
|
50
|
|
|
|
19
|
if(!File::Spec->file_name_is_absolute($inc)) |
|
45
|
|
|
|
|
|
|
{ |
|
46
|
2
|
|
|
|
|
56
|
my($v,$dir) = File::Spec->splitpath( File::Spec->rel2abs($inc), 1 ); |
|
47
|
2
|
|
|
|
|
19
|
my @dirs = File::Spec->splitdir($dir); |
|
48
|
2
|
50
|
33
|
|
|
16
|
if(defined $dirs[-1] && $dirs[-1] eq 'lib') |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
2
|
|
|
|
|
5
|
pop @dirs; # pop off the 'lib'; |
|
51
|
|
|
|
|
|
|
# put humpty dumpty back together again |
|
52
|
2
|
|
|
|
|
27
|
my $share = File::Spec->catdir( |
|
53
|
|
|
|
|
|
|
File::Spec->catpath($v, |
|
54
|
|
|
|
|
|
|
File::Spec->catdir(@dirs), |
|
55
|
|
|
|
|
|
|
'', |
|
56
|
|
|
|
|
|
|
), |
|
57
|
|
|
|
|
|
|
'share', |
|
58
|
|
|
|
|
|
|
); |
|
59
|
|
|
|
|
|
|
|
|
60
|
2
|
100
|
|
|
|
45
|
if(-d $share) |
|
61
|
|
|
|
|
|
|
{ |
|
62
|
1
|
|
|
|
|
9
|
return $share; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
1
|
|
|
|
|
3
|
last; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
5
|
|
|
|
|
22
|
return; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub dist_config |
|
76
|
|
|
|
|
|
|
{ |
|
77
|
4
|
|
|
4
|
1
|
13884
|
my($dist_name) = @_; |
|
78
|
4
|
|
|
|
|
10
|
my $dir = dist_share $dist_name; |
|
79
|
4
|
100
|
66
|
|
|
54
|
return {} unless defined $dir && -d $dir; |
|
80
|
2
|
|
|
|
|
21
|
my $fn = File::Spec->catfile($dir, 'config.pl'); |
|
81
|
2
|
100
|
|
|
|
48
|
return {} unless -f $fn; |
|
82
|
1
|
|
|
|
|
4
|
my $fh; |
|
83
|
1
|
50
|
|
|
|
46
|
open($fh, '<', $fn) || die "unable to read $fn $!"; |
|
84
|
1
|
|
|
|
|
5
|
my $pl = do { local $/; <$fh> }; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
27
|
|
|
85
|
1
|
|
|
|
|
11
|
close $fh; |
|
86
|
1
|
|
|
|
|
90
|
my $config = eval $pl; |
|
87
|
1
|
50
|
|
|
|
6
|
die $@ if $@; |
|
88
|
1
|
|
|
|
|
9
|
$config; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub import |
|
92
|
|
|
|
|
|
|
{ |
|
93
|
2
|
|
|
2
|
|
4114
|
my($class, @args) = @_; |
|
94
|
|
|
|
|
|
|
|
|
95
|
2
|
|
|
|
|
4
|
my @modify; |
|
96
|
|
|
|
|
|
|
|
|
97
|
2
|
|
|
|
|
6
|
foreach my $arg (@args) |
|
98
|
|
|
|
|
|
|
{ |
|
99
|
3
|
100
|
|
|
|
16
|
if($arg =~ /^-(.*?)=(.*)$/) |
|
100
|
|
|
|
|
|
|
{ |
|
101
|
1
|
|
|
|
|
5
|
$over{$1} = $2; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
else |
|
104
|
|
|
|
|
|
|
{ |
|
105
|
2
|
|
|
|
|
6
|
push @modify, $arg; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
2
|
|
|
|
|
5
|
@_ = ($class, @modify); |
|
110
|
|
|
|
|
|
|
|
|
111
|
2
|
|
|
|
|
3030
|
goto \&Exporter::import; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
__END__ |