line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Parse::CPAN::Packages::Distribution; |
2
|
1
|
|
|
1
|
|
4
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
3
|
1
|
|
|
1
|
|
636
|
use Archive::Peek; |
|
1
|
|
|
|
|
552093
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
8
|
use Path::Class 'file'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
80
|
|
5
|
1
|
|
|
1
|
|
686
|
use Types::Standard qw( ArrayRef Maybe Str ); |
|
1
|
|
|
|
|
58375
|
|
|
1
|
|
|
|
|
15
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'prefix' => ( is => 'rw', isa => Str ); |
8
|
|
|
|
|
|
|
has 'dist' => ( is => 'rw', isa => Maybe [Str] ); |
9
|
|
|
|
|
|
|
has 'version' => ( is => 'rw', isa => Maybe [Str] ); |
10
|
|
|
|
|
|
|
has 'maturity' => ( is => 'rw', isa => Str ); |
11
|
|
|
|
|
|
|
has 'filename' => ( is => 'rw', isa => Str ); |
12
|
|
|
|
|
|
|
has 'cpanid' => ( is => 'rw', isa => Str ); |
13
|
|
|
|
|
|
|
has 'distvname' => ( is => 'rw', isa => Maybe [Str] ); |
14
|
|
|
|
|
|
|
has 'packages' => ( is => 'rw', isa => ArrayRef, default => sub { [] } ); |
15
|
|
|
|
|
|
|
has 'mirror_dir' => ( is => 'rw', isa => Maybe [Str] ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub contains { |
18
|
1
|
|
|
1
|
1
|
495
|
my $self = shift; |
19
|
1
|
|
|
|
|
2
|
return @{ $self->packages }; |
|
1
|
|
|
|
|
28
|
|
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub add_package { |
23
|
54
|
|
|
54
|
1
|
67
|
my $self = shift; |
24
|
54
|
|
|
|
|
52
|
push @{ $self->packages }, @_; |
|
54
|
|
|
|
|
993
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub list_files { |
28
|
6
|
|
|
6
|
1
|
1811
|
my ( $self ) = @_; |
29
|
|
|
|
|
|
|
|
30
|
6
|
|
|
|
|
26
|
my @filenames = $self->_tarball->files; |
31
|
6
|
|
|
|
|
35640
|
return @filenames; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub get_file_from_tarball { |
35
|
4
|
|
|
4
|
1
|
24
|
my ( $self, $filename ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
4
|
|
|
|
|
17
|
my $contents = $self->_tarball->file( $filename ); |
38
|
4
|
|
|
|
|
21667
|
return $contents; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _tarball { |
42
|
10
|
|
|
10
|
|
22
|
my ( $self ) = @_; |
43
|
|
|
|
|
|
|
|
44
|
10
|
|
|
|
|
196
|
my $file = file( $self->mirror_dir, 'authors', 'id', $self->prefix ); |
45
|
10
|
|
|
|
|
2497
|
my $peek = Archive::Peek->new( filename => $file ); |
46
|
|
|
|
|
|
|
|
47
|
10
|
|
|
|
|
19382
|
return $peek; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Parse::CPAN::Packages::Distribution |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 DESCRIPTION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Represents a CPAN distribution. Note: The functions list_files and |
61
|
|
|
|
|
|
|
get_file_from_tarball work only if a mirror directory was supplied for parsing |
62
|
|
|
|
|
|
|
or the package file was situated inside a cpan mirror structure. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 METHODS |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 contains |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Returns the packages in the distribution. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 add_package |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Adds a package to the distribution. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 list_files |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Tries to list all files in the distribution. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 get_file_from_tarball( $filename ) |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Tries to retrieve the contents of a file from the distribution. |