lib/Markdown/Parser/TableBody.pm

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