mediawiki merging, row identification, tests
[scpubgit/System-Introspector-Report.git] / lib / System / Introspector / Report / Builder / Perls.pm
CommitLineData
499ebcdd 1package System::Introspector::Report::Builder::Perls;
2use Moo;
3
4extends 'System::Introspector::Report::Builder';
5
6has skip_errors => (is => 'ro', default => sub { 1 });
7
8has _rows => (is => 'ro', default => sub { [] });
9
10sub required_data {
11 return qw(
12 perls
13 host
14 );
15}
16
17sub collect_from {
18 my ($self, $id, $data) = @_;
19 my $perls = $data->{perls}{perls} || {};
20 my $hostname = $data->{host}{hostname};
21 if (my @perl_keys = sort keys %$perls) {
22 for my $perl_key (@perl_keys) {
23 my $perl = $perls->{$perl_key};
24 next if defined($perl->{__error__}) and $self->skip_errors;
25 push @{$self->_rows}, {
26 hostname => $hostname,
27 remote => $id,
28 location => $perl->{executable},
29 version => $perl->{config}{version},
30 defined($perl->{__error__})
31 ? (__error__ => $perl->{__error__})
32 : (),
33 };
34 }
35 }
36 else {
37 push @{$self->_rows}, {
38 hostname => $hostname,
39 remote => $id,
40 };
41 }
42 return 1;
43}
44
45sub render_reports {
46 my ($self) = @_;
47 return +{
48 title => 'Perl Installations',
49 id => 'perls',
21e7cc98 50 rowid => [qw( remote location )],
499ebcdd 51 columns => [
52 { key => 'remote', label => 'Remote' },
53 { key => 'hostname', label => 'Hostname' },
54 { key => 'location', label => 'Location' },
55 { key => 'version', label => 'Version' },
56 ],
57 rows => $self->_rows,
58 };
59}
60
611;