blib/lib/XML/Grammar/Fiction/FromProto/Parser/QnD.pm

filter: Statementstmt 97.2% 71 / 73 Branchbran 75.0% 9 / 12 Conditioncond 77.7% 7 / 9 MC/DCmcdc 66.6% 4 / 6 Subroutinesub 100% 17 / 17 Podpod n/a totaltotal 92.3% 108 / 117 CC 10 SCAR 12.3
CC
10
Cov
93%
_generate_non_tag_text_event
8.3
_handle_open_para
2.0
_look_ahead_for_tag
2.0
CRAP 3.4
« blib/lib/XML/Grammar/Fiction/FromProto.pm ↑ Summary blib/lib/XML/Grammar/Screenplay/FromProto.pm »
1 package XML::Grammar::Fiction::FromProto::Parser::QnD;
2 19 $XML::Grammar::Fiction::FromProto::Parser::QnD::VERSION = '0.32.0';
3 21 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 21 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 21 ▶use MooX 'late';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 19 extends("XML::Grammar::FictionBase::FromProto::Parser::XmlIterator");
9  
10 21 ▶use XML::Grammar::Fiction::Struct::Tag ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 21 ▶use XML::Grammar::Fiction::Err ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 21 ▶use XML::Grammar::FictionBase::Event ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 sub _non_tag_text_unit_consume_regex
16 257 ▶{
Subroutine _non_tag_text_unit_consume_regex: called CC=1 SCAR=0.0
17 257 return qr{(?:[\<]|^\n?$)}ms;
18 }
19  
20 sub _generate_non_tag_text_event
21 257 ▶{
Subroutine _generate_non_tag_text_event: called CC=8 SCAR=21.2
22 257 my $self = shift;
23  
24 257 my $is_para = $self->at_line_start;
25  
26 257 my $status = $self->_parse_non_tag_text_unit();
27  
28 256 ▶ if ( !defined($status) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $status) 0 256 256
29 {
30 0 return;
31 }
32  
33 256 my $elem = $status->{'elem'};
34 256 my $is_para_end = $status->{'para_end'};
35  
36 256 my $in_para = $self->_in_para();
37 256 ▶ if ( $is_para && !$in_para )
Branch: 1 branch
BranchTrueFalseTotal
if ($is_para and not $in_para) 121 135 256
Condition66%2/3
$is_para and not $in_para
!ll&&!rl&&r
1350121
MC/DC50%1/2
$is_para and not $in_para
$is_para not $in_para
Truth table66%2/3
A and not(B)
A= $is_paraB= not $in_para
ABresult
0X0
100
111
38 {
39 121 $self->_enqueue_event(
40 XML::Grammar::FictionBase::Event->new(
41 { type => "open", tag => "para", }
42 ),
43 );
44 121 $in_para = 1;
45 }
46  
47 256 ▶ if ( my ($rest) = $elem->get_text() =~ m{\A\+(.*)}ms )
Branch: 1 branch
BranchTrueFalseTotal
if (my($rest) = $elem->get_text =~ /\A\+(.*)/ms) { } 1 255 256
48 {
49 1 ▶ if ( length($rest) )
Branch: 1 branch
BranchTrueFalseTotal
if (length $rest) 0 1 1
50 {
51 0 $self->throw_text_error(
52 'XML::Grammar::Fiction::Err::Parse::ParaOpenPlusNotFollowedByTag',
53 "Got a paragraph opening plus sign not followed by a tag.",
54 );
55 }
56  
57 # Else - do nothing - just ignore the + sign before the
58 # style tag.
59 }
60 else
61 {
62 255 $self->_enqueue_event(
63 XML::Grammar::FictionBase::Event->new(
64 { type => "elem", elem => $elem }
65 )
66 );
67 }
68  
69 256 ▶ if ( $is_para_end && $in_para )
Branch: 1 branch
BranchTrueFalseTotal
if ($is_para_end and $in_para) 119 137 256
Condition66%2/3
$is_para_end and $in_para
!ll&&!rl&&r
1370119
MC/DC50%1/2
$is_para_end and $in_para
$is_para_end $in_para
Truth table66%2/3
A and B
A= $is_para_endB= $in_para
ABresult
0X0
100
111
70 {
71 119 $self->_enqueue_event(
72 XML::Grammar::FictionBase::Event->new(
73 { type => "close", tag => "para" }
74 )
75 );
76 119 $in_para = 0;
77 }
78  
79 256 return;
80 }
81  
82 627 ▶before '_generate_text_unit_events' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
83 627 my $self = shift;
84  
85 627 $self->skip_multiline_space();
86  
87 626 return;
88 19 };
89  
90 sub _calc_open_para
91 121 ▶{
Subroutine _calc_open_para: called CC=1 SCAR=0.0
92 121 my $self = shift;
93  
94 121 return XML::Grammar::Fiction::Struct::Tag::Para->new(
95 name => "p",
96 is_standalone => 0,
97 line => $self->line_num(),
98 attrs => [],
99 children => [],
100 );
101 }
102  
103 sub _handle_open_para
104 121 ▶{
Subroutine _handle_open_para: called CC=2 SCAR=7.0
105 121 my ( $self, $event ) = @_;
106  
107 121 ▶ die if $self->_in_para();
Branch: 1 branch
BranchTrueFalseTotal
if $self->_in_para 0 121 121
108  
109 121 $self->_push_tag( $self->_calc_open_para() );
110  
111 121 $self->_in_para(1);
112  
113 121 return;
114 }
115  
116 sub _handle_close_para
117 119 ▶{
Subroutine _handle_close_para: called CC=1 SCAR=0.0
118 119 my ( $self, $event ) = @_;
119  
120 119 my $open = $self->_pop_tag;
121  
122 119 my $new_elem = $self->_new_para( $open->detach_children(), );
123  
124 119 $self->_add_to_top_tag($new_elem);
125  
126 119 $self->_in_para(0);
127  
128 119 return;
129 }
130  
131 sub _list_valid_tag_events
132 4 ▶{
Subroutine _list_valid_tag_events: called CC=1 SCAR=0.0
133 4 return [qw(para)];
134 }
135  
136 202 ▶before '_handle_close_tag' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
137 202 my $self = shift;
138  
139 202 $self->skip_space();
140 19 };
141  
142 sub _look_ahead_for_tag
143 940 ▶{
Subroutine _look_ahead_for_tag: called CC=2 SCAR=6.9
144 940 my $self = shift;
145  
146 940 my $l = $self->curr_line_copy();
147  
148 940 my $is_tag_cond = ( $$l =~ m{\G<}cg );
149 940 ▶ my $is_close = $is_tag_cond && ( $$l =~ m{\G/}cg );
Condition100%3/3
$is_tag_cond && $$l =~ m[\G/]cg
!ll&&!rl&&r
529209202
MC/DC100%2/2
$is_tag_cond && $$l =~ m[\G/]cg
$is_tag_cond $$l =~ m[\G/]cg
Truth table100%3/3
A && B
A= $is_tag_condB= $$l =~ m[\G/]cg
ABresult
0X0
100
111
150  
151 940 return ( $is_tag_cond, $is_close );
152 }
153  
154 sub _main_loop_iter_body_prelude
155 940 ▶{
Subroutine _main_loop_iter_body_prelude: called CC=1 SCAR=0.0
156 940 my $self = shift;
157  
158 # $self->skip_space();
159  
160 940 return 1;
161 }
162  
163 23 ▶before '_parse_all' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
164 23 my $self = shift;
165  
166 23 $self->skip_space();
167  
168 23 return;
169 19 };
170  
171  
172 19 1;
173  
174 __END__
« blib/lib/XML/Grammar/Fiction/FromProto.pm ↑ Summary blib/lib/XML/Grammar/Screenplay/FromProto.pm »