| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CPAN::Testers::Reports::Query::JSON; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
26054
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use namespace::autoclean; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use version; |
|
7
|
|
|
|
|
|
|
use LWP::Simple; |
|
8
|
|
|
|
|
|
|
use CPAN::Testers::WWW::Reports::Parser; |
|
9
|
|
|
|
|
|
|
use CPAN::Testers::Reports::Query::JSON::Set; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has distribution => ( isa => 'Str', is => 'ro', required => 1 ); |
|
14
|
|
|
|
|
|
|
has version => ( isa => 'Str', is => 'rw' ); |
|
15
|
|
|
|
|
|
|
has current_version => ( isa => 'Str', is => 'ro', lazy_build => 1 ); |
|
16
|
|
|
|
|
|
|
has versions => ( isa => 'ArrayRef[Str]', is => 'ro', lazy_build => 1 ); |
|
17
|
|
|
|
|
|
|
has report => ( |
|
18
|
|
|
|
|
|
|
is => 'rw', |
|
19
|
|
|
|
|
|
|
lazy_build => 1, |
|
20
|
|
|
|
|
|
|
isa => 'ArrayRef[CPAN::Testers::WWW::Reports::Report]', |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _build_current_version { |
|
24
|
|
|
|
|
|
|
my $self = shift; |
|
25
|
|
|
|
|
|
|
return $self->versions()->[0]; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _build_report { |
|
29
|
|
|
|
|
|
|
my $self = shift; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $data = $self->_raw_json(); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $obj = CPAN::Testers::WWW::Reports::Parser->new( |
|
34
|
|
|
|
|
|
|
format => 'JSON', |
|
35
|
|
|
|
|
|
|
data => $data, |
|
36
|
|
|
|
|
|
|
objects => 1, |
|
37
|
|
|
|
|
|
|
); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my @results; |
|
40
|
|
|
|
|
|
|
while ( my $data = $obj->report() ) { |
|
41
|
|
|
|
|
|
|
next unless $data->csspatch() eq 'unp'; |
|
42
|
|
|
|
|
|
|
push( @results, $data ); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
return \@results; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _build_versions { |
|
48
|
|
|
|
|
|
|
my $self = shift; |
|
49
|
|
|
|
|
|
|
my $report = $self->report(); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my %versions; |
|
52
|
|
|
|
|
|
|
foreach my $data ( @{$report} ) { |
|
53
|
|
|
|
|
|
|
my $this_version = version->new( $data->version() ); |
|
54
|
|
|
|
|
|
|
$versions{ $this_version->stringify } = 1; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
my @vers = reverse sort keys %versions; |
|
57
|
|
|
|
|
|
|
return \@vers; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 NAME |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
CPAN::Testers::Reports::Query::JSON - Find out about a distributions cpantesters results |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
my $dist_query = CPAN::Testers::Reports::Query::JSON->new( |
|
67
|
|
|
|
|
|
|
{ distribution => 'Data::Pageset', |
|
68
|
|
|
|
|
|
|
version => '1.01', # optional, will default to latest version |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
print "Processing version: " . $dist_query->version() . "\n"; |
|
73
|
|
|
|
|
|
|
print "Other versions are: " . join(" ", @{$dist_query->versions()}) . "\n"; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $all = $dist_query->all(); |
|
76
|
|
|
|
|
|
|
printf "There were %s tests, %s passed, %s failed - e.g. %s percent", |
|
77
|
|
|
|
|
|
|
$all->total_tests(), |
|
78
|
|
|
|
|
|
|
$all->number_passed(), |
|
79
|
|
|
|
|
|
|
$all->number_failed(), |
|
80
|
|
|
|
|
|
|
$all->percent_passed(); |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $win32_only = $dist_query->win32_only(); |
|
83
|
|
|
|
|
|
|
printf "There were %s windows tests, %s passed, %s failed - e.g. %s percent", |
|
84
|
|
|
|
|
|
|
$win32_only->total_tests(), |
|
85
|
|
|
|
|
|
|
$win32_only->number_passed(), |
|
86
|
|
|
|
|
|
|
$win32_only->number_failed(), |
|
87
|
|
|
|
|
|
|
$win32_only->percent_passed(); |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $non_win32 = $dist_query->non_win32(); |
|
90
|
|
|
|
|
|
|
printf "There were %s windows tests, %s passed, %s failed - e.g. %s percent", |
|
91
|
|
|
|
|
|
|
$non_win32->total_tests(), |
|
92
|
|
|
|
|
|
|
$non_win32->number_passed(), |
|
93
|
|
|
|
|
|
|
$non_win32->number_failed(), |
|
94
|
|
|
|
|
|
|
$non_win32->percent_passed(); |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# Get results for a specific OS |
|
97
|
|
|
|
|
|
|
my $specific_os = $dist_query->for_os('linux'); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This module queries the cpantesters website (via the JSON interface) and |
|
102
|
|
|
|
|
|
|
gets the test results back, it then parses these to answer a few simple questions. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This module only reports on versions of Perl which are unpatched. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 all() |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Get stats on all tests, returns a CPAN::Testers::Reports::Query::JSON::Set object. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 win32_only() |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Returns a CPAN::Testers::Reports::Query::JSON::Set object for win32 only |
|
113
|
|
|
|
|
|
|
test results. 'MSWin32' and 'cygwin' are osnames. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 non_win32() |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Non windows, returns a CPAN::Testers::Reports::Query::JSON::Set object. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 for_os() |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
my $report = $dist_query->for_os('linux'); |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Returns a CPAN::Testers::Reports::Query::JSON::Set object for the |
|
124
|
|
|
|
|
|
|
specified OS. |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 current_version() |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
my $current_version = $query->current_version(); |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Returns the latest version available |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 AUTHOR |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Leo Lapworth, LLAP@cuckoo.org |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 BUGS |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
None that I'm aware of - export may not encode correctly. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 Repository (git) |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
http://github.com/ranguard/cpan-testers-reports-query-json, |
|
143
|
|
|
|
|
|
|
git://github.com/ranguard/cpan-testers-reports-query-json.git |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Copyright (c) Leo Lapworth. All rights reserved. |
|
148
|
|
|
|
|
|
|
This program is free software; you can redistribute |
|
149
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub all { |
|
154
|
|
|
|
|
|
|
my $self = shift; |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
return $self->_create_set( { name => 'all', } ); |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub win32_only { |
|
160
|
|
|
|
|
|
|
my $self = shift; |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
return $self->_create_set( |
|
163
|
|
|
|
|
|
|
{ os_include_only => { |
|
164
|
|
|
|
|
|
|
'MSWin32' => 1, |
|
165
|
|
|
|
|
|
|
'cygwin' => 1, |
|
166
|
|
|
|
|
|
|
}, |
|
167
|
|
|
|
|
|
|
name => 'win32_only', |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
); |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub non_win32 { |
|
174
|
|
|
|
|
|
|
my $self = shift; |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
return $self->_create_set( |
|
177
|
|
|
|
|
|
|
{ os_exclude => { |
|
178
|
|
|
|
|
|
|
'MSWin32' => 1, |
|
179
|
|
|
|
|
|
|
'cygwin' => 1, |
|
180
|
|
|
|
|
|
|
}, |
|
181
|
|
|
|
|
|
|
name => 'non_win32', |
|
182
|
|
|
|
|
|
|
} |
|
183
|
|
|
|
|
|
|
); |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
} |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub for_os { |
|
188
|
|
|
|
|
|
|
my ( $self, $os ) = @_; |
|
189
|
|
|
|
|
|
|
return $self->_create_set( |
|
190
|
|
|
|
|
|
|
{ os_include_only => { $os => 1, }, |
|
191
|
|
|
|
|
|
|
name => $os, |
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
); |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub _create_set { |
|
197
|
|
|
|
|
|
|
my ( $self, $conf ) = @_; |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
$conf ||= {}; |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
my @os_data; |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
foreach my $data ( @{ $self->_get_data_for_version() } ) { |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
# Only want non-patched Perl at the moment |
|
206
|
|
|
|
|
|
|
if ( $conf->{os_exclude} ) { |
|
207
|
|
|
|
|
|
|
next if $conf->{os_exclude}->{ $data->osname() }; |
|
208
|
|
|
|
|
|
|
} |
|
209
|
|
|
|
|
|
|
if ( $conf->{os_include_only} ) { |
|
210
|
|
|
|
|
|
|
next unless $conf->{os_include_only}->{ $data->osname() }; |
|
211
|
|
|
|
|
|
|
} |
|
212
|
|
|
|
|
|
|
push( @os_data, $data ); |
|
213
|
|
|
|
|
|
|
} |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
return CPAN::Testers::Reports::Query::JSON::Set->new( |
|
216
|
|
|
|
|
|
|
{ data => \@os_data, name => $conf->{name} } ); |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
sub _get_data_for_version { |
|
220
|
|
|
|
|
|
|
my $self = shift; |
|
221
|
|
|
|
|
|
|
my $version = $self->version || $self->current_version; |
|
222
|
|
|
|
|
|
|
my $report = $self->report(); |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
my @data = grep { $_->version() eq $version } @{$report}; |
|
225
|
|
|
|
|
|
|
return \@data; |
|
226
|
|
|
|
|
|
|
} |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub _json_url { |
|
229
|
|
|
|
|
|
|
my $self = shift; |
|
230
|
|
|
|
|
|
|
my $dist = $self->distribution(); |
|
231
|
|
|
|
|
|
|
$dist =~ s/::/-/; |
|
232
|
|
|
|
|
|
|
my ($letter) = ( $dist =~ /(.{1})/ ); |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
return "http://www.cpantesters.org/distro/$letter/$dist.json"; |
|
235
|
|
|
|
|
|
|
} |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
sub _raw_json { |
|
238
|
|
|
|
|
|
|
my $self = shift; |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
# Fetch from website - could have caching here |
|
241
|
|
|
|
|
|
|
return get( $self->_json_url() ); |
|
242
|
|
|
|
|
|
|
} |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
1; |