lib/Config/Neat.pm

filter: Statementstmt 95.2% 181 / 190 Branchbran 87.5% 98 / 112 Conditioncond 66.6% 26 / 39 MC/DCmcdc 50.0% 13 / 26 Subroutinesub 100% 12 / 12 Podpod 0.0% 0 / 8 totaltotal 85.2% 330 / 387 CC 70 SCAR 37.0
CC
70
Cov
89%
parse
58.4
append_text
8.0
end_of_param
7.0
CRAP 40.5
« blib/lib/Config/Neat/Inheritable.pm ↑ Summary lib/Config/Neat/Schema.pm »
1 =head1 NAME
2  
3 Config::Neat - Parse/render human-readable configuration files with inheritance and schema validation
4  
5 =head1 SYNOPSIS
6  
7 use Config::Neat;
8  
9 my $cfg = Config::Neat->new();
10 my $data = $cfg->parse_file('server.nconf');
11  
12 =head1 DESCRIPTION
13  
14 This module provides parsing capabilites for the Config::Neat configuration file
15 format (see the example below). This is a highly readable and clean format inspired
16 by [nginx configuration files](http://wiki.nginx.org/FullExample).
17 See L<https://github.com/iafan/Config-Neat/blob/master/sample/readme.nconf>
18 for the detailed file syntax specification.
19  
20 Sample configuration file (let's call it 'server.nconf'):
21  
22 # Server configuration
23  
24 host localhost
25 port 8080
26 use_ssl YES
27 supported_mime_types text/html text/css text/xml text/plain
28 image/gif image/jpeg image/png image/x-icon
29 application/x-javascript
30  
31 handler test1 {
32 url /test1
33 class MyApp::Test
34 }
35  
36 handler test2 {
37 url /test2
38 class MyApp::AnotherTest
39 }
40  
41 Sample usage:
42  
43 use Config::Neat;
44  
45 my $cfg = Config::Neat->new();
46 my $data = $cfg->parse_file('server.nconf');
47  
48 # now $data contains a parsed hash tree which you can examine
49  
50 # consider the sample configuration file above
51  
52 my $list = $data->{'server'}->{'supported_mime_types'};
53 #
54 # $list now is an array reference:
55 # ['text/html', 'text/css', ..., 'application/x-javascript']
56  
57 my $handlers = $data->{'handler'};
58 map {
59 print $_->{url}->as_string, ' maps to ', $_->{class}->as_string
60 } @$handlers;
61  
62 =head1 COPYRIGHT
63  
64 Copyright (C) 2012-2015 Igor Afanasyev <igor.afanasyev@gmail.com>
65  
66 =head1 SEE ALSO
67  
68 L<https://github.com/iafan/Config-Neat>
69  
70 =cut
71  
72 package Config::Neat;
73  
74 4 our $VERSION = '1.4';
75  
76 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
77  
78 4 ▶use Config::Neat::Array;
Subroutine BEGIN: called CC=1 SCAR=0.0
79 4 ▶use Config::Neat::Util qw(is_neat_array new_ixhash get_next_auto_key read_file);
Subroutine BEGIN: called CC=1 SCAR=0.0
80 4 ▶use Tie::IxHash;
Subroutine BEGIN: called CC=1 SCAR=0.0
81  
82 4 my $LINE_START = 0;
83 4 my $KEY = 1;
84 4 my $WHITESPACE = 2;
85 4 my $VALUE = 3;
86 4 my $LINE_COMMENT = 4;
87 4 my $BLOCK_COMMENT = 5;
88  
89 #
90 # Initialize object
91 #
92 sub new {
93 5 ▶ my ($class) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
94  
95 5 my $self = {
96 cfg => {}
97 };
98  
99 5 bless $self, $class;
100 5 return $self;
101 }
102  
103 # Given a string representation of the config, returns a parsed tree
104 sub parse {
105 98 ▶ my ($self, $nconf) = @_;
Subroutine parse: called CC=54 SCAR=40.7
Pod undocumented
106  
107 98 my $o = {
108 context => [new_ixhash],
109 context_data => [{}],
110 c => undef,
111  
112 pos => 0,
113  
114 key => '',
115 values => Config::Neat::Array->new(),
116 value => undef,
117 mode => $LINE_START,
118 previous_mode => $LINE_START,
119 was_backslash => undef,
120 was_slash => undef,
121 was_asterisk => undef,
122 first_value_pos => 0,
123 };
124  
125 98 my $in_raw_mode = undef;
126 98 my $line = 1;
127  
128 sub end_of_param {
129 915 ▶ my ($o, $no_default_param) = @_;
Subroutine end_of_param: called CC=7 SCAR=19.5
Pod undocumented
130  
131 915 ▶ if ($o->{key} ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{"key"} ne "") 463 452 915
132 463 ▶ push @{$o->{values}}, 'YES' if !$no_default_param && scalar(@{$o->{values}}) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if not $no_default_param and scalar @{$o->{"values"};} == 0 11 452 463
Condition100%3/3
not $no_default_param and scalar @{$o->{"values"};} == 0
!ll&&!rl&&r
18526711
MC/DC100%2/2
not $no_default_param and scalar @{$o->{"values"};} == 0
not $no_default_param scalar @{$o->{"values"};} == 0
Truth table100%3/3
not(A) and B
A= not $no_default_paramB= scalar @{$o->{"values"};} == 0
ABresult
0X0
100
111
133 463 my $current_ctx = $o->{context}->[$#{$o->{context}}];
134 463 my $data = $o->{context_data}->[$#{$o->{context_data}}];
135 463 ▶ if (exists $current_ctx->{$o->{key}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$current_ctx{$o->{'key'}}) { } 18 445 463
136 18 ▶ $data->{is_array} = {} unless exists $data->{is_array};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $data->{"is_array"} 13 5 18
137 18 ▶ if (!$data->{is_array}->{$o->{key}}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($data->{"is_array"}{$o->{"key"}}) 13 5 18
138 13 $current_ctx->{$o->{key}} = Config::Neat::Array->new([$current_ctx->{$o->{key}}]);
139 13 $data->{is_array}->{$o->{key}} = 1;
140 }
141 18 $current_ctx->{$o->{key}}->push($o->{values});
142 } else {
143 445 $current_ctx->{$o->{key}} = $o->{values};
144 }
145 463 $o->{values} = Config::Neat::Array->new();
146 463 $o->{key} = '';
147 }
148 }
149  
150 sub append_text {
151 4780 ▶ my ($o, $text) = @_;
Subroutine append_text: called CC=8 SCAR=20.8
Pod undocumented
152  
153 4780 ▶ if ($o->{mode} == $LINE_START) {
Branch: 2 branches
BranchTrueFalseTotal
if ($o->{'mode'} == $LINE_START) { } 454 4326 4780
elsif ($o->{'mode'} == $WHITESPACE) { } 387 3939 4326
154 454 ▶ if (($o->{first_value_pos} > 0) and ($o->{pos} >= $o->{first_value_pos})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{'first_value_pos'} > 0 and $o->{'pos'} >= $o->{'first_value_pos'}) { } 5 449 454
Condition100%3/3
$o->{"first_value_pos"} > 0 and $o->{"pos"} >= $o->{"first_value_pos"}
!ll&&!rl&&r
2831665
MC/DC100%2/2
$o->{"first_value_pos"} > 0 and $o->{"pos"} >= $o->{"first_value_pos"}
$o->{"first_value_pos"} > 0 $o->{"pos"} >= $o->{"first_value_pos"}
Truth table100%3/3
A and B
A= $o->{"first_value_pos"} > 0B= $o->{"pos"} >= $o->{"first_value_pos"}
ABresult
0X0
100
111
155 5 $o->{mode} = $VALUE;
156 } else {
157 449 end_of_param($o);
158 449 $o->{mode} = $KEY;
159 449 $o->{first_value_pos} = 0;
160 }
161 } elsif ($o->{mode} == $WHITESPACE) {
162 387 $o->{mode} = $VALUE;
163 387 ▶ if ($o->{first_value_pos} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{"first_value_pos"} == 0) 285 102 387
164 285 $o->{first_value_pos} = $o->{pos} - 1; # -1 to allow for non-hanging backtick before the first value
165 }
166 }
167  
168 4780 ▶ if ($o->{mode} == $KEY) {
Branch: 2 branches
BranchTrueFalseTotal
if ($o->{'mode'} == $KEY) { } 2555 2225 4780
elsif ($o->{'mode'} == $VALUE) { } 2225 0 2225
169 2555 $o->{key} .= $text;
170 } elsif ($o->{mode} == $VALUE) {
171 2225 $o->{value} .= $text;
172 } else {
173 0 die "Unexpected mode $o->{mode}";
174 }
175 }
176  
177 sub process_pending_chars {
178 6192 ▶ my $o = shift;
Subroutine process_pending_chars: called CC=3 SCAR=11.0
Pod undocumented
179  
180 6192 ▶ if ($o->{was_slash}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{"was_slash"}) 78 6114 6192
181 78 append_text($o, '/');
182 78 $o->{was_slash} = undef;
183 }
184  
185 6192 ▶ if ($o->{was_backslash}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{"was_backslash"}) 14 6178 6192
186 14 append_text($o, '\\');
187 14 $o->{was_backslash} = undef;
188 }
189 }
190  
191 sub process_char {
192 4688 ▶ my $o = shift;
Subroutine process_char: called CC=1 SCAR=0.0
Pod undocumented
193  
194 4688 process_pending_chars($o);
195  
196 4688 append_text($o, $o->{c});
197 4688 $o->{c} = undef;
198 }
199  
200 sub end_of_value {
201 1404 ▶ my $o = shift;
Subroutine end_of_value: called CC=2 SCAR=6.9
Pod undocumented
202  
203 1404 process_pending_chars($o);
204  
205 1404 ▶ if (defined $o->{value}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $o->{"value"}) 392 1012 1404
206 392 push @{$o->{values}}, $o->{value};
207 392 $o->{value} = undef;
208 }
209 }
210  
211 98 ▶ for (my $i = 0, my $l = length($nconf); $i < $l; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $l) 10713 97 10810
212 10713 my $c = $o->{c} = substr($nconf, $i, 1);
213 10713 $o->{pos}++;
214  
215 10713 ▶ if ($c ne '/') {
Branch: 1 branch
BranchTrueFalseTotal
if ($c ne "/") 10615 98 10713
216 10615 $o->{was_asterisk} = undef;
217 }
218  
219 10713 ▶ if ($c eq '{') {
Branch: 10 branches
BranchTrueFalseTotal
if ($c eq '{') { } 185 10528 10713
elsif ($c eq '}') { } 185 10343 10528
elsif ($c eq '\\') { } 19 10324 10343
elsif ($c eq '/') { } 98 10226 10324
elsif ($c eq '*') { } 28 10198 10226
elsif ($c eq '`') { } 51 10147 10198
elsif ($c eq ' ' or $c eq "\t") { } 4494 5653 10147
elsif ($c eq "\r") { } 0 5653 5653
elsif ($c eq "\n") { } 838 4815 5653
elsif ($c eq '#') { } 57 4758 4815
220 185 ▶ next if ($o->{mode} == $LINE_COMMENT) or ($o->{mode} == $BLOCK_COMMENT);
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT 0 185 185
Condition33%1/3
$o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT
l!l&&r!l&&!r
00185
MC/DC0%0/2
$o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT
$o->{"mode"} == $LINE_COMMENT $o->{"mode"} == $BLOCK_COMMENT
Truth table33%1/3
A or B
A= $o->{"mode"} == $LINE_COMMENTB= $o->{"mode"} == $BLOCK_COMMENT
ABresult
1X1
011
000
221  
222 185 ▶ if ($in_raw_mode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_raw_mode) 0 185 185
223 0 process_char($o);
224 0 next;
225 }
226  
227 185 end_of_value($o);
228  
229 185 ▶ if (!$o->{key}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($o->{"key"}) 16 169 185
230 16 $o->{key} = get_next_auto_key($o->{context}->[$#{$o->{context}}]);
231 }
232  
233 185 my $old_values = $o->{values};
234 185 my $new_context = $o->{values} = new_ixhash;
235  
236 185 end_of_param($o, 1); # do not push a default parameter
237  
238 185 $o->{value} = undef;
239 185 $o->{mode} = $LINE_START;
240 185 $o->{first_value_pos} = 0;
241  
242 185 push @{$o->{context}}, $new_context;
243 185 push @{$o->{context_data}}, {};
244  
245 # any values preceding the block will be added into it with an empty key value
246 185 ▶ if (scalar(@{$old_values}) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$old_values;} > 0) 18 167 185
247 18 $new_context->{''} = $old_values;
248 }
249  
250 } elsif ($c eq '}') {
251 185 ▶ next if ($o->{mode} == $LINE_COMMENT) or ($o->{mode} == $BLOCK_COMMENT);
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT 0 185 185
Condition33%1/3
$o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT
l!l&&r!l&&!r
00185
MC/DC0%0/2
$o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT
$o->{"mode"} == $LINE_COMMENT $o->{"mode"} == $BLOCK_COMMENT
Truth table33%1/3
A or B
A= $o->{"mode"} == $LINE_COMMENTB= $o->{"mode"} == $BLOCK_COMMENT
ABresult
1X1
011
000
252  
253 185 ▶ if ($in_raw_mode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_raw_mode) 0 185 185
254 0 process_char($o);
255 0 next;
256 }
257  
258 185 end_of_value($o);
259 185 end_of_param($o);
260  
261 185 ▶ if (scalar(@{$o->{context}}) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$o->{"context"};} == 1) 1 184 185
262 1 die "Unmatched closing bracket at config line $line position $o->{pos}";
263 }
264 184 pop @{$o->{context}};
265 184 pop @{$o->{context_data}};
266 184 $o->{mode} = $WHITESPACE;
267 184 $o->{key} = '';
268 184 $o->{values} = Config::Neat::Array->new();
269  
270 } elsif ($c eq '\\') {
271 19 ▶ next if ($o->{mode} == $LINE_COMMENT) or ($o->{mode} == $BLOCK_COMMENT);
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT 0 19 19
Condition33%1/3
$o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT
l!l&&r!l&&!r
0019
MC/DC0%0/2
$o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT
$o->{"mode"} == $LINE_COMMENT $o->{"mode"} == $BLOCK_COMMENT
Truth table33%1/3
A or B
A= $o->{"mode"} == $LINE_COMMENTB= $o->{"mode"} == $BLOCK_COMMENT
ABresult
1X1
011
000
272  
273 19 process_pending_chars($o);
274  
275 19 $o->{was_backslash} = 1; # do not print current slash, but wait for the next char
276 19 next;
277  
278 } elsif ($c eq '/') {
279 98 ▶ next if ($o->{mode} == $LINE_COMMENT);
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"mode"} == $LINE_COMMENT 0 98 98
280 98 ▶ next if (!$o->{was_asterisk} and $o->{mode} == $BLOCK_COMMENT);
Branch: 1 branch
BranchTrueFalseTotal
if not $o->{"was_asterisk"} and $o->{"mode"} == $BLOCK_COMMENT 2 96 98
Condition100%3/3
not $o->{"was_asterisk"} and $o->{"mode"} == $BLOCK_COMMENT
!ll&&!rl&&r
3932
MC/DC100%2/2
not $o->{"was_asterisk"} and $o->{"mode"} == $BLOCK_COMMENT
not $o->{"was_asterisk"} $o->{"mode"} == $BLOCK_COMMENT
Truth table100%3/3
not(A) and B
A= not $o->{"was_asterisk"}B= $o->{"mode"} == $BLOCK_COMMENT
ABresult
0X0
100
111
281  
282 96 ▶ if ($in_raw_mode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_raw_mode) 12 84 96
283 12 process_char($o);
284 12 next;
285 }
286  
287 84 ▶ if ($o->{was_asterisk} and ($o->{mode} == $BLOCK_COMMENT)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{"was_asterisk"} and $o->{"mode"} == $BLOCK_COMMENT) 3 81 84
Condition66%2/3
$o->{"was_asterisk"} and $o->{"mode"} == $BLOCK_COMMENT
!ll&&!rl&&r
8103
MC/DC50%1/2
$o->{"was_asterisk"} and $o->{"mode"} == $BLOCK_COMMENT
$o->{"was_asterisk"} $o->{"mode"} == $BLOCK_COMMENT
Truth table66%2/3
A and B
A= $o->{"was_asterisk"}B= $o->{"mode"} == $BLOCK_COMMENT
ABresult
0X0
100
111
288 3 $o->{mode} = $o->{previous_mode};
289 3 next;
290 }
291  
292 81 process_pending_chars($o);
293  
294 81 $o->{was_slash} = 1; # do not print current slash, but wait for the next char
295 81 next;
296  
297 } elsif ($c eq '*') {
298 28 ▶ next if ($o->{mode} == $LINE_COMMENT);
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"mode"} == $LINE_COMMENT 0 28 28
299  
300 28 ▶ if ($o->{mode} == $BLOCK_COMMENT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{'mode'} == $BLOCK_COMMENT) { } 5 23 28
301 5 $o->{was_asterisk} = 1;
302 5 next;
303 } else {
304 23 ▶ if ($o->{was_slash}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{"was_slash"}) 3 20 23
305 3 $o->{was_slash} = undef;
306 3 $o->{previous_mode} = $o->{mode};
307 3 $o->{mode} = $BLOCK_COMMENT;
308 3 next;
309 }
310  
311 20 process_char($o);
312 }
313  
314 } elsif ($c eq '`') {
315 51 ▶ next if ($o->{mode} == $LINE_COMMENT) or ($o->{mode} == $BLOCK_COMMENT);
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT 0 51 51
Condition33%1/3
$o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT
l!l&&r!l&&!r
0051
MC/DC0%0/2
$o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT
$o->{"mode"} == $LINE_COMMENT $o->{"mode"} == $BLOCK_COMMENT
Truth table33%1/3
A or B
A= $o->{"mode"} == $LINE_COMMENTB= $o->{"mode"} == $BLOCK_COMMENT
ABresult
1X1
011
000
316  
317 51 ▶ if ($o->{was_backslash}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{"was_backslash"}) 5 46 51
318 5 $o->{was_backslash} = undef;
319 5 process_char($o);
320 5 next;
321 }
322  
323 46 $o->{c} = '';
324 46 process_char($o);
325  
326 46 $in_raw_mode = !$in_raw_mode;
327  
328 ▶ } elsif (($c eq ' ') or ($c eq "\t")) {
Condition66%2/3
$c eq " " or $c eq "\t"
l!l&&r!l&&!r
449405653
MC/DC50%1/2
$c eq " " or $c eq "\t"
$c eq " " $c eq "\t"
Truth table66%2/3
A or B
A= $c eq " "B= $c eq "\t"
ABresult
1X1
011
000
329 4494 ▶ if ($c eq "\t") {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "\t") 0 4494 4494
330 0 warn "Tab symbol at config line $line position $o->{pos} (replace tabs with spaces to ensure proper parsing of multiline parameters)";
331 }
332  
333 4494 ▶ next if ($o->{mode} == $LINE_COMMENT) or ($o->{mode} == $BLOCK_COMMENT);
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT 50 4444 4494
Condition100%3/3
$o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT
l!l&&r!l&&!r
4194444
MC/DC100%2/2
$o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT
$o->{"mode"} == $LINE_COMMENT $o->{"mode"} == $BLOCK_COMMENT
Truth table100%3/3
A or B
A= $o->{"mode"} == $LINE_COMMENTB= $o->{"mode"} == $BLOCK_COMMENT
ABresult
1X1
011
000
334  
335 4444 ▶ if ($in_raw_mode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_raw_mode) 35 4409 4444
336 35 process_char($o);
337 35 next;
338 }
339  
340 4409 ▶ if ($o->{mode} == $KEY) {
Branch: 2 branches
BranchTrueFalseTotal
if ($o->{'mode'} == $KEY) { } 344 4065 4409
elsif ($o->{'mode'} == $VALUE) { } 102 3963 4065
341 344 $o->{mode} = $WHITESPACE;
342 } elsif ($o->{mode} == $VALUE) {
343 102 end_of_value($o);
344 102 $o->{mode} = $WHITESPACE;
345 }
346  
347 } elsif ($c eq "\r") {
348 0 next;
349  
350 } elsif ($c eq "\n") {
351 838 $line++;
352 838 $o->{pos} = 0;
353  
354 838 ▶ next if ($o->{mode} == $BLOCK_COMMENT);
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"mode"} == $BLOCK_COMMENT 2 836 838
355  
356 836 ▶ if ($in_raw_mode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_raw_mode) 0 836 836
357 0 process_char($o);
358 0 next;
359 }
360  
361 836 end_of_value($o);
362 836 $o->{mode} = $LINE_START;
363  
364 } elsif ($c eq "#") {
365 57 ▶ next if ($o->{mode} == $LINE_COMMENT) or ($o->{mode} == $BLOCK_COMMENT);
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT 0 57 57
Condition33%1/3
$o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT
l!l&&r!l&&!r
0057
MC/DC0%0/2
$o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT
$o->{"mode"} == $LINE_COMMENT $o->{"mode"} == $BLOCK_COMMENT
Truth table33%1/3
A or B
A= $o->{"mode"} == $LINE_COMMENTB= $o->{"mode"} == $BLOCK_COMMENT
ABresult
1X1
011
000
366  
367 57 ▶ if ($in_raw_mode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_raw_mode) 6 51 57
368 6 process_char($o);
369 6 next;
370 }
371  
372 51 ▶ if (($o->{mode} == $LINE_START) or ($o->{mode} == $WHITESPACE)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{'mode'} == $LINE_START or $o->{'mode'} == $WHITESPACE) { } 11 40 51
Condition66%2/3
$o->{"mode"} == $LINE_START or $o->{"mode"} == $WHITESPACE
l!l&&r!l&&!r
11040
MC/DC50%1/2
$o->{"mode"} == $LINE_START or $o->{"mode"} == $WHITESPACE
$o->{"mode"} == $LINE_START $o->{"mode"} == $WHITESPACE
Truth table66%2/3
A or B
A= $o->{"mode"} == $LINE_STARTB= $o->{"mode"} == $WHITESPACE
ABresult
1X1
011
000
373 11 $o->{mode} = $LINE_COMMENT;
374 } else {
375 40 process_char($o);
376 }
377  
378 } else {
379 4758 ▶ next if ($o->{mode} == $LINE_COMMENT) or ($o->{mode} == $BLOCK_COMMENT);
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT 234 4524 4758
Condition100%3/3
$o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT
l!l&&r!l&&!r
217174524
MC/DC100%2/2
$o->{"mode"} == $LINE_COMMENT or $o->{"mode"} == $BLOCK_COMMENT
$o->{"mode"} == $LINE_COMMENT $o->{"mode"} == $BLOCK_COMMENT
Truth table100%3/3
A or B
A= $o->{"mode"} == $LINE_COMMENTB= $o->{"mode"} == $BLOCK_COMMENT
ABresult
1X1
011
000
380  
381 4524 process_char($o);
382 }
383  
384 10255 $o->{was_asterisk} = undef;
385 }
386  
387 97 ▶ die "Unmatched backtick at config line $line position $o->{pos}" if $in_raw_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $in_raw_mode 0 97 97
388  
389 97 ▶ die "Missing closing bracket at config line $line position $o->{pos}" if @{$o->{context}} > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @{$o->{"context"};} > 1 1 96 97
390  
391 96 end_of_value($o);
392 96 end_of_param($o);
393  
394 96 return $self->{cfg} = $o->{context}->[0];
395 } # end sub
396  
397 # Given file name, will read this file in the specified mode (defaults to UTF-8) and parse it
398 sub parse_file {
399 5 ▶ my ($self, $filename, $binmode) = @_;
Subroutine parse_file: called CC=1 SCAR=0.0
Pod undocumented
400 5 return $self->parse(read_file($filename, $binmode));
401 } # end sub
402  
403 4 1; # return true
« blib/lib/Config/Neat/Inheritable.pm ↑ Summary lib/Config/Neat/Schema.pm »