| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package App::Slackeria::Output; | 
| 2 | 1 |  |  | 1 |  | 419206 | use strict; | 
|  | 1 |  |  |  |  | 14 |  | 
|  | 1 |  |  |  |  | 103 |  | 
| 3 | 1 |  |  | 1 |  | 6 | use warnings; | 
|  | 1 |  |  |  |  | 8 |  | 
|  | 1 |  |  |  |  | 162 |  | 
| 4 | 1 |  |  | 1 |  | 1230 | use autodie; | 
|  | 1 |  |  |  |  | 30505 |  | 
|  | 1 |  |  |  |  | 8 |  | 
| 5 | 1 |  |  | 1 |  | 7027 | use 5.010; | 
|  | 1 |  |  |  |  | 8 |  | 
|  | 1 |  |  |  |  | 55 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 1 |  |  | 1 |  | 1152 | use File::ShareDir qw(dist_file); | 
|  | 1 |  |  |  |  | 9383 |  | 
|  | 1 |  |  |  |  | 96 |  | 
| 8 | 1 |  |  | 1 |  | 1914 | use HTML::Template; | 
|  | 1 |  |  |  |  | 16659 |  | 
|  | 1 |  |  |  |  | 38 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | our $VERSION = '0.12'; | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | sub format_check { | 
| 13 | 0 |  |  | 0 | 0 |  | my ( $self, $res ) = @_; | 
| 14 | 0 |  |  |  |  |  | my ( $class, $href, $data ); | 
| 15 |  |  |  |  |  |  |  | 
| 16 | 0 | 0 | 0 |  |  |  | if ( not $res->{skip} and $res->{ok} and $res->{data} eq q{} ) { | 
|  |  |  | 0 |  |  |  |  | 
| 17 | 0 |  |  |  |  |  | $data = 'ok'; | 
| 18 |  |  |  |  |  |  | } | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 0 | 0 | 0 |  |  |  | if ( $res->{ok} and $res->{href} ) { | 
| 21 | 0 |  |  |  |  |  | $href = $res->{href}; | 
| 22 |  |  |  |  |  |  | } | 
| 23 |  |  |  |  |  |  |  | 
| 24 | 0 | 0 |  |  |  |  | if ( not $res->{skip} ) { | 
| 25 | 0 |  | 0 |  |  |  | $data //= $res->{data}; | 
| 26 | 0 | 0 |  |  |  |  | if ( $res->{ok} ) { | 
| 27 | 0 |  |  |  |  |  | $class = 'ok'; | 
| 28 |  |  |  |  |  |  | } | 
| 29 |  |  |  |  |  |  | else { | 
| 30 | 0 |  |  |  |  |  | $class = 'fail'; | 
| 31 |  |  |  |  |  |  | } | 
| 32 |  |  |  |  |  |  | } | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | return { | 
| 35 | 0 |  | 0 |  |  |  | class => $class // q{}, | 
| 36 |  |  |  |  |  |  | data  => $data, | 
| 37 |  |  |  |  |  |  | href  => $href, | 
| 38 |  |  |  |  |  |  | }; | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | sub write_out { | 
| 42 | 0 |  |  | 0 | 1 |  | my ( $self, %opt ) = @_; | 
| 43 | 0 |  |  |  |  |  | my @project_lines; | 
| 44 |  |  |  |  |  |  | my @headers; | 
| 45 |  |  |  |  |  |  |  | 
| 46 | 0 |  |  |  |  |  | my $filename = $opt{filename}; | 
| 47 | 0 |  |  |  |  |  | my $project  = $opt{data}; | 
| 48 | 0 |  | 0 |  |  |  | my $template = $opt{template} | 
| 49 |  |  |  |  |  |  | // dist_file( 'App-Slackeria', 'template.xhtml' ); | 
| 50 |  |  |  |  |  |  |  | 
| 51 | 0 |  |  |  |  |  | my $tmpl = HTML::Template->new( filename => $template ); | 
| 52 |  |  |  |  |  |  |  | 
| 53 | 0 |  |  |  |  |  | $tmpl->param( | 
| 54 |  |  |  |  |  |  | title   => 'Software version matrix', | 
| 55 |  |  |  |  |  |  | version => $VERSION, | 
| 56 |  |  |  |  |  |  | ); | 
| 57 |  |  |  |  |  |  |  | 
| 58 | 0 |  |  |  |  |  | for my $p ( sort keys %{$project} ) { | 
|  | 0 |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  |  | 
| 60 | 0 |  |  |  |  |  | my @plugins = sort keys %{ $project->{$p} }; | 
|  | 0 |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | my @project_plugins | 
| 63 | 0 |  |  |  |  |  | = map { $self->format_check( $project->{$p}->{$_} ) } @plugins; | 
|  | 0 |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  |  | 
| 65 | 0 | 0 |  |  |  |  | if ( @headers == 0 ) { | 
| 66 | 0 |  |  |  |  |  | push( @headers, map { { plugin => $_ } } @plugins ); | 
|  | 0 |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | } | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | push( | 
| 70 | 0 |  |  |  |  |  | @project_lines, | 
| 71 |  |  |  |  |  |  | { | 
| 72 |  |  |  |  |  |  | project => $p, | 
| 73 |  |  |  |  |  |  | plugins => [@project_plugins] | 
| 74 |  |  |  |  |  |  | } | 
| 75 |  |  |  |  |  |  | ); | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | } | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | $tmpl->param( | 
| 80 | 0 |  |  |  |  |  | headers  => [@headers], | 
| 81 |  |  |  |  |  |  | projects => [@project_lines], | 
| 82 |  |  |  |  |  |  | ); | 
| 83 |  |  |  |  |  |  |  | 
| 84 | 0 |  |  |  |  |  | open( my $fh, '>', $filename ); | 
| 85 | 0 |  |  |  |  |  | print $fh $tmpl->output(); | 
| 86 | 0 |  |  |  |  |  | close($fh); | 
| 87 |  |  |  |  |  |  |  | 
| 88 | 0 |  |  |  |  |  | return; | 
| 89 |  |  |  |  |  |  | } | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | 1; | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | __END__ |