-
Notifications
You must be signed in to change notification settings - Fork 2
/
Report.pm
91 lines (64 loc) · 1.76 KB
/
Report.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package CPAN::Testers::WWW::Reports::Report;
use strict;
use warnings;
use Carp;
our $AUTOLOAD;
my @methods = (
"ostext", "osvers", "perl", "platform",
"version", "csspatch", "distversion", "id",
"status", "state", "cssperl", "dist",
"distribution", "osname",
);
my %permitted_methods = map { $_ => 1 } @methods;
sub new {
my ( $class, $self ) = @_;
bless $self, 'CPAN::Testers::WWW::Reports::Report';
$self->{_permitted} = \%permitted_methods;
return $self;
}
sub DESTROY {
}
sub AUTOLOAD {
my $self = shift;
my $type = ref($self)
or croak "$self is not an object";
my $name = $AUTOLOAD;
$name =~ s/.*://; # strip fully-qualified portion
unless ( exists $self->{_permitted}->{$name} ) {
croak "Can't access `$name' field in class $type";
}
if (@_) {
return $self->{$name} = shift;
} else {
return $self->{$name};
}
}
1;
__DATA__
=head1 NAME
CPAN::Testers::WWW::Reports::Report
=head1 SYNOPSIS
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 $report = $obj->report() ) {
$report->csspatch();
$report->cssperl();
$report->dist();
$report->distribution();
$report->distversion();
$report->id();
$report->osname();
$report->ostext();
$report->osvers();
$report->perl();
$report->platform();
$report->state();
$report->status();
$report->version();
}
=cut