lib/Text/Xatena/Node/Table.pm

filter: Statementstmt 100% 33 / 33 Branchbran 100% 6 / 6 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 94.4% 51 / 54 CC 7 SCAR 10.5
CC
7
Cov
100%
parse
4.0
as_struct
4.0
BEGIN
1.0
CRAP 2.8
« blib/lib/Text/Xatena/Node.pm ↑ Summary blib/lib/Text/Xatena/LineScanner.pm »
1 package Text::Xatena::Node::Table;
2  
3 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 19 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 19 ▶use base qw(Text::Xatena::Node);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 19 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 19 TABLE => qr/^\|/,
8 19 };
9  
10 324 ▶sub parse {
Subroutine parse: called CC=4 SCAR=13.9
Pod undocumented
11 324 my ($class, $s, $parent, $stack) = @_;
12 324 ▶ if ($s->scan(TABLE)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s->scan(qr/^\|/)) 4 320 324
13 4 my $a = $class->new([ $s->matched->[0] ]);
14 4 ▶ until ($s->eos || !$s->scan(TABLE)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s->eos or not $s->scan(qr/^\|/)) 7 4 11
Condition100%3/3
$s->eos or not $s->scan(qr/^\|/)
l!l&&r!l&&!r
317
MC/DC100%2/2
$s->eos or not $s->scan(qr/^\|/)
$s->eos not $s->scan(qr/^\|/)
Truth table100%3/3
A or not(B)
A= $s->eosB= not $s->scan(qr/^\|/)
ABresult
1X1
011
000
15 7 push @$a, $s->matched->[0];
16 }
17 4 push @$parent, $a;
18 4 return 1;
19 }
20 }
21  
22 3 ▶sub as_struct {
Subroutine as_struct: called CC=4 SCAR=13.9
Pod undocumented
23 3 my ($self, $context) = @_;
24 3 my $ret = [];
25 3 my $children = $self->children;
26  
27 3 for my $line (@$children) {
28 8 my $row = [];
29 8 for my $col (split /\|/, $line) {
30 32 my ($th, $content) = ($col =~ /^(\*)?(.*)$/);
31 32 ▶ push @$row, +{
Branch: 1 branch
BranchTrueFalseTotal
$th ? : 9 23 32
32 name => ($th ? 'th' : 'td'),
33 content => $context->inline->format($content),
34 };
35 }
36 8 shift @$row;
37 8 push @$ret, $row;
38 }
39  
40 3 $ret;
41 }
42  
43 3 ▶sub as_html {
Subroutine as_html: called CC=1 SCAR=0.0
Pod undocumented
44 3 my ($self, $context, %opts) = @_;
45 3 $context->_tmpl(__PACKAGE__, q[
46 <table>
47 ? for my $row (@$rows) {
48 <tr>
49 ? for my $col (@$row) {
50 <{{= $col->{name} }}>{{= $col->{content} }}</{{= $col->{name} }}>
51 ? }
52 </tr>
53 ? }
54 </table>
55 ], {
56 rows => $self->as_struct($context)
57 });
58 }
59  
60  
61 19 1;
62 __END__
« blib/lib/Text/Xatena/Node.pm ↑ Summary blib/lib/Text/Xatena/LineScanner.pm »