Parser/TableBody.pm

filter: Statementstmt 27.4% 20 / 73 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 41.1% 7 / 17 Podpod 100% 6 / 6 totaltotal 29.4% 33 / 112 CC 9 SCAR 25.1
CC
9
Cov
22%
as_string
42.0
as_css_grid
6.0
as_markdown
6.0
CRAP 12.3
« Parser/Document.pm ↑ Summary Parser/TableHeader.pm »
1 ##----------------------------------------------------------------------------
2 ## Markdown Parser Only - ~/lib/Markdown/Parser/TableBody.pm
3 ## Version v0.3.0
4 ## Copyright(c) 2022 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/08/23
7 ## Modified 2024/08/30
8 ## All rights reserved
9 ##
10 ## This program is free software; you can redistribute it and/or modify it
11 ## under the same terms as Perl itself.
12 ##----------------------------------------------------------------------------
13 package Markdown::Parser::TableBody;
14 BEGIN
15 1 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶ use parent qw( Markdown::Parser::Element );
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 our $VERSION = 'v0.3.0';
21 };
22  
23 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 sub init
27 0 ▶{
Subroutine init: not called CC=1 SCAR=6.9
Pod documented
28 0 my $self = shift( @_ );
29 0 $self->{rows} = [];
30 0 $self->{tag_name} = 'tbody';
31 0 return( $self->SUPER::init( @_ ) );
32 }
33  
34 sub as_css_grid
35 0 ▶{
Subroutine as_css_grid: not called CC=2 SCAR=17.9
Pod documented
36 0 my $self = shift( @_ );
37 0 ▶ return( $self->{_as_css_grid} ) if( $self->{_as_css_grid} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_as_css_grid"} 0 0 0
38 0 my $row_data = $self->new_array;
39 ## Check each row
40 $self->children->for(sub
41 0 ▶ {
Subroutine __ANON__: not called CC=1 SCAR=6.9
42 0 my( $i, $row ) = @_;
43 0 $row_data->push( $row->as_css_grid->scalar );
44 0 });
45 0 $self->{_as_css_grid} = $row_data->join( "\n" )->scalar;
46 0 return( $self->{_as_css_grid} );
47 }
48  
49 sub as_markdown
50 0 ▶{
Subroutine as_markdown: not called CC=2 SCAR=17.9
Pod documented
51 0 my $self = shift( @_ );
52 0 ▶ return( $self->{_as_markdown} ) if( $self->{_as_markdown} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_as_markdown"} 0 0 0
53 0 my $row_data = $self->new_array;
54 # Check each row
55 $self->children->for(sub
56 0 ▶ {
Subroutine __ANON__: not called CC=1 SCAR=6.9
57 0 my( $i, $row ) = @_;
58 0 my $row_str = $row->as_markdown;
59 0 $row_data->push( $row_str->scalar );
60 0 });
61 0 $self->{_as_markdown} = $row_data->join( "\n" )->scalar;
62 0 return( $self->{_as_markdown} );
63 }
64  
65 sub as_pod
66 0 ▶{
Subroutine as_pod: not called CC=2 SCAR=17.9
Pod documented
67 0 my $self = shift( @_ );
68 0 ▶ return( $self->{_as_pod} ) if( $self->{_as_pod} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_as_pod"} 0 0 0
69 0 my $row_data = $self->new_array;
70 # Check each row
71 $self->children->for(sub
72 0 ▶ {
Subroutine __ANON__: not called CC=1 SCAR=6.9
73 0 my( $i, $row ) = @_;
74 0 my $row_str = $row->as_pod;
75 0 $row_data->push( $row_str->scalar );
76 0 });
77 0 $self->{_as_pod} = $row_data->join( "\n" )->scalar;
78 0 return( $self->{_as_pod} );
79 }
80  
81 sub as_string
82 0 ▶{
Subroutine as_string: not called CC=6 SCAR=37.4
Pod documented
83 0 my $self = shift( @_ );
84 0 ▶ return( $self->{_as_string} ) if( $self->{_as_string} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_as_string"} 0 0 0
85 0 my $arr = $self->new_array;
86 0 my $tag = $self->tag_name;
87 0 my $tag_open = $tag;
88 0 my $tmp = $self->new_array;
89 0 $tmp->push( "<$tag_open" );
90 0 my $attr = $self->new_array;
91 0 ▶ $attr->push( $self->format_id ) if( $self->id->length );
Branch: 1 branch
BranchTrueFalseTotal
if $self->id->length 0 0 0
92 0 ▶ $attr->push( $self->format_class ) if( $self->class->length );
Branch: 1 branch
BranchTrueFalseTotal
if $self->class->length 0 0 0
93 0 my $attributes = $self->format_attributes;
94 0 ▶ $attr->push( $attributes->join( ' ' )->scalar ) if( $attributes->length );
Branch: 1 branch
BranchTrueFalseTotal
if $attributes->length 0 0 0
95 0 ▶ $tmp->push( ' ' . $attr->join( ' ' )->scalar ) if( $attr->length );
Branch: 1 branch
BranchTrueFalseTotal
if $attr->length 0 0 0
96 0 $tmp->push( '>' );
97 0 $arr->push( $tmp->join( '' )->scalar );
98 $arr->push( $self->children->map(sub
99 0 ▶ {
Subroutine __ANON__: not called CC=1 SCAR=6.9
100 0 $_->as_string;
101 0 })->list );
102 0 $arr->push( "</$tag>" );
103 0 $self->{_as_string} = $arr->join( "\n" )->scalar;
104 0 return( $self->{_as_string} );
105 }
106  
107 sub reset
108 0 ▶{
Subroutine reset: not called CC=1 SCAR=6.9
Pod documented
109 0 my $self = shift( @_ );
110 0 delete( @$self{ qw( _as_css_grid _as_markdown _as_string ) } );
111 0 return( $self );
112 }
113  
114 1 1;
115 # NOTE: POD
116 __END__
« Parser/Document.pm ↑ Summary Parser/TableHeader.pm »