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

filter: Statementstmt 97.2% 70 / 72 Branchbran 80.0% 8 / 10 Conditioncond 77.7% 7 / 9 MC/DCmcdc 66.6% 4 / 6 Subroutinesub 100% 17 / 17 Podpod n/a totaltotal 92.9% 106 / 114 CC 9 SCAR 12.3
CC
9
Cov
93%
_generate_non_tag_text_event
8.3
_look_ahead_for_tag
2.0
BEGIN
1.0
CRAP 3.4
« blib/lib/XML/Grammar/Fiction/FromProto.pm ↑ Summary blib/lib/XML/Grammar/FictionBase/Event.pm »
1 package XML::Grammar::Fiction::FromProto::Parser::QnD;
2 5 $XML::Grammar::Fiction::FromProto::Parser::QnD::VERSION = '0.22.0';
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=1 SCAR=0.0
106  
107 121 $self->_push_tag( $self->_calc_open_para() );
108  
109 121 $self->_in_para(1);
110  
111 121 return;
112 }
113  
114 sub _handle_close_para
115 {
116 119 ▶ my ( $self, $event ) = @_;
Subroutine _handle_close_para: called CC=1 SCAR=0.0
117  
118 119 my $open = $self->_pop_tag;
119  
120 119 my $new_elem = $self->_new_para( $open->detach_children(), );
121  
122 119 $self->_add_to_top_tag($new_elem);
123  
124 119 $self->_in_para(0);
125  
126 119 return;
127 }
128  
129 sub _list_valid_tag_events
130 {
131 4 ▶ return [qw(para)];
Subroutine _list_valid_tag_events: called CC=1 SCAR=0.0
132 }
133  
134 before '_handle_close_tag' => sub {
135 202 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
136  
137 202 $self->skip_space();
138 5 };
139  
140 sub _look_ahead_for_tag
141 {
142 940 ▶ my $self = shift;
Subroutine _look_ahead_for_tag: called CC=2 SCAR=6.9
143  
144 940 my $l = $self->curr_line_copy();
145  
146 940 my $is_tag_cond = ( $$l =~ m{\G<}cg );
147 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
148  
149 940 return ( $is_tag_cond, $is_close );
150 }
151  
152 sub _main_loop_iter_body_prelude
153 {
154 940 ▶ my $self = shift;
Subroutine _main_loop_iter_body_prelude: called CC=1 SCAR=0.0
155  
156 # $self->skip_space();
157  
158 940 return 1;
159 }
160  
161 before '_parse_all' => sub {
162 23 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
163  
164 23 $self->skip_space();
165  
166 23 return;
167 5 };
168  
169  
170 5 1;
171  
172 __END__
173  
174 =pod
175  
176 =encoding UTF-8
177  
178 =head1 NAME
179  
180 XML::Grammar::Fiction::FromProto::Parser::QnD - Quick and Dirty parser
181 for the Fiction-XML proto-text.
182  
183 B<For internal use only>.
184  
185 =head1 VERSION
186  
187 version 0.22.0
188  
189 =head1 METHODS
190  
191 =head2 $self->process_text($string)
192  
193 Processes the text and returns the parse tree.
194  
195 =head2 $self->meta()
196  
197 Leftover from Moo.
198  
199 =for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
200  
201 =head1 SUPPORT
202  
203 =head2 Websites
204  
205 The following websites have more information about this module, and may be of help to you. As always,
206 in addition to those websites please use your favorite search engine to discover more resources.
207  
208 =over 4
209  
210 =item *
211  
212 MetaCPAN
213  
214 A modern, open-source CPAN search engine, useful to view POD in HTML format.
215  
216 L<https://metacpan.org/release/XML-Grammar-Fiction>
217  
218 =item *
219  
220 RT: CPAN's Bug Tracker
221  
222 The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.
223  
224 L<https://rt.cpan.org/Public/Dist/Display.html?Name=XML-Grammar-Fiction>
225  
226 =item *
227  
228 CPANTS
229  
230 The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.
231  
232 L<http://cpants.cpanauthors.org/dist/XML-Grammar-Fiction>
233  
234 =item *
235  
236 CPAN Testers
237  
238 The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions.
239  
240 L<http://www.cpantesters.org/distro/X/XML-Grammar-Fiction>
241  
242 =item *
243  
244 CPAN Testers Matrix
245  
246 The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.
247  
248 L<http://matrix.cpantesters.org/?dist=XML-Grammar-Fiction>
249  
250 =item *
251  
252 CPAN Testers Dependencies
253  
254 The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.
255  
256 L<http://deps.cpantesters.org/?module=XML::Grammar::Fiction>
257  
258 =back
259  
260 =head2 Bugs / Feature Requests
261  
262 Please report any bugs or feature requests by email to C<bug-xml-grammar-fiction at rt.cpan.org>, or through
263 the web interface at L<https://rt.cpan.org/Public/Bug/Report.html?Queue=XML-Grammar-Fiction>. You will be automatically notified of any
264 progress on the request by the system.
265  
266 =head2 Source Code
267  
268 The code is open to the world, and available for you to hack on. Please feel free to browse it and play
269 with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
270 from your repository :)
271  
272 L<https://github.com/shlomif/fiction-xml>
273  
274 git clone git://github.com/shlomif/fiction-xml.git
275  
276 =head1 AUTHOR
277  
278 Shlomi Fish <shlomif@cpan.org>
279  
280 =head1 BUGS
281  
282 Please report any bugs or feature requests on the bugtracker website
283 L<https://github.com/shlomif/fiction-xml/issues>
284  
285 When submitting a bug or request, please include a test-file or a
286 patch to an existing test-file that illustrates the bug or desired
287 feature.
288  
289 =head1 COPYRIGHT AND LICENSE
290  
291 This software is Copyright (c) 2007 by Shlomi Fish.
292  
293 This is free software, licensed under:
294  
295 The MIT (X11) License
296  
297 =cut
« blib/lib/XML/Grammar/Fiction/FromProto.pm ↑ Summary blib/lib/XML/Grammar/FictionBase/Event.pm »