Skip to content

Commit

Permalink
updated leo's patch, added initial support for guid
Browse files Browse the repository at this point in the history
  • Loading branch information
barbie committed Dec 31, 2009
1 parent 6ee9174 commit 520bc37
Show file tree
Hide file tree
Showing 9 changed files with 247 additions and 118 deletions.
8 changes: 5 additions & 3 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Revision history for the CPAN-Testers-WWW-Reports-Parser distribution

0.02 07/12/2009
- Add report_object config option
- CPAN::Testers::WWW::Reports::Report
0.02 31/12/2009
- Ranguard patched distro to add the ability to return report objects
rather than a hash. Added CPAN::Testers::WWW::Reports::Report module.
- minor amendments to Ranguards patches.
- added support for the Metabase GUID.

0.01 08/06/2009
- Initial release
12 changes: 8 additions & 4 deletions META.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: CPAN-Testers-WWW-Reports-Parser
version: 0.01
version: 0.02
abstract: CPAN Testers reports data parser
author:
- Barbie <barbie@cpan.org>
Expand All @@ -24,20 +24,24 @@ build_requires:
provides:
CPAN::Testers::WWW::Reports::Parser:
file: lib/CPAN/Testers/WWW/Reports/Parser.pm
version: 0.01
version: 0.02
CPAN::Testers::WWW::Reports::Report:
file: lib/CPAN/Testers/WWW/Reports/Report.pm
version: 0.02
CPAN::Testers::WWW::Reports::Parser::JSON:
file: lib/CPAN/Testers/WWW/Reports/Parser/JSON.pm
version: 0.01
version: 0.02
CPAN::Testers::WWW::Reports::Parser::YAML:
file: lib/CPAN/Testers/WWW/Reports/Parser/YAML.pm
version: 0.01
version: 0.02
no_index:
directory:
- t

resources:
license: http://dev.perl.org/licenses/
bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=CPAN-Testers-WWW-Reports-Parser
repository: http://github.com/barbie/CPAN-Testers-WWW-Reports-Parser

