| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perl::Dist::Asset; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Convenience base class for Perl::Dist assets |
|
4
|
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
3015
|
use 5.006; |
|
|
3
|
|
|
|
|
23
|
|
|
|
3
|
|
|
|
|
123
|
|
|
6
|
3
|
|
|
3
|
|
20
|
use strict; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
106
|
|
|
7
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
110
|
|
|
8
|
3
|
|
|
3
|
|
16
|
use Carp 'croak'; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
166
|
|
|
9
|
3
|
|
|
3
|
|
14
|
use File::Spec (); |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
44
|
|
|
10
|
3
|
|
|
3
|
|
14
|
use File::Spec::Unix (); |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
66
|
|
|
11
|
3
|
|
|
3
|
|
1743
|
use File::ShareDir (); |
|
|
3
|
|
|
|
|
14893
|
|
|
|
3
|
|
|
|
|
61
|
|
|
12
|
3
|
|
|
3
|
|
3178
|
use URI::file (); |
|
|
3
|
|
|
|
|
20462
|
|
|
|
3
|
|
|
|
|
75
|
|
|
13
|
3
|
|
|
3
|
|
25
|
use Params::Util qw{ _STRING _CODELIKE }; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
188
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
3
|
|
|
3
|
|
18
|
use vars qw{$VERSION}; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
226
|
|
|
16
|
|
|
|
|
|
|
BEGIN { |
|
17
|
3
|
|
|
3
|
|
65
|
$VERSION = '1.16'; |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
3
|
|
|
|
|
25
|
use Object::Tiny qw{ |
|
21
|
|
|
|
|
|
|
parent |
|
22
|
|
|
|
|
|
|
file |
|
23
|
|
|
|
|
|
|
url |
|
24
|
|
|
|
|
|
|
share |
|
25
|
|
|
|
|
|
|
dist |
|
26
|
3
|
|
|
3
|
|
1704
|
}; |
|
|
3
|
|
|
|
|
666
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
##################################################################### |
|
33
|
|
|
|
|
|
|
# Constructor |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
|
36
|
3
|
|
|
3
|
0
|
26
|
my $self = shift->SUPER::new(@_); |
|
37
|
|
|
|
|
|
|
|
|
38
|
3
|
100
|
|
|
|
52
|
unless ( $self->url ) { |
|
39
|
1
|
50
|
0
|
|
|
48
|
if ( $self->share ) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Map share to url vis File::ShareDir |
|
41
|
1
|
|
|
|
|
22
|
my ($dist, $name) = split /\s+/, $self->share; |
|
42
|
1
|
|
|
|
|
12
|
$self->trace("Finding $name in $dist... "); |
|
43
|
1
|
|
|
|
|
8
|
my $file = File::Spec->rel2abs( |
|
44
|
|
|
|
|
|
|
File::ShareDir::dist_file( $dist, $name ) |
|
45
|
|
|
|
|
|
|
); |
|
46
|
1
|
50
|
|
|
|
299
|
unless ( -f $file ) { |
|
47
|
0
|
|
|
|
|
0
|
croak("Failed to find $file"); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
1
|
|
|
|
|
13
|
$self->{url} = URI::file->new($file)->as_string; |
|
50
|
1
|
|
|
|
|
2905
|
$self->trace(" found\n"); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} elsif ( $self->dist ) { |
|
53
|
|
|
|
|
|
|
# Map CPAN dist path to url |
|
54
|
0
|
|
|
|
|
0
|
my $dist = $self->dist; |
|
55
|
0
|
|
|
|
|
0
|
$self->trace("Using distribution path $dist\n"); |
|
56
|
0
|
|
|
|
|
0
|
my $one = substr( $self->dist, 0, 1 ); |
|
57
|
0
|
|
|
|
|
0
|
my $two = substr( $self->dist, 1, 1 ); |
|
58
|
0
|
|
|
|
|
0
|
my $path = File::Spec::Unix->catfile( |
|
59
|
|
|
|
|
|
|
'authors', 'id', $one, "$one$two", $dist, |
|
60
|
|
|
|
|
|
|
); |
|
61
|
0
|
|
|
|
|
0
|
$self->{url} = URI->new_abs( $path, $self->cpan )->as_string; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} elsif ( $self->can('name') and $self->name ) { |
|
64
|
|
|
|
|
|
|
# Map name to URL via the default package path |
|
65
|
0
|
|
|
|
|
0
|
$self->{url} = $self->parent->binary_url($self->name); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# Check params |
|
70
|
3
|
50
|
|
|
|
34
|
unless ( _STRING($self->url) ) { |
|
71
|
0
|
|
|
|
|
0
|
croak("Missing or invalid url param"); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Create the filename from the url |
|
75
|
3
|
|
|
|
|
33
|
$self->{file} = $self->url; |
|
76
|
3
|
|
|
|
|
21
|
$self->{file} =~ s|.+/||; |
|
77
|
3
|
50
|
33
|
|
|
79
|
unless ( $self->file and length $self->file ) { |
|
78
|
0
|
|
|
|
|
0
|
croak("Missing or invalid file"); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
3
|
|
|
|
|
103
|
return $self; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub cpan { |
|
85
|
0
|
|
|
0
|
0
|
0
|
$_[0]->parent->cpan; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
##################################################################### |
|
93
|
|
|
|
|
|
|
# Support Methods |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub trace { |
|
96
|
2
|
|
|
2
|
0
|
4
|
my $self = shift; |
|
97
|
2
|
50
|
|
|
|
13
|
if ( _CODELIKE($self->{trace}) ) { |
|
98
|
0
|
|
|
|
|
0
|
$self->{trace}->(@_); |
|
99
|
|
|
|
|
|
|
} else { |
|
100
|
2
|
|
|
|
|
66
|
print $_[0]; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |