File Coverage

blib/lib/App/sdview/Parser.pm
Criterion Covered Total %
statement 84 88 95.4
branch n/a
condition n/a
subroutine 35 37 94.5
pod n/a
total 119 125 95.2


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, 2022-2023 -- leonerd@leonerd.org.uk
5              
6 8     8   675 use v5.26;
  8         31  
7 8     8   45 use warnings;
  8         16  
  8         224  
8 8     8   38 use utf8;
  8         15  
  8         51  
9              
10 8     8   995 use Object::Pad 0.800 ':experimental(adjust_params)';
  8         12425  
  8         374  
11 8     8   5322 use Object::Pad::FieldAttr::Checked;
  8         5352  
  8         53  
12              
13             package App::sdview::Parser 0.11;
14             role App::sdview::Parser;
15              
16 8     8   8134 use String::Tagged;
  8         66529  
  8         338  
17 8     8   5567 use Types::Standard;
  8         656035  
  8         78  
18              
19             my $ListType;
20             BEGIN {
21 8     8   5462 $ListType = Types::Standard::Enum[qw( bullet number text )];
22             }
23              
24             # This package is empty but provides a bunch of helper classes
25              
26             class App::sdview::Para::Heading :strict(params) {
27 8     8   23148 use Types::Standard qw( InstanceOf Num );
  8         23  
  8         52  
28              
29 0     0   0 field $level :param :reader :Checked(Num);
  0         0  
30 31     31   915 field $text :param :reader :Checked(InstanceOf['String::Tagged']);
  31         217  
31              
32 36     36   2597 method type { "head" . $level }
  36         306  
33             }
34              
35             class App::sdview::Para::Plain :strict(params) {
36 8     8   31807 use Types::Standard qw( InstanceOf Num );
  8         21  
  8         68  
37              
38 144     144   4768 field $text :param :reader :Checked(InstanceOf['String::Tagged']);
  144         584  
39 2     2   8 field $indent :param :reader :Checked(Num) = 0;
40              
41 2     94   11 method type { "plain" }
  94         998  
  94         452  
42             }
43              
44             class App::sdview::Para::Verbatim :strict(params) {
45 8     8   3338 use Types::Standard qw( InstanceOf Num );
  8         20  
  8         37  
46              
47 21     21   60 field $text :param :reader :Checked(InstanceOf['String::Tagged']);
  21         139  
48 0     0   0 field $indent :param :reader :Checked(Num) = 0;
49              
50 0     8   0 method type { "verbatim" }
  8         21  
  8         54  
51             }
52              
53             class App::sdview::Para::List :strict(params) {
54 8     8   3219 use Types::Standard qw( Num );
  8         40  
  8         41  
55              
56 36     36   79 field $listtype :param :reader :Checked($ListType);
  36         160  
57 24     24   57 field $indent :param :reader :Checked(Num);
  24         99  
58 9     9   24 field $initial :param :reader :Checked(Num) = 1; # for number lists
59              
60 9     19   32 field @items :reader;
  19         55  
  19         94  
61              
62 61     61   458 method push_item ( $item ) { push @items, $item; }
  61         96  
  61         85  
  61         79  
  61         222  
63              
64 40     40   3445 method type { "list-$listtype" }
  40         291  
65             }
66              
67             class App::sdview::Para::ListItem :strict(params) {
68 8     8   5251 use Types::Standard qw( InstanceOf Maybe );
  8         18  
  8         40  
69              
70 50     50   95 field $listtype :param :reader :Checked($ListType);
  50         254  
71             field $term :param :reader :Checked(Maybe[InstanceOf['String::Tagged']]) = undef;
72 42     42   86 field $text :param :reader :Checked(InstanceOf['String::Tagged']);
  42     94   156  
  94         200  
  94         377  
73              
74 119     119   2966 method type { "item" }
  119         589  
75             }
76              
77             class App::sdview::Para::Table :strict(params) {
78 5     5   411 method type { "table" }
  5         37  
79              
80 6     6   16 field @rows :reader;
  6         29  
81              
82             ADJUST :params ( :$rows ) {
83             @rows = $rows->@*;
84             }
85             }
86              
87             class App::sdview::Para::TableCell :isa(App::sdview::Para::Plain) :strict(params) {
88 8     8   8430 use Types::Standard qw( Enum );
  8         18  
  8         87  
89              
90 31     31   66 field $align :param :reader :Checked(Enum[qw( left centre right )]);
  31         132  
91              
92 4     4   399 method type { "table-cell" }
  4         27  
93             }
94              
95             0x55AA;