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

filter: Statementstmt 93.1% 203 / 218 Branchbran 85.0% 51 / 60 Conditioncond 91.6% 33 / 36 MC/DCmcdc 77.2% 17 / 22 Subroutinesub 94.2% 49 / 52 Podpod n/a totaltotal 90.9% 353 / 388 CC 43 SCAR 13.0
CC
43
Cov
91%
_generate_non_tag_text_event
13.1
_handle_saying_event
6.0
_parse_speech_unit
4.0
CRAP 3.7
« Build ↑ Summary blib/lib/XML/Grammar/Fiction/FromProto.pm »
1 package XML::Grammar::Screenplay::FromProto::Parser::QnD;
2 9 $XML::Grammar::Screenplay::FromProto::Parser::QnD::VERSION = '0.22.0';
3 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 9 ▶use MooX 'late';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 9 extends('XML::Grammar::FictionBase::FromProto::Parser::XmlIterator');
9  
10 9 ▶use XML::Grammar::Fiction::Struct::Tag ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 9 ▶use XML::Grammar::FictionBase::Event ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 9 ▶use List::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 9 ▶use List::MoreUtils ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 9 has "_in_saying" => ( isa => "Bool", is => "rw" );
17 9 has "_prev_line_is_empty" => ( isa => "Bool", is => "rw", default => 1 );
18 9 has '_is_start' => ( isa => 'Bool', is => 'rw' );
19  
20 before 'next_line_ref' => sub {
21 669 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
22  
23 $self->_prev_line_is_empty(
24 669 scalar( ${ $self->curr_line_ref() } =~ m{\A\s*\z} ) );
25  
26 669 return;
27 9 };
28  
29 sub _top_is_para
30 {
31 499 ▶ my $self = shift;
Subroutine _top_is_para: called CC=2 SCAR=6.9
32  
33 499 ▶ return $self->_in_para() && ( $self->_top_is('p') );
Condition100%3/3
$self->_in_para && $self->_top_is('p')
!ll&&!rl&&r
25144204
MC/DC100%2/2
$self->_in_para && $self->_top_is('p')
$self->_in_para $self->_top_is('p')
Truth table100%3/3
A && B
A= $self->_in_paraB= $self->_top_is('p')
ABresult
0X0
100
111
34 }
35  
36 sub _top_is_saying
37 {
38 197 ▶ my $self = shift;
Subroutine _top_is_saying: called CC=2 SCAR=6.9
39  
40 197 ▶ return $self->_in_saying() && ( $self->_top_is('saying') );
Condition100%3/3
$self->_in_saying && $self->_top_is('saying')
!ll&&!rl&&r
1243340
MC/DC100%2/2
$self->_in_saying && $self->_top_is('saying')
$self->_in_saying $self->_top_is('saying')
Truth table100%3/3
A && B
A= $self->_in_sayingB= $self->_top_is('saying')
ABresult
0X0
100
111
41 }
42  
43 sub _top_is
44 {
45 787 ▶ my ( $self, $want_name ) = @_;
Subroutine _top_is: called CC=1 SCAR=0.0
46  
47 787 return ( $self->_top_tag->name eq $want_name );
48 }
49  
50 sub _top_is_desc
51 {
52 466 ▶ my $self = shift;
Subroutine _top_is_desc: called CC=1 SCAR=0.0
53  
54 466 return $self->_top_is('desc');
55 }
56  
57 around '_pop_tag' => sub {
58 456 ▶ my ( $orig, $self ) = @_;
Subroutine __ANON__: called CC=2 SCAR=6.9
59  
60 456 my $open = $self->$orig();
61  
62 456 ▶ if ( $open->name() eq "saying" )
Branch: 1 branch
BranchTrueFalseTotal
if ($open->name eq "saying") 103 353 456
63 {
64 103 $self->_in_saying(0);
65 }
66  
67 456 return $open;
68 9 };
69  
70 sub _count_tags_in_stack
71 {
72 924 ▶ my $self = shift;
Subroutine _count_tags_in_stack: called CC=1 SCAR=0.0
73 924 my $name = shift;
74  
75 924 ▶ my @tags = $self->_grep_tags_stack( sub { $_->name() eq $name; } );
Subroutine __ANON__: called CC=1 SCAR=0.0
76  
77 924 return scalar(@tags);
78 }
79  
80 after '_push_tag' => sub {
81 462 ▶ my $self = shift;
Subroutine __ANON__: called CC=3 SCAR=12.7
82  
83 # This is an assert - it must never happen.
84 462 ▶ if ( $self->_count_tags_in_stack("p") == 2 )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_count_tags_in_stack("p") == 2) 0 462 462
85 {
86 0 Carp::confess(qq{Two paragraphs in the tags stack.});
87 }
88  
89 # This is an assert - it must never happen.
90 462 ▶ if ( $self->_count_tags_in_stack("saying") == 2 )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_count_tags_in_stack("saying") == 2) 0 462 462
91 {
92 0 Carp::confess(qq{Two sayings in the tags stack at the same time.});
93 }
94  
95 462 return;
96 9 };
97  
98 sub _new_saying
99 {
100 207 ▶ my $self = shift;
Subroutine _new_saying: called CC=1 SCAR=0.0
101 207 my $sayer = shift;
102 207 my $contents = shift;
103  
104 207 return $self->_new_node(
105 {
106 t => "Saying",
107 character => $sayer,
108 children => $self->_new_list($contents),
109 }
110 );
111 }
112  
113 sub _get_desc_name
114 {
115 55 ▶ my $self = shift;
Subroutine _get_desc_name: called CC=2 SCAR=6.9
116  
117 55 ▶ return ( $self->_in_para() ? "innerdesc" : "desc" );
Branch: 1 branch
BranchTrueFalseTotal
$self->_in_para ? : 8 47 55
118 }
119  
120 sub _create_closing_desc_tag
121 {
122 51 ▶ my $self = shift;
Subroutine _create_closing_desc_tag: called CC=1 SCAR=0.0
123  
124 51 return XML::Grammar::Fiction::Struct::Tag->new(
125 name => $self->_get_desc_name(),
126 line => $self->line_num(),
127 );
128 }
129  
130 sub _detect_closing_desc_tag
131 {
132 149 ▶ my $self = shift;
Subroutine _detect_closing_desc_tag: called CC=1 SCAR=0.0
133  
134 149 return ( ${ $self->curr_line_ref() } =~ m{\G\]}cg );
135 }
136  
137 around '_parse_closing_tag' => sub {
138 149 ▶ my ( $orig, $self ) = @_;
Subroutine __ANON__: called CC=2 SCAR=6.9
139  
140 149 ▶ return $self->_detect_closing_desc_tag
Branch: 1 branch
BranchTrueFalseTotal
$self->_detect_closing_desc_tag ? : 51 98 149
141 ? $self->_create_closing_desc_tag
142 : $self->$orig();
143 9 };
144  
145 sub _detect_open_desc_tag
146 {
147 173 ▶ my $self = shift;
Subroutine _detect_open_desc_tag: called CC=1 SCAR=0.0
148  
149 173 return ( ${ $self->curr_line_ref } =~ m{\G\[}cg );
150 }
151  
152 sub _create_open_desc_tag
153 {
154 52 ▶ my ($self) = @_;
Subroutine _create_open_desc_tag: called CC=4 SCAR=13.9
155  
156 52 my $not_inline = 0;
157 52 ▶ if ( $self->_is_start && $self->_prev_line_is_empty() )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_start and $self->_prev_line_is_empty) 48 4 52
Condition100%3/3
$self->_is_start and $self->_prev_line_is_empty
!ll&&!rl&&r
3148
MC/DC100%2/2
$self->_is_start and $self->_prev_line_is_empty
$self->_is_start $self->_prev_line_is_empty
Truth table100%3/3
A and B
A= $self->_is_startB= $self->_prev_line_is_empty
ABresult
0X0
100
111
158 {
159 48 $self->_close_top_tags();
160 48 $not_inline = 1;
161 }
162  
163 52 ▶ return XML::Grammar::Fiction::Struct::Tag->new(
Branch: 1 branch
BranchTrueFalseTotal
$not_inline ? : 48 4 52
164 name => $not_inline ? "desc" : $self->_get_desc_name(),
165 line => $self->line_num(),
166 attrs => [],
167 );
168 }
169  
170 sub _set_is_start
171 {
172 173 ▶ my $self = shift;
Subroutine _set_is_start: called CC=1 SCAR=0.0
173  
174 173 $self->_is_start( $self->at_line_start );
175  
176 173 return;
177 }
178  
179 around '_parse_opening_tag' => sub {
180 173 ▶ my ( $orig, $self ) = @_;
Subroutine __ANON__: called CC=2 SCAR=6.9
181  
182 173 $self->_set_is_start;
183  
184 173 ▶ return $self->_detect_open_desc_tag
Branch: 1 branch
BranchTrueFalseTotal
$self->_detect_open_desc_tag ? : 52 121 173
185 ? $self->_create_open_desc_tag
186 : $self->$orig();
187 9 };
188  
189 sub _parse_speech_unit
190 {
191 137 ▶ my $self = shift;
Subroutine _parse_speech_unit: called CC=4 SCAR=13.9
192  
193 137 ▶ if ( ${ $self->curr_line_ref() } !~ /\G([^:\n]+): /cgms )
Branch: 1 branch
BranchTrueFalseTotal
unless (${$self->curr_line_ref;} =~ /\G([^:\n]+): /cgms) 0 137 137
194 {
195 0 Carp::confess( "Cannot match addressing at line " . $self->line_num() );
196 }
197  
198 137 my $sayer = $1;
199  
200 137 ▶ if ( $sayer =~ m{[\[\]]} )
Branch: 1 branch
BranchTrueFalseTotal
if ($sayer =~ /[\[\]]/) 1 136 137
201 {
202 1 Carp::confess(
203 "Tried to put an inner-desc inside an addressing at line "
204 . $self->line_num() );
205 }
206  
207 # All pluses
208 136 ▶ if ( $sayer =~ m{\A\++\z} )
Branch: 1 branch
BranchTrueFalseTotal
if ($sayer =~ /\A\++\z/) { } 32 104 136
209 {
210 32 return { elem => $self->_new_para( [] ), para_end => 0 };
211 }
212 else
213 {
214 return {
215 104 elem => $self->_new_saying( $sayer, [] ),
216 sayer => $sayer,
217 para_end => 0
218 };
219 }
220 }
221  
222 sub _non_tag_text_unit_consume_regex
223 {
224 593 ▶ return qr{(?:[\<\[\]]|^\n?$)}ms;
Subroutine _non_tag_text_unit_consume_regex: called CC=1 SCAR=0.0
225 }
226  
227 sub _is_there_a_speech_unit
228 {
229 730 ▶ my $self = shift;
Subroutine _is_there_a_speech_unit: called CC=3 SCAR=11.0
230  
231 730 my $l = $self->curr_line_ref();
232  
233 730 ▶ return ( $self->at_line_start()
Condition100%6/6
$self->at_line_start && !$self->_top_is_desc && $$l =~ /\A[^\[][^:]*:/
!ll&&!rl&&r
448145137
$self->at_line_start and not $self->_top_is_desc
!ll&&!rl&&r
43612282
MC/DC100%3/3
$self->at_line_start && !$self->_top_is_desc && $$l =~ /\A[^\[][^:]*:/
$self->at_line_start not $self->_top_is_desc $$l =~ /\A[^\[][^:]*:/
Truth table100%4/4
A and not(B) && C
A= $self->at_line_startB= not $self->_top_is_descC= $$l =~ /\A[^\[][^:]*:/
ABCresult
0XX0
10X0
1100
1111
234 && ( !$self->_top_is_desc() )
235 && ( $$l =~ m{\A[^\[][^:]*:} ) );
236 }
237  
238 around '_parse_non_tag_text_unit' => sub {
239 730 ▶ my ( $orig, $self ) = @_;
Subroutine __ANON__: called CC=2 SCAR=6.9
240  
241 return (
242 730 ▶ $self->_is_there_a_speech_unit()
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_there_a_speech_unit ? : 137 593 730
243 ? $self->_parse_speech_unit()
244 : $self->$orig()
245 );
246 9 };
247  
248 sub _look_for_tag_opener
249 {
250 862 ▶ my $self = shift;
Subroutine _look_for_tag_opener: called CC=2 SCAR=6.9
251  
252 862 my $l = $self->curr_line_ref();
253  
254 862 ▶ if ( $$l =~ m{\G([<\[\]])} )
Branch: 1 branch
BranchTrueFalseTotal
if ($$l =~ /\G([<\[\]])/) { } 132 730 862
255 {
256 132 return $1;
257 }
258 else
259 {
260 730 return;
261 }
262 }
263  
264 sub _is_closing_tag
265 {
266 132 ▶ my $self = shift;
Subroutine _is_closing_tag: called CC=1 SCAR=0.0
267 132 my $tag_start = shift;
268  
269 132 return ( ${ $self->curr_line_ref() } =~ m{\G(</|\])} );
270 }
271  
272 sub _generate_non_tag_text_event
273 {
274 730 ▶ my $self = shift;
Subroutine _generate_non_tag_text_event: called CC=13 SCAR=25.7
275 730 my $status = $self->_parse_non_tag_text_unit();
276  
277 729 ▶ if ( !defined($status) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $status) 303 426 729
278 {
279 303 return;
280 }
281  
282 426 my $elem = $status->{'elem'};
283 426 my $is_para_end = $status->{'para_end'};
284 426 my $is_saying =
285 $elem->isa("XML::Grammar::Fiction::FromProto::Node::Saying");
286 426 my $is_para =
287 $elem->isa("XML::Grammar::Fiction::FromProto::Node::Paragraph");
288  
289 426 my $in_para = $self->_in_para();
290 426 my $was_already_enqueued = 0;
291  
292 426 ▶ if ( ( $is_saying || $is_para ) && $in_para )
Branch: 1 branch
BranchTrueFalseTotal
if ($is_saying || $is_para and $in_para) 0 426 426
Condition83%5/6
$is_saying || $is_para and $in_para
!ll&&!rl&&r
2901360
$is_saying or $is_para
l!l&&r!l&&!r
10432290
MC/DC0%0/3
$is_saying || $is_para and $in_para
$is_saying $is_para $in_para
Truth table60%3/5
A or B and C
A= $is_sayingB= $is_paraC= $in_para
ABCresult
00X0
1X00
0100
1X11
0111
293 {
294 0 $self->_enqueue_event(
295 XML::Grammar::FictionBase::Event->new(
296 { type => "close", tag => "para" }
297 )
298 );
299 0 $in_para = 0;
300 }
301  
302 426 ▶ if ( $is_saying && $self->_in_saying() )
Branch: 1 branch
BranchTrueFalseTotal
if ($is_saying and $self->_in_saying) 63 363 426
Condition100%3/3
$is_saying and $self->_in_saying
!ll&&!rl&&r
3224163
MC/DC100%2/2
$is_saying and $self->_in_saying
$is_saying $self->_in_saying
Truth table100%3/3
A and B
A= $is_sayingB= $self->_in_saying
ABresult
0X0
100
111
303 {
304 63 $self->_enqueue_event(
305 XML::Grammar::FictionBase::Event->new(
306 { type => "close", tag => "saying" }
307 )
308 );
309 }
310  
311 426 ▶ if ($is_saying)
Branch: 2 branches
BranchTrueFalseTotal
if ($is_saying) { } 104 322 426
elsif ($is_para and not $in_para) { } 32 580 612
312 {
313 104 $self->_enqueue_event(
314 XML::Grammar::FictionBase::Event->new(
315 { type => "open", tag => "saying", tag_elem => $elem, },
316 ),
317 );
318 104 $was_already_enqueued = 1;
319  
320 104 $self->_enqueue_event(
321 XML::Grammar::FictionBase::Event->new(
322 { type => "open", tag => "para" }
323 )
324 );
325 104 $in_para = 1;
326 }
327 ▶ elsif ( $is_para && !$in_para )
Condition66%2/3
$is_para and not $in_para
!ll&&!rl&&r
290032
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
328 {
329 32 $self->_enqueue_event(
330 XML::Grammar::FictionBase::Event->new(
331 { type => "open", tag => "para" }
332 ),
333 );
334 32 $in_para = 1;
335 }
336  
337 426 ▶ if ( $elem->isa("XML::Grammar::Fiction::FromProto::Node::Text")
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa("XML::Grammar::Fiction::FromProto::Node::Text") and not $was_already_enqueued) 290 136 426
Condition100%3/3
$elem->isa("XML::Grammar::Fiction::FromProto::Node::Text") and not $was_already_enqueued
!ll&&!rl&&r
32104290
MC/DC100%2/2
$elem->isa("XML::Grammar::Fiction::FromProto::Node::Text") and not $was_already_enqueued
$elem->isa("XML::Grammar::Fiction::FromProto::Node::Text") not $was_already_enqueued
Truth table100%3/3
A and not(B)
A= $elem->isa("XML::Grammar::Fiction::FromProto::Node::Text")B= not $was_already_enqueued
ABresult
0X0
100
111
338 && !$was_already_enqueued )
339 {
340 290 ▶ if ( !$in_para )
Branch: 1 branch
BranchTrueFalseTotal
unless ($in_para) 13 277 290
341 {
342 13 $self->_enqueue_event(
343 XML::Grammar::FictionBase::Event->new(
344 { type => "open", tag => "para" },
345 )
346 );
347 13 $in_para = 1;
348 }
349 $self->_enqueue_event(
350 290 XML::Grammar::FictionBase::Event->new(
351 { type => "elem", elem => $elem, }
352 )
353 );
354 290 $was_already_enqueued = 1;
355 }
356  
357 426 return;
358 }
359  
360 sub _handle_close_saying
361 {
362 103 ▶ my $self = shift;
Subroutine _handle_close_saying: called CC=2 SCAR=7.1
363 103 my $open = $self->_pop_tag();
364  
365 # This is an assert.
366 103 ▶ if ( $open->name() ne "saying" )
Branch: 1 branch
BranchTrueFalseTotal
if ($open->name ne "saying") 0 103 103
367 {
368 0 Carp::confess(qq{Not a saying tag.});
369 }
370  
371 my $new_elem = $self->_new_saying(
372 (
373 103 ▶ List::Util::first { $_->{key} eq "character" }
Subroutine __ANON__: called CC=1 SCAR=0.0
374 103 @{ $open->attrs() }
375 )->{value},
376 103 $open->detach_children(),
377 );
378  
379 103 $self->_add_to_top_tag($new_elem);
380  
381 103 return;
382 }
383  
384 sub _assert_top_is_para
385 {
386 204 ▶ my ( $self, $open ) = @_;
Subroutine _assert_top_is_para: called CC=2 SCAR=7.6
387  
388 204 ▶ if ( $open->name() ne "p" )
Branch: 1 branch
BranchTrueFalseTotal
if ($open->name ne "p") 0 204 204
389 {
390 0 Carp::confess(qq{Not a para tag.});
391 }
392  
393 204 return;
394 }
395  
396 sub _process_closed_para
397 {
398 204 ▶ my ( $self, $open ) = @_;
Subroutine _process_closed_para: called CC=3 SCAR=11.0
399  
400 204 my $children = $open->detach_children();
401  
402 # Filter away empty paragraphs.
403 204 ▶ if ( defined($children) && @$children )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $children and @$children) 191 13 204
Condition66%2/3
defined $children and @$children
!ll&&!rl&&r
013191
MC/DC50%1/2
defined $children and @$children
defined $children @$children
Truth table66%2/3
A and B
A= defined $childrenB= @$children
ABresult
0X0
100
111
404 {
405 191 $self->_add_to_top_tag( $self->_new_para($children) );
406 }
407  
408 204 return;
409 }
410  
411 sub _close_para
412 {
413 204 ▶ my $self = shift;
Subroutine _close_para: called CC=1 SCAR=0.0
414  
415 204 my $open = $self->_pop_tag();
416  
417 204 $self->_assert_top_is_para($open);
418  
419 204 $self->_process_closed_para($open);
420  
421 204 $self->_in_para(0);
422  
423 204 return;
424 }
425  
426 sub _create_start_para
427 {
428 204 ▶ my $self = shift;
Subroutine _create_start_para: called CC=1 SCAR=0.0
429  
430 204 return XML::Grammar::Fiction::Struct::Tag::Para->new(
431 name => "p",
432 is_standalone => 0,
433 line => $self->line_num(),
434 attrs => [],
435 children => [],
436 );
437 }
438  
439 sub _start_para
440 {
441 204 ▶ my $self = shift;
Subroutine _start_para: called CC=1 SCAR=0.0
442  
443 204 $self->_push_tag( $self->_create_start_para() );
444  
445 204 $self->_in_para(1);
446  
447 204 return;
448 }
449  
450 sub _close_top_tags
451 {
452 197 ▶ my $self = shift;
Subroutine _close_top_tags: called CC=3 SCAR=11.0
453  
454 197 ▶ if ( $self->_top_is_para() )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_top_is_para) 40 157 197
455 {
456 40 $self->_close_para();
457 }
458  
459 197 ▶ if ( $self->_top_is_saying() )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_top_is_saying) 40 157 197
460 {
461 40 $self->_handle_close_saying();
462 }
463  
464 197 return;
465 }
466  
467 sub _handle_close_para
468 {
469 0 ▶ my ( $self, $event ) = @_;
Subroutine _handle_close_para: not called CC=1 SCAR=6.9
470  
471 0 return $self->_close_para();
472 }
473  
474 sub _handle_open_para
475 {
476 149 ▶ my ( $self, $event ) = @_;
Subroutine _handle_open_para: called CC=1 SCAR=0.0
477  
478 149 return $self->_start_para();
479 }
480  
481 sub _create_open_saying_tag
482 {
483 104 ▶ my $self = shift;
Subroutine _create_open_saying_tag: called CC=1 SCAR=0.0
484 104 my $event = shift;
485  
486 104 return XML::Grammar::Fiction::Struct::Tag->new(
487 {
488 name => "saying",
489 is_standalone => 0,
490  
491 # TODO : propagate the correct line_num
492 # from the called-to layers.
493 line => $self->line_num(),
494 attrs => [
495 { key => "character", value => $event->tag_elem->character() }
496 ],
497 children => [],
498 }
499 );
500 }
501  
502 sub _handle_open_saying
503 {
504 104 ▶ my ( $self, $event ) = @_;
Subroutine _handle_open_saying: called CC=1 SCAR=0.0
505  
506 104 $self->_push_tag( $self->_create_open_saying_tag($event) );
507  
508 104 $self->_in_saying(1);
509  
510 104 return;
511 }
512  
513 sub _handle_saying_event
514 {
515 0 ▶ my ( $self, $event ) = @_;
Subroutine _handle_saying_event: not called CC=2 SCAR=17.9
516  
517 0 ▶ return $event->is_open()
Branch: 1 branch
BranchTrueFalseTotal
$event->is_open ? : 0 0 0
518 ? $self->_handle_open_saying($event)
519 : $self->_handle_close_saying();
520 }
521  
522 sub _list_valid_tag_events
523 {
524 5 ▶ return [qw(para saying)];
Subroutine _list_valid_tag_events: called CC=1 SCAR=0.0
525 }
526  
527 after '_handle_open_tag' => sub {
528 172 ▶ my $self = shift;
Subroutine __ANON__: called CC=2 SCAR=6.9
529  
530 172 ▶ if ( $self->_top_is_desc )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_top_is_desc) 55 117 172
531 {
532 55 $self->_start_para();
533 }
534  
535 172 return;
536 9 };
537  
538 before '_handle_close_tag' => sub {
539 149 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
540  
541 149 $self->_close_top_tags();
542 9 };
543  
544 sub _look_ahead_for_tag
545 {
546 906 ▶ my $self = shift;
Subroutine _look_ahead_for_tag: called CC=2 SCAR=6.9
547  
548 906 my $l = $self->curr_line_copy();
549  
550 906 my $is_tag_cond = ( $$l =~ m{\G([<\[\]])} );
551  
552 906 ▶ my $is_close = $is_tag_cond && ( $$l =~ m{\G(?:</|\])} );
Condition100%3/3
$is_tag_cond && $$l =~ m(\G(?:</|\]))
!ll&&!rl&&r
585172149
MC/DC100%2/2
$is_tag_cond && $$l =~ m(\G(?:</|\]))
$is_tag_cond $$l =~ m(\G(?:</|\]))
Truth table100%3/3
A && B
A= $is_tag_condB= $$l =~ m(\G(?:</|\]))
ABresult
0X0
100
111
553  
554 906 return ( $is_tag_cond, $is_close );
555 }
556  
557 sub _main_loop_iter_on_empty_line
558 {
559 302 ▶ my $self = shift;
Subroutine _main_loop_iter_on_empty_line: called CC=2 SCAR=6.9
560  
561 302 ▶ if ( $self->_top_is_para() )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_top_is_para) 164 138 302
562 {
563 164 $self->_close_para();
564 }
565  
566 302 $self->next_line_ref();
567  
568 302 return;
569 }
570  
571 sub _main_loop_iter_on_whitepsace
572 {
573 0 ▶ my $self = shift;
Subroutine _main_loop_iter_on_whitepsace: not called CC=1 SCAR=6.9
574  
575 0 $self->_add_to_top_tag( $self->_new_text( [" "] ) );
576  
577 0 $self->next_line_ref();
578  
579 0 return;
580 }
581  
582 sub _main_loop_iter_body_prelude
583 {
584 1208 ▶ my $self = shift;
Subroutine _main_loop_iter_body_prelude: called CC=3 SCAR=11.1
585  
586 1208 my $l = $self->curr_line_ref();
587  
588 return (
589 1208 ▶ ( $$l eq "\n" ) ? $self->_main_loop_iter_on_empty_line
Branch: 2 branches
BranchTrueFalseTotal
$$l eq "\n" ? : 302 906 1208
$$l =~ /\G[ \t]+\n?\z/ ? : 0 906 906
590 : ( $$l =~ m{\G[ \t]+\n?\z} ) ? $self->_main_loop_iter_on_whitepsace
591 : 1
592 );
593 }
594  
595  
596 9 1;
597  
598 __END__
599  
600 =pod
601  
602 =encoding UTF-8
603  
604 =head1 NAME
605  
606 XML::Grammar::Screenplay::FromProto::Parser::QnD - Quick and Dirty parser
607 for the Screenplay-XML proto-text.
608  
609 B<For internal use only>.
610  
611 =head1 VERSION
612  
613 version 0.22.0
614  
615 =head1 METHODS
616  
617 =head2 $self->process_text($string)
618  
619 Processes the text and returns the parse tree.
620  
621 =head2 $self->meta()
622  
623 Leftover from Moo.
624  
625 =head2 $self->next_line_ref
626  
627 Leftover from Moo.
628  
629 =for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
630  
631 =head1 SUPPORT
632  
633 =head2 Websites
634  
635 The following websites have more information about this module, and may be of help to you. As always,
636 in addition to those websites please use your favorite search engine to discover more resources.
637  
638 =over 4
639  
640 =item *
641  
642 MetaCPAN
643  
644 A modern, open-source CPAN search engine, useful to view POD in HTML format.
645  
646 L<https://metacpan.org/release/XML-Grammar-Fiction>
647  
648 =item *
649  
650 RT: CPAN's Bug Tracker
651  
652 The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.
653  
654 L<https://rt.cpan.org/Public/Dist/Display.html?Name=XML-Grammar-Fiction>
655  
656 =item *
657  
658 CPANTS
659  
660 The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.
661  
662 L<http://cpants.cpanauthors.org/dist/XML-Grammar-Fiction>
663  
664 =item *
665  
666 CPAN Testers
667  
668 The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions.
669  
670 L<http://www.cpantesters.org/distro/X/XML-Grammar-Fiction>
671  
672 =item *
673  
674 CPAN Testers Matrix
675  
676 The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.
677  
678 L<http://matrix.cpantesters.org/?dist=XML-Grammar-Fiction>
679  
680 =item *
681  
682 CPAN Testers Dependencies
683  
684 The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.
685  
686 L<http://deps.cpantesters.org/?module=XML::Grammar::Fiction>
687  
688 =back
689  
690 =head2 Bugs / Feature Requests
691  
692 Please report any bugs or feature requests by email to C<bug-xml-grammar-fiction at rt.cpan.org>, or through
693 the web interface at L<https://rt.cpan.org/Public/Bug/Report.html?Queue=XML-Grammar-Fiction>. You will be automatically notified of any
694 progress on the request by the system.
695  
696 =head2 Source Code
697  
698 The code is open to the world, and available for you to hack on. Please feel free to browse it and play
699 with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
700 from your repository :)
701  
702 L<https://github.com/shlomif/fiction-xml>
703  
704 git clone git://github.com/shlomif/fiction-xml.git
705  
706 =head1 AUTHOR
707  
708 Shlomi Fish <shlomif@cpan.org>
709  
710 =head1 BUGS
711  
712 Please report any bugs or feature requests on the bugtracker website
713 L<https://github.com/shlomif/fiction-xml/issues>
714  
715 When submitting a bug or request, please include a test-file or a
716 patch to an existing test-file that illustrates the bug or desired
717 feature.
718  
719 =head1 COPYRIGHT AND LICENSE
720  
721 This software is Copyright (c) 2007 by Shlomi Fish.
722  
723 This is free software, licensed under:
724  
725 The MIT (X11) License
726  
727 =cut
« Build ↑ Summary blib/lib/XML/Grammar/Fiction/FromProto.pm »