File Coverage

blib/lib/App/sdview/Output.pm
Criterion Covered Total %
statement 25 31 80.6
branch 3 4 75.0
condition n/a
subroutine 9 19 47.3
pod 0 16 0.0
total 37 70 52.8


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   50 use v5.26;
  4         15  
7 4     4   22 use warnings;
  4         13  
  4         133  
8              
9 4     4   46 use Object::Pad 0.800;
  4         28  
  4         160  
10              
11             package App::sdview::Output 0.11;
12             role App::sdview::Output;
13              
14             field $_content;
15              
16 113     113 0 4285 method say ( @s ) { $_content .= join "", @s, "\n"; }
  113     113 0 161  
  113     0 0 180  
  113     0 0 133  
  113         429  
17              
18 25 100   25 0 50 method maybe_blank { $_content .= "\n" if length $_content; }
  25     25 0 95  
        0 0    
        0 0    
19              
20 17         30 method generate ( @paragraphs )
  17         30  
  17         24  
21 17     17 0 91 {
        17 0    
        0 0    
        0 0    
22 17         28 $_content = "";
23              
24 17         43 while ( @paragraphs ) {
25 35         68 my $para = shift @paragraphs;
26              
27 35 50       121 if( my $code = $self->can( "output_" . ( $para->type =~ s/-/_/gr ) ) ) {
28 35         121 $self->$code( $para );
29             }
30             else {
31 0         0 die "Unhandled paragraph type " . $para->type;
32             }
33             }
34              
35 17         56 return $_content;
36             }
37              
38 0           method output ( @paragraphs )
  0            
  0            
39 0     0 0   {
        0 0    
        0 0    
        0 0    
40 0           say $self->generate( @paragraphs );
41             }
42              
43             0x55AA;