line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Access::AdHoc::Util; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
16082
|
use 5.008; |
|
7
|
|
|
|
|
22
|
|
|
7
|
|
|
|
|
265
|
|
4
|
|
|
|
|
|
|
|
5
|
7
|
|
|
7
|
|
32
|
use strict; |
|
7
|
|
|
|
|
9
|
|
|
7
|
|
|
|
|
238
|
|
6
|
7
|
|
|
7
|
|
46
|
use warnings; |
|
7
|
|
|
|
|
24
|
|
|
7
|
|
|
|
|
212
|
|
7
|
|
|
|
|
|
|
|
8
|
7
|
|
|
7
|
|
35
|
use base qw{ Exporter }; |
|
7
|
|
|
|
|
8
|
|
|
7
|
|
|
|
|
981
|
|
9
|
|
|
|
|
|
|
|
10
|
7
|
|
|
7
|
|
3676
|
use LWP::MediaTypes (); |
|
7
|
|
|
|
|
78106
|
|
|
7
|
|
|
|
|
5658
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw{ |
13
|
|
|
|
|
|
|
__attr __cache __expand_distribution_path __guess_media_type |
14
|
|
|
|
|
|
|
__load __whinge __wail __weep |
15
|
|
|
|
|
|
|
}; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
18
|
|
|
|
|
|
|
all => [ @EXPORT_OK ], |
19
|
|
|
|
|
|
|
carp => [ qw{ __whinge __wail __weep } ], |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.000_194'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub __attr { |
25
|
438
|
|
|
438
|
|
402
|
my ( $self ) = @_; |
26
|
438
|
|
|
|
|
549
|
my $name_space = caller; |
27
|
438
|
|
100
|
|
|
1377
|
return ( $self->{$name_space} ||= {} ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub __cache { |
31
|
19
|
|
|
19
|
|
26
|
my ( $self ) = @_; |
32
|
19
|
|
|
|
|
41
|
my $name_space = caller; |
33
|
19
|
|
100
|
|
|
99
|
return ( $self->{'.cache'}{$name_space} ||= {} ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub __expand_distribution_path { |
37
|
17
|
|
|
17
|
|
28
|
my ( $path ) = @_; |
38
|
17
|
100
|
|
|
|
76
|
$path =~ m{ \A ( [^/] ) / ( \1 [^/] ) / ( \2 [^/]* ) }smx |
39
|
|
|
|
|
|
|
and return $path; |
40
|
14
|
50
|
|
|
|
35
|
$path =~ m< \A ( [^/]{2} ) / ( \1 [^/]* ) >smx |
41
|
|
|
|
|
|
|
and return join '/', substr( $1, 0, 1 ), $path; |
42
|
14
|
50
|
|
|
|
59
|
$path =~ m< \A ( [^/]+ ) >smx |
43
|
|
|
|
|
|
|
or __wail( "Invalid distribution path '$path'" ); |
44
|
14
|
|
|
|
|
79
|
return join '/', substr( $1, 0, 1 ), |
45
|
|
|
|
|
|
|
substr( $1, 0, 2 ), $path; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
{ |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my %expand_ending = ( |
51
|
|
|
|
|
|
|
tbz => 'tar.bz2', |
52
|
|
|
|
|
|
|
tgz => 'tar.gz', |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub __guess_media_type { |
56
|
53
|
|
|
53
|
|
7612
|
my ( $resp, $path ) = @_; |
57
|
|
|
|
|
|
|
|
58
|
53
|
50
|
|
|
|
146
|
if ( defined $path ) { |
59
|
53
|
|
|
|
|
150
|
$resp->header( 'Content-Location' => $path ); |
60
|
|
|
|
|
|
|
} else { |
61
|
0
|
0
|
|
|
|
0
|
defined( $path = $resp->header( 'Content-Location' ) ) |
62
|
|
|
|
|
|
|
or __wail( |
63
|
|
|
|
|
|
|
'No path provided, and none in Content-Location' ); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# LWP::MediaTypes needs help with some paths. |
67
|
53
|
|
|
|
|
2604
|
$path =~ s{ (?<= [.] ) ( [^.]+ ) \z } |
68
|
49
|
100
|
|
|
|
263
|
{ $expand_ending{$1} || $1 }smxie; |
69
|
|
|
|
|
|
|
|
70
|
53
|
|
|
|
|
164
|
LWP::MediaTypes::guess_media_type( $path, $resp ); |
71
|
|
|
|
|
|
|
|
72
|
53
|
|
|
|
|
5812
|
return; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub __load { |
78
|
17
|
|
|
17
|
|
555
|
my ( @args ) = @_; |
79
|
17
|
|
|
|
|
35
|
foreach my $module ( @args ) { |
80
|
|
|
|
|
|
|
|
81
|
17
|
100
|
|
|
|
139
|
$module =~ m< \A |
82
|
|
|
|
|
|
|
[[:alpha:]_] \w* |
83
|
|
|
|
|
|
|
(?: :: [[:alpha:]_] \w* )* \z |
84
|
|
|
|
|
|
|
>smx |
85
|
|
|
|
|
|
|
or __wail( "Malformed module name '$module'" ); |
86
|
|
|
|
|
|
|
|
87
|
16
|
|
|
|
|
66
|
( my $fn = $module ) =~ s{ :: }{/}smxg; |
88
|
16
|
|
|
|
|
29
|
$fn .= '.pm'; |
89
|
16
|
|
|
|
|
5360
|
require $fn; |
90
|
|
|
|
|
|
|
} |
91
|
16
|
|
|
|
|
48
|
return; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
our @CARP_NOT = qw{ |
95
|
|
|
|
|
|
|
CPAN::Access::AdHoc |
96
|
|
|
|
|
|
|
CPAN::Access::AdHoc::Archive |
97
|
|
|
|
|
|
|
CPAN::Access::AdHoc::Archive::Null |
98
|
|
|
|
|
|
|
CPAN::Access::AdHoc::Archive::Tar |
99
|
|
|
|
|
|
|
CPAN::Access::AdHoc::Archive::Zip |
100
|
|
|
|
|
|
|
}; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub __whinge { |
104
|
1
|
|
|
1
|
|
711
|
my @args = @_; |
105
|
1
|
|
|
|
|
13
|
require Carp; |
106
|
1
|
|
|
|
|
222
|
Carp::carp( @args ); |
107
|
1
|
|
|
|
|
5
|
return; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub __wail { |
111
|
15
|
|
|
15
|
|
786
|
my @args = @_; |
112
|
15
|
|
|
|
|
81
|
require Carp; |
113
|
15
|
|
|
|
|
1871
|
Carp::croak( @args ); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub __weep { |
117
|
7
|
|
|
7
|
|
427
|
my @args = @_; |
118
|
7
|
|
|
|
|
31
|
require Carp; |
119
|
7
|
|
|
|
|
1079
|
Carp::confess( 'Programming Error - ', @args ); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
__END__ |