meta-spec:
version: 1.4
Expand Down
6 changes: 3 additions & 3 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ WriteMakefile(
'NAME' => 'CPAN::Testers::WWW::Reports::Parser',
'VERSION_FROM' => 'lib/CPAN/Testers/WWW/Reports/Parser.pm',
'PREREQ_PM' => {
'Carp' => 0,
'Carp' => 0,

# only one of the following is required.

#'JSON::XS' => 0,
#'YAML::XS' => 0,
#'JSON::XS' => 0,
#'YAML::XS' => 0,
},
'NO_META' => 1,

Expand Down
106 changes: 63 additions & 43 deletions lib/CPAN/Testers/WWW/Reports/Parser.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package CPAN::Testers::WWW::Reports::Parser;

use 5.006;
use strict;
use warnings;

Expand Down Expand Up @@ -33,14 +34,14 @@ sub new {
croak "Cannot access file [$hash{file}]\n" if(defined $hash{file} && ! -f $hash{file});

my $self = {
'format' => uc $hash{'format'},
'data' => $hash{'data'},
'file' => $hash{'file'},
'report_objects' => $hash{'report_objects'},
'format' => uc $hash{'format'},
'data' => $hash{'data'},
'file' => $hash{'file'},
'objects' => $hash{'objects'},
};
bless $self, $class;

if($self->{report_objects}) {
if($self->{objects}) {
eval "use CPAN::Testers::WWW::Reports::Report";
}

Expand Down Expand Up @@ -136,7 +137,7 @@ sub report {
}
}

if($self->{report_objects}) {
if($self->{objects}) {
my $rep = CPAN::Testers::WWW::Reports::Report->new(\%report);
return $rep;
}
Expand Down Expand Up @@ -182,27 +183,18 @@ CPAN::Testers::WWW::Reports::Parser - CPAN Testers reports data parser
=head1 SYNOPSIS
The parser can be used in two different ways, either by accessing each report
as a hashref (each field having a key/value pair entry) or via an object.
=head2 The hashref access API:
use CPAN::Testers::WWW::Reports::Parser;
my $obj = CPAN::Testers::WWW::Reports::Parser->new(
format => 'YAML', # or 'JSON'
file => $file # or data => $data
report_objects => 1, # Optional, works with $obj->report()
);
# iterator, accessing aternate field names
while( my $data = $obj->report() ) {
my $dist = $obj->distribution(); # or $obj->dist(), or $obj->distname()
...
# note that the object is used to reference the methods retrieving
# the individual field names, as the $data variable is a hashref to a
# hash of a single report.
}
# if 'report_objects' was set, then $obj->report() will return
# CPAN::Testers::WWW::Reports::Report objects instead of a hashref
# iterator, filtering field names
$obj->filter(@fields);
$obj->filter('ALL', @fields);
Expand All @@ -221,6 +213,28 @@ CPAN::Testers::WWW::Reports::Parser - CPAN Testers reports data parser
my $data = $obj->reports(@fields); # array of amended hashes
my $data = $obj->reports('ALL',@fields); # array of original + amended hashes
=head2 The object access API:
use CPAN::Testers::WWW::Reports::Parser;
# if 'objects' was set, then $obj->report() will return
# CPAN::Testers::WWW::Reports::Report objects instead of a hashref
my $obj = CPAN::Testers::WWW::Reports::Parser->new(
format => 'YAML', # or 'JSON'
file => $file # or data => $data
objects => 1, # Optional, works with $obj->report()
);
# iterator, accessing aternate field names
while( my $data = $obj->report() ) {
my $dist = $obj->distribution(); # or $obj->dist(), or $obj->distname()
...
# note that the object is used to reference the methods retrieving
# the individual field names, as the $data variable is a hashref to a
# hash of a single report.
}
=head1 DESCRIPTION
Expand All @@ -239,8 +253,9 @@ from the CPAN Testers website.
Instatiates the object CPAN::Testers::WWW::Reports::Parser:
my $obj = CPAN::Testers::WWW::Reports::Parser->new(
format => 'YAML', # or 'JSON'
file => $file # or data => $data
format => 'YAML', # or 'JSON'
file => $file # or data => $data
objects => 1 # optional, uses hash API if absent
);
=back
Expand Down Expand Up @@ -273,76 +288,81 @@ require, otherwise the default data hash is returned.
=over
=item * id
=item * id
Returns the current Report NNTP ID. Note that Metabase reports will always
return a zero value.
=item * guid
Report ID.
Returns the current Report GUID. This is the full Metabase GUID.
=item * distribution
=item * distribution
=item * dist
=item * dist
=item * distname
=item * distname
Variations of the distribution name.
=item * version
=item * version
Distribution version.
=item * distversion
=item * distversion
Distribution name and version.
=item * perl
=item * perl
Version of perl used to test.
=item * state
=item * state
=item * status
=item * status
=item * grade
=item * grade
=item * action
=item * action
Variations on the grade of the report. Note that 'state' represents the lower
case version, while the others are upper case.
=item * osname
=item * osname
String extracted representing the Operating System name.
=item * ostext
=item * ostext
Normalised version of the Operating System name, where known, as occasionally
the name may not correctly reflect a print friendly version of the name, or
even the actual name.
=item * osvers
=item * osvers
Operating System version, if known.
=item * platform
=item * platform
=item * archname
=item * archname
The architecture name of the Operating System installed, as this usually
gives more information about the setup of the smoke box, such as whether the
OS is 64-bit or not.
=item * url
=item * url
The current path to an online version of the individual report.
=item * csspatch
=item * csspatch
Primarily used for web, provides a quick indicator as to whether this release
was tested with a patched version of perl. Possible values are:
pat - patched
unp - unpatched
=item * cssperl
=item * cssperl
Primarily used for web, provides a quick indicator as to whether this release
was tested with a development version of perl. Possible values are:
Expand Down Expand Up @@ -381,7 +401,7 @@ F<http://blog.cpantesters.org/>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2009 Barbie <barbie@cpan.org>
Copyright (C) 2009-2010 Barbie <barbie@cpan.org>
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
Expand Down
5 changes: 3 additions & 2 deletions lib/CPAN/Testers/WWW/Reports/Parser/JSON.pm
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package CPAN::Testers::WWW::Reports::Parser::JSON;

use 5.006;
use strict;
use warnings;

use vars qw($VERSION);
$VERSION = '0.01';
$VERSION = '0.02';

#----------------------------------------------------------------------------
# Library Modules
Expand Down Expand Up @@ -126,7 +127,7 @@ F<http://blog.cpantesters.org/>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2009 Barbie <barbie@cpan.org>
Copyright (C) 2009-2010 Barbie <barbie@cpan.org>
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
Expand Down
5 changes: 3 additions & 2 deletions lib/CPAN/Testers/WWW/Reports/Parser/YAML.pm
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package CPAN::Testers::WWW::Reports::Parser::YAML;

use 5.006;
use strict;
use warnings;

use vars qw($VERSION);
$VERSION = '0.01';
$VERSION = '0.02';

#----------------------------------------------------------------------------
# Library Modules
Expand Down Expand Up @@ -114,7 +115,7 @@ F<http://blog.cpantesters.org/>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2009 Barbie <barbie@cpan.org>
Copyright (C) 2009-2010 Barbie <barbie@cpan.org>
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
Expand Down
Loading

0 comments on commit 520bc37

Please sign in to comment.