line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Importer::CPAN; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
51036
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
139300
|
|
|
1
|
|
|
|
|
8
|
|
4
|
1
|
|
|
1
|
|
780
|
use MetaCPAN::Client; |
|
1
|
|
|
|
|
246865
|
|
|
1
|
|
|
|
|
28
|
|
5
|
1
|
|
|
1
|
|
7
|
use Moo; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
with 'Catmandu::Importer'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has prefix => (is => 'ro'); |
12
|
|
|
|
|
|
|
has author => (is => 'ro'); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has fields => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
default => sub { [ qw(id date distribution version abstract) ] }, |
17
|
|
|
|
|
|
|
coerce => sub { |
18
|
|
|
|
|
|
|
ref $_[0] ? $_[0] |
19
|
|
|
|
|
|
|
: ($_[0] eq 'all' ? undef |
20
|
|
|
|
|
|
|
: [ split /,/, $_[0] ]); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
0
|
|
|
has mcpan => (is => 'ro', builder => sub { MetaCPAN::Client->new }); |
25
|
|
|
|
|
|
|
has filter => (is => 'ro', lazy => 1, builder => 1); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _build_filter { |
28
|
0
|
|
|
0
|
|
|
my $self = $_[0]; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my @filter = { status => 'latest' }; |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
if ($self->prefix) { |
33
|
0
|
|
|
|
|
|
push @filter, { distribution => $self->prefix . '*' }; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
if ($self->author) { |
37
|
0
|
|
|
|
|
|
push @filter, { author => $self->author }; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
if (@filter > 1) { |
41
|
0
|
|
|
|
|
|
return { all => \@filter }; |
42
|
|
|
|
|
|
|
} else { |
43
|
0
|
|
|
|
|
|
return $filter[0]; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub generator { |
48
|
|
|
|
|
|
|
my $self = $_[0]; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $result = $self->mcpan->release($self->filter); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
return sub { |
53
|
|
|
|
|
|
|
my $hit = $result->next; |
54
|
|
|
|
|
|
|
return undef unless $hit; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
if ($self->fields) { |
57
|
|
|
|
|
|
|
return { |
58
|
|
|
|
|
|
|
map { $_ => $hit->data->{$_} } @{$self->fields} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
else { |
62
|
|
|
|
|
|
|
return $hit->data; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 NAME |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Catmandu::Importer::CPAN - get information about CPAN releases |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 SYNOPSIS |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
use Catmandu::Importer::CPAN; |
78
|
|
|
|
|
|
|
my $importer = Catmandu::Importer::CPAN->new( prefix => 'Catmandu' ); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
$importer->each(sub { |
81
|
|
|
|
|
|
|
my $module = shift; |
82
|
|
|
|
|
|
|
print $module->{name} , "\n"; |
83
|
|
|
|
|
|
|
print $module->{version} , "\n"; |
84
|
|
|
|
|
|
|
print $module->{date} , "\n"; |
85
|
|
|
|
|
|
|
}); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Or with the L<catmandu> command line client: |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
$ catmandu convert CPAN --author NICS --fields distribution,date to CSV |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 DESCRIPTION |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This L<Catmandu::Importer> retrieves information about CPAN releases via |
94
|
|
|
|
|
|
|
MetaCPAN API. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 CONFIGURATION |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=over |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item prefix |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Prefix that releases must start with, e.g. C<Catmandu>. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item author |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Selected author |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item fields |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Array reference or comma separated list of fields to get. The special value |
111
|
|
|
|
|
|
|
C<all> will return all fields. Set to C<id,date,distribution,version,abstract> |
112
|
|
|
|
|
|
|
by default. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=back |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Patrick Hochstenbach, C<< <patrick.hochstenbach at ugent.be> >> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Jakob Voss C<< <jakob.voss at gbv.de> >> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |