File Coverage

blib/lib/App/sdview/Output.pm
Criterion Covered Total %
statement 23 29 79.3
branch 1 2 50.0
condition n/a
subroutine 7 15 46.6
pod 0 12 0.0
total 31 58 53.4


line stmt bran cond sub pod time code
1             # You may distribute under the terms of either the GNU General Public License
2             # or the Artistic License (the same terms as Perl itself)
3             #
4             # (C) Paul Evans, 2021-2022 -- leonerd@leonerd.org.uk
5              
6 4     4   58 use v5.26;
  4         14  
7 4     4   24 use warnings;
  4         7  
  4         250  
8              
9 4     4   23 use Object::Pad 0.800;
  4         37  
  4         171  
10              
11             package App::sdview::Output 0.20;
12             role App::sdview::Output;
13              
14             field $_content;
15              
16 139     139 0 7456 method say ( @s ) { $_content .= join "", @s, "\n"; }
  139     139 0 431  
  139     0 0 349  
  139     0 0 187  
  139         780  
17              
18             method maybe_blank { $_content .= "\n" if length $_content; }
19              
20 22     22 0 122 method generate ( @paragraphs )
  22     22 0 66  
  22     0 0 51  
  22     0 0 34  
21             {
22 22         85 $_content = "";
23              
24 22         108 while ( @paragraphs ) {
25 44         91 my $para = shift @paragraphs;
26              
27 44 50       264 if( my $code = $self->can( "output_" . ( $para->type =~ s/-/_/gr ) ) ) {
28 44         187 $self->$code( $para );
29             }
30             else {
31 0         0 die "Unhandled paragraph type " . $para->type;
32             }
33             }
34              
35 22         89 return $_content;
36             }
37              
38 0     0 0   method output ( @paragraphs )
  0     0 0    
  0     0 0    
  0     0 0    
39             {
40 0           say $self->generate( @paragraphs );
41             }
42              
43             0x55AA;