CPAN-Testers-Reports-Query-JSON
view release on metacpan or search on metacpan
lib/CPAN/Testers/Reports/Query/JSON.pm view on Meta::CPAN
my $dist_query = CPAN::Testers::Reports::Query::JSON->new(
{ distribution => 'Data::Pageset',
version => '1.01', # optional, will default to latest version
}
);
print "Processing version: " . $dist_query->version() . "\n";
print "Other versions are: " . join(" ", @{$dist_query->versions()}) . "\n";
my $all = $dist_query->all();
printf "There were %s tests, %s passed, %s failed - e.g. %s percent",
$all->total_tests(),
$all->number_passed(),
$all->number_failed(),
$all->percent_passed();
my $win32_only = $dist_query->win32_only();
printf "There were %s windows tests, %s passed, %s failed - e.g. %s percent",
$win32_only->total_tests(),
$win32_only->number_passed(),
$win32_only->number_failed(),
$win32_only->percent_passed();
my $non_win32 = $dist_query->non_win32();
printf "There were %s windows tests, %s passed, %s failed - e.g. %s percent",
$non_win32->total_tests(),
$non_win32->number_passed(),
$non_win32->number_failed(),
$non_win32->percent_passed();
# Get results for a specific OS
my $specific_os = $dist_query->for_os('linux');
=head1 DESCRIPTION
This module queries the cpantesters website (via the JSON interface) and
gets the test results back, it then parses these to answer a few simple questions.
This module only reports on versions of Perl which are unpatched.
lib/CPAN/Testers/Reports/Query/JSON/Set.pm view on Meta::CPAN
package CPAN::Testers::Reports::Query::JSON::Set;
use Moose;
use namespace::autoclean;
has name => ( isa => 'Str', is => 'ro', default => 'no-name' );
has total_tests => ( isa => 'Int', is => 'rw', default => 0 );
has number_passed => ( isa => 'Int', is => 'rw', default => 0 );
has number_failed => ( isa => 'Str', is => 'rw', default => 0 );
has percent_passed => ( isa => 'Str', is => 'rw', default => 0 );
has data => ( isa => 'ArrayRef', is => 'rw', );
sub BUILD {
my $self = shift;
my $total_tests = 0;
my $number_failed = 0;
# Go get the data
foreach my $data ( @{ $self->data() } ) {
$total_tests++;
$number_failed++ unless $data->state eq 'pass';
}
return unless $total_tests;
$self->total_tests($total_tests);
$self->number_failed($number_failed);
$self->number_passed( $total_tests - $number_failed );
# calc percent
$self->percent_passed( ( $self->number_passed() / $total_tests ) * 100 );
# We don't need the data now
$self->data( [] );
}
__PACKAGE__->meta->make_immutable;
1;
__DATA__
lib/CPAN/Testers/Reports/Query/JSON/Set.pm view on Meta::CPAN
=over
=item name()
=item total_tests()
=item number_passed()
=item number_failed()
=item percent_passed()
=back
=head1 AUTHOR
Leo Lapworth, LLAP@cuckoo.org
=cut
( run in 0.298 second using v1.01-cache-2.11-cpan-624ce96ca49 )