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

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