line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Parse::CPAN::Packages::Package; |
2
|
1
|
|
|
1
|
|
5
|
use Moo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
2576
|
use PPI; |
|
1
|
|
|
|
|
84001
|
|
|
1
|
|
|
|
|
37
|
|
5
|
1
|
|
|
1
|
|
7
|
use Types::Standard qw( InstanceOf Str ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'package' => ( is => 'rw', isa => Str ); |
8
|
|
|
|
|
|
|
has 'version' => ( is => 'rw', isa => Str ); |
9
|
|
|
|
|
|
|
has 'prefix' => ( is => 'rw', isa => Str ); |
10
|
|
|
|
|
|
|
has 'distribution' => ( is => 'rw', isa => InstanceOf ['Parse::CPAN::Packages::Distribution'] ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub filename { |
13
|
4
|
|
|
4
|
1
|
1884
|
my ( $self ) = @_; |
14
|
4
|
|
|
|
|
106
|
my $distribution = $self->distribution; |
15
|
4
|
|
|
|
|
47
|
my @filenames = $distribution->list_files; |
16
|
4
|
|
|
|
|
612
|
my $package_file = $self->package; |
17
|
4
|
|
|
|
|
39
|
$package_file =~ s{::}{/}g; |
18
|
4
|
|
|
|
|
9
|
$package_file .= '.pm'; |
19
|
4
|
|
|
|
|
12
|
my ( $filename ) = grep { /$package_file$/ } sort { length( $a ) <=> length( $b ) } @filenames; |
|
4
|
|
|
|
|
45
|
|
|
0
|
|
|
|
|
0
|
|
20
|
4
|
|
|
|
|
22
|
return $filename; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub file_content { |
24
|
2
|
|
|
2
|
1
|
1446
|
my ( $self ) = @_; |
25
|
2
|
|
|
|
|
8
|
my $filename = $self->filename; |
26
|
2
|
|
|
|
|
38
|
my $content = $self->distribution->get_file_from_tarball( $filename ); |
27
|
2
|
|
|
|
|
295
|
return $content; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub subs { |
31
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $document = PPI::Document->new( \( $self->file_content ) ); |
34
|
0
|
|
|
|
|
|
my $subs = $document->find('PPI::Statement::Sub'); |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
return map { $_->name } @{$subs}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub has_matching_sub { |
40
|
0
|
|
|
0
|
1
|
|
my ( $self, $sub_regex ) = @_; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my @matching_subs = grep { $_ =~ $sub_regex } $self->subs; |
|
0
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
return @matching_subs; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 NAME |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Parse::CPAN::Packages::Package |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 DESCRIPTION |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Represents a CPAN Package. Note: The functions filename and file_content work |
58
|
|
|
|
|
|
|
only if a mirror directory was supplied for parsing or the package file was |
59
|
|
|
|
|
|
|
situated inside a cpan mirror structure. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 METHODS |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 filename |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Tries to guess the name of the file containing this package by looking through |
66
|
|
|
|
|
|
|
the files contained in the distribution it belongs to. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 file_content |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Tries to return the contents of the file returned by filename(). |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 subs |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Experimental function. Tries to return the names of all subs in the package. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 has_matching_sub( $regex ) |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Experimental function. Tries to see if any sub name in the package matches the |
79
|
|
|
|
|
|
|
regex. |