lib/Text/Xatena/Node/DefinitionList.pm

filter: Statementstmt 100% 38 / 38 Branchbran 100% 8 / 8 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 3 totaltotal 95.2% 60 / 63 CC 7 SCAR 9.6
CC
7
Cov
100%
parse
4.0
as_struct
4.0
BEGIN
1.0
CRAP 2.6
« blib/lib/Text/Xatena/LineScanner.pm ↑ Summary lib/Text/Xatena/Node/Pre.pm »
1 package Text::Xatena::Node::DefinitionList;
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  
6 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 19 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 19 ▶use base qw(Text::Xatena::Node);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 19 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
10 19 DL => qr/^:([^:]*):(.*)/,
11 19 };
12  
13 332 ▶sub parse {
Subroutine parse: called CC=4 SCAR=13.9
Pod undocumented
14 332 my ($class, $s, $parent, $stack) = @_;
15 332 ▶ if ($s->scan(DL)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s->scan(qr/^:([^:]*):(.*)/)) 8 324 332
16 8 my $node = $class->new([ $s->matched->[0] ]);
17 8 ▶ until ($s->eos || !$s->scan(DL)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s->eos or not $s->scan(qr/^:([^:]*):(.*)/)) 11 8 19
Condition100%3/3
$s->eos or not $s->scan(qr/^:([^:]*):(.*)/)
l!l&&r!l&&!r
4411
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
18 11 push @$node, $s->matched->[0];
19 }
20 8 push @$parent, $node;
21 8 return 1;
22 }
23 }
24  
25 ## NOT COMPATIBLE WITH Hatena Syntax
26 8 ▶sub as_struct {
Subroutine as_struct: called CC=4 SCAR=13.9
Pod undocumented
27 8 my ($self, $context) = @_;
28 8 my $ret = [];
29  
30 8 my $children = $self->children;
31  
32 8 for my $line (@$children) {
33 19 ▶ if (my ($description) = ($line =~ /^::(.+)/)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($description) = $line =~ /^::(.+)/) { } 3 16 19
34 3 push @$ret, +{
35 name => 'dd',
36 content => $context->inline->format($description),
37 };
38 } else {
39 16 my ($title, $description) = ($line =~ /^:([^:]+)(?::(.*))?$/);
40 16 push @$ret, +{
41 name => 'dt',
42 content => $context->inline->format($title),
43 };
44 16 ▶ push @$ret, +{
Branch: 1 branch
BranchTrueFalseTotal
if $description 14 2 16
45 name => 'dd',
46 content => $context->inline->format($description),
47 } if $description;
48 }
49 }
50  
51 8 $ret;
52 }
53  
54 8 ▶sub as_html {
Subroutine as_html: called CC=1 SCAR=0.0
Pod undocumented
55 8 my ($self, $context, %opts) = @_;
56  
57 8 $context->_tmpl(__PACKAGE__, q[
58 <dl>
59 ? for (@$items) {
60 <{{= $_->{name} }}>{{= $_->{content} }}</{{= $_->{name} }}>
61 ? }
62 </dl>
63 ], {
64 items => $self->as_struct($context),
65 });
66 }
67  
68  
69  
70 19 1;
71 __END__
« blib/lib/Text/Xatena/LineScanner.pm ↑ Summary lib/Text/Xatena/Node/Pre.pm »