line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::ReverseDependencies; |
2
|
|
|
|
|
|
|
# ABSTRACT: given a CPAN dist name, find other CPAN dists that use it |
3
|
|
|
|
|
|
|
$CPAN::ReverseDependencies::VERSION = '0.01'; |
4
|
2
|
|
|
2
|
|
21764
|
use 5.006; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
67
|
|
5
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
56
|
|
6
|
2
|
|
|
2
|
|
18
|
use warnings; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
105
|
|
7
|
2
|
|
|
2
|
|
1744
|
use Moo; |
|
2
|
|
|
|
|
34262
|
|
|
2
|
|
|
|
|
14
|
|
8
|
2
|
|
|
2
|
|
3526
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
172
|
|
9
|
2
|
|
|
2
|
|
1764
|
use MetaCPAN::API; |
|
2
|
|
|
|
|
279961
|
|
|
2
|
|
|
|
|
913
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $SLICE_SIZE = 100; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has ua => ( |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
default => sub { MetaCPAN::API->new() }, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub get_reverse_dependencies |
19
|
|
|
|
|
|
|
{ |
20
|
1
|
|
|
1
|
0
|
868
|
my $self = shift; |
21
|
1
|
|
|
|
|
2
|
my $distname = shift; |
22
|
1
|
|
|
|
|
2
|
my @deps; |
23
|
1
|
|
|
|
|
2
|
my $offset = 0; |
24
|
1
|
|
|
|
|
2
|
my @deps_slice; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
2
|
do { |
27
|
1
|
|
|
|
|
4
|
@deps_slice = $self->_get_dependency_slice($distname, $offset); |
28
|
1
|
|
|
|
|
8
|
push(@deps, @deps_slice); |
29
|
1
|
|
|
|
|
5
|
$offset += scalar @deps_slice; |
30
|
|
|
|
|
|
|
} while (@deps_slice == $SLICE_SIZE); |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
10
|
return @deps; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _get_dependency_slice |
36
|
|
|
|
|
|
|
{ |
37
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
38
|
1
|
|
|
|
|
2
|
my $distname = shift; |
39
|
1
|
|
|
|
|
2
|
my $offset = shift; |
40
|
1
|
|
|
|
|
1
|
my $result; |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
2
|
eval { |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
24
|
$result = $self->ua->post('/search/reverse_dependencies/'.$distname, |
45
|
|
|
|
|
|
|
{ |
46
|
|
|
|
|
|
|
query => { |
47
|
|
|
|
|
|
|
filtered => { |
48
|
|
|
|
|
|
|
query => { 'match_all' => {} }, |
49
|
|
|
|
|
|
|
filter => { |
50
|
|
|
|
|
|
|
and => [ |
51
|
|
|
|
|
|
|
{ term => { 'release.status' => 'latest' } }, |
52
|
|
|
|
|
|
|
{ term => { 'release.authorized' => \1 } }, |
53
|
|
|
|
|
|
|
], |
54
|
|
|
|
|
|
|
}, |
55
|
|
|
|
|
|
|
}, |
56
|
|
|
|
|
|
|
}, |
57
|
|
|
|
|
|
|
size => $SLICE_SIZE, |
58
|
|
|
|
|
|
|
from => $offset, |
59
|
|
|
|
|
|
|
}); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
|
63
|
1
|
50
|
|
|
|
103882
|
if ($@) { |
64
|
0
|
|
|
|
|
0
|
croak "Failed to get reverse dependencies for $distname: $@"; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
|
|
3
|
my @dists = map { $_->{_source}->{metadata}->{name} } @{ $result->{hits}->{hits} }; |
|
16
|
|
|
|
|
35
|
|
|
1
|
|
|
|
|
6
|
|
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
720
|
return @dists; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 NAME |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
CPAN::ReverseDependencies - given a CPAN dist name, find other CPAN dists that use it |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SYNOPSIS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
use CPAN::ReverseDependencies; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $revua = CPAN::ReverseDependencies->new(); |
83
|
|
|
|
|
|
|
my @deps = $revua->get_reverse_dependencies('Module-Path'); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 DESCRIPTION |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
B takes the name of a CPAN distribution and |
88
|
|
|
|
|
|
|
returns a list containing names of other CPAN distributions that have declared |
89
|
|
|
|
|
|
|
a dependence on the specified distribution. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
It uses the L |
92
|
|
|
|
|
|
|
L |
93
|
|
|
|
|
|
|
to look up the reverse dependencies, so obviously you have to be online |
94
|
|
|
|
|
|
|
for this module to work. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
This module will C in a number of situations: |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=over 4 |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item * If you request reverse dependencies for a non-existent distribution; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item * If you're not online; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * If there's a problem with MetaCPAN itself. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=back |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 REPOSITORY |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
L |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 AUTHOR |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Neil Bowers Eneilb@cpan.orgE |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Neil Bowers . |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
121
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|