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 5 $XML::Grammar::Fiction::FromProto::Parser::QnD::VERSION = '0.22.4';
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use MooX 'late';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 extends("XML::Grammar::FictionBase::FromProto::Parser::XmlIterator");
9  
10 5 ▶use XML::Grammar::Fiction::Struct::Tag ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use XML::Grammar::Fiction::Err ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use XML::Grammar::FictionBase::Event ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 sub _non_tag_text_unit_consume_regex
16 {
17 257 ▶ return qr{(?:[\<]|^\n?$)}ms;
Subroutine _non_tag_text_unit_consume_regex: called CC=1 SCAR=0.0
18 }
19  
20 sub _generate_non_tag_text_event
21 {
22 257 ▶ my $self = shift;
Subroutine _generate_non_tag_text_event: called CC=8 SCAR=21.2
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 before '_generate_text_unit_events' => sub {
83 627 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
84  
85 627 $self->skip_multiline_space();
86  
87 626 return;
88 5 };
89  
90 sub _calc_open_para
91 {
92 121 ▶ my $self = shift;
Subroutine _calc_open_para: called CC=1 SCAR=0.0
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 {
105 121 ▶ my ( $self, $event ) = @_;
Subroutine _handle_open_para: called CC=2 SCAR=7.0
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 {
118 119 ▶ my ( $self, $event ) = @_;
Subroutine _handle_close_para: called CC=1 SCAR=0.0
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 {
133 4 ▶ return [qw(para)];
Subroutine _list_valid_tag_events: called CC=1 SCAR=0.0
134 }
135  
136 before '_handle_close_tag' => sub {
137 202 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
138  
139 202 $self->skip_space();
140 5 };
141  
142 sub _look_ahead_for_tag
143 {
144 940 ▶ my $self = shift;
Subroutine _look_ahead_for_tag: called CC=2 SCAR=6.9
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 {
156 940 ▶ my $self = shift;
Subroutine _main_loop_iter_body_prelude: called CC=1 SCAR=0.0
157  
158 # $self->skip_space();
159  
160 940 return 1;
161 }
162  
163 before '_parse_all' => sub {
164 23 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
165  
166 23 $self->skip_space();
167  
168 23 return;
169 5 };
170  
171  
172 5 1;
173  
174 __END__
175  
176 =pod
177  
178 =encoding UTF-8
179  
180 =head1 NAME
181  
182 XML::Grammar::Fiction::FromProto::Parser::QnD - Quick and Dirty parser
183 for the Fiction-XML proto-text.
184  
185 B<For internal use only>.
186  
187 =head1 VERSION
188  
189 version 0.22.4
190  
191 =head1 METHODS
192  
193 =head2 $self->process_text($string)
194  
195 Processes the text and returns the parse tree.
196  
197 =head2 $self->meta()
198  
199 Leftover from Moo.
200  
201 =for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
202  
203 =head1 SUPPORT
204  
205 =head2 Websites
206  
207 The following websites have more information about this module, and may be of help to you. As always,
208 in addition to those websites please use your favorite search engine to discover more resources.
209  
210 =over 4
211  
212 =item *
213  
214 MetaCPAN
215  
216 A modern, open-source CPAN search engine, useful to view POD in HTML format.
217  
218 L<https://metacpan.org/release/XML-Grammar-Fiction>
219  
220 =item *
221  
222 RT: CPAN's Bug Tracker
223  
224 The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.
225  
226 L<https://rt.cpan.org/Public/Dist/Display.html?Name=XML-Grammar-Fiction>
227  
228 =item *
229  
230 CPANTS
231  
232 The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.
233  
234 L<http://cpants.cpanauthors.org/dist/XML-Grammar-Fiction>
235  
236 =item *
237  
238 CPAN Testers
239  
240 The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions.
241  
242 L<http://www.cpantesters.org/distro/X/XML-Grammar-Fiction>
243  
244 =item *
245  
246 CPAN Testers Matrix
247  
248 The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.
249  
250 L<http://matrix.cpantesters.org/?dist=XML-Grammar-Fiction>
251  
252 =item *
253  
254 CPAN Testers Dependencies
255  
256 The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.
257  
258 L<http://deps.cpantesters.org/?module=XML::Grammar::Fiction>
259  
260 =back
261  
262 =head2 Bugs / Feature Requests
263  
264 Please report any bugs or feature requests by email to C<bug-xml-grammar-fiction at rt.cpan.org>, or through
265 the web interface at L<https://rt.cpan.org/Public/Bug/Report.html?Queue=XML-Grammar-Fiction>. You will be automatically notified of any
266 progress on the request by the system.
267  
268 =head2 Source Code
269  
270 The code is open to the world, and available for you to hack on. Please feel free to browse it and play
271 with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
272 from your repository :)
273  
274 L<https://github.com/shlomif/fiction-xml>
275  
276 git clone git://github.com/shlomif/fiction-xml.git
277  
278 =head1 AUTHOR
279  
280 Shlomi Fish <shlomif@cpan.org>
281  
282 =head1 BUGS
283  
284 Please report any bugs or feature requests on the bugtracker website
285 L<https://github.com/shlomif/fiction-xml/issues>
286  
287 When submitting a bug or request, please include a test-file or a
288 patch to an existing test-file that illustrates the bug or desired
289 feature.
290  
291 =head1 COPYRIGHT AND LICENSE
292  
293 This software is Copyright (c) 2007 by Shlomi Fish.
294  
295 This is free software, licensed under:
296  
297 The MIT (X11) License
298  
299 =cut
« blib/lib/XML/Grammar/Fiction/FromProto.pm ↑ Summary blib/lib/XML/Grammar/Screenplay/FromProto.pm »