line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
259979
|
use 5.008001; |
|
2
|
|
|
|
|
13
|
|
2
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
41
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
103
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package CPAN::Common::Index::MetaDB; |
6
|
|
|
|
|
|
|
# ABSTRACT: Search index via CPAN MetaDB |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.007'; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
11
|
use parent 'CPAN::Common::Index'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
17
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
114
|
use Class::Tiny qw/uri/; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
9
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
339
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
107
|
|
15
|
2
|
|
|
2
|
|
846
|
use CPAN::Meta::YAML; |
|
2
|
|
|
|
|
8590
|
|
|
2
|
|
|
|
|
105
|
|
16
|
2
|
|
|
2
|
|
555
|
use HTTP::Tiny; |
|
2
|
|
|
|
|
20427
|
|
|
2
|
|
|
|
|
512
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#pod =attr uri |
19
|
|
|
|
|
|
|
#pod |
20
|
|
|
|
|
|
|
#pod A URI for the endpoint of a CPAN MetaDB server. The |
21
|
|
|
|
|
|
|
#pod default is L. |
22
|
|
|
|
|
|
|
#pod |
23
|
|
|
|
|
|
|
#pod =cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub BUILD { |
26
|
3
|
|
|
3
|
0
|
3603
|
my $self = shift; |
27
|
3
|
|
|
|
|
82
|
my $uri = $self->uri; |
28
|
3
|
100
|
|
|
|
27
|
$uri = "http://cpanmetadb.plackperl.org/v1.0/" |
29
|
|
|
|
|
|
|
unless defined $uri; |
30
|
|
|
|
|
|
|
# ensure URI ends in '/' |
31
|
3
|
|
|
|
|
13
|
$uri =~ s{/?$}{/}; |
32
|
3
|
|
|
|
|
46
|
$self->uri($uri); |
33
|
3
|
|
|
|
|
17
|
return; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub search_packages { |
37
|
1
|
|
|
1
|
1
|
386
|
my ( $self, $args ) = @_; |
38
|
1
|
50
|
|
|
|
6
|
Carp::croak("Argument to search_packages must be hash reference") |
39
|
|
|
|
|
|
|
unless ref $args eq 'HASH'; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# only support direct package query |
42
|
|
|
|
|
|
|
return |
43
|
1
|
50
|
33
|
|
|
16
|
unless keys %$args == 1 && exists $args->{package} && ref $args->{package} eq ''; |
|
|
|
33
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
2
|
my $mod = $args->{package}; |
46
|
1
|
|
|
|
|
8
|
my $res = HTTP::Tiny->new->get( $self->uri . "package/$mod" ); |
47
|
1
|
50
|
|
|
|
37170
|
return unless $res->{success}; |
48
|
|
|
|
|
|
|
|
49
|
1
|
50
|
|
|
|
14
|
if ( my $yaml = CPAN::Meta::YAML->read_string( $res->{content} ) ) { |
50
|
1
|
|
|
|
|
22708
|
my $meta = $yaml->[0]; |
51
|
1
|
50
|
33
|
|
|
8
|
if ( $meta && $meta->{distfile} ) { |
52
|
1
|
|
|
|
|
15
|
my $file = $meta->{distfile}; |
53
|
1
|
|
|
|
|
7
|
$file =~ s{^./../}{}; # strip leading |
54
|
|
|
|
|
|
|
return { |
55
|
|
|
|
|
|
|
package => $mod, |
56
|
|
|
|
|
|
|
version => $meta->{version}, |
57
|
1
|
|
|
|
|
169
|
uri => "cpan:///distfile/$file", |
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
0
|
1
|
|
sub index_age { return time }; # pretend always current |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
0
|
1
|
|
sub search_authors { return }; # not supported |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# vim: ts=4 sts=4 sw=4 et: |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |