Inline/denter.pm

filter: Statementstmt 57.6% 144 / 250 Branchbran 36.1% 47 / 130 Conditioncond 23.9% 11 / 46 MC/DCmcdc 4.0% 1 / 25 Subroutinesub 56.2% 18 / 32 Podpod 0.0% 0 / 18 totaltotal 44.1% 221 / 501 CC 84 SCAR 30.7
CC
84
Cov
47%
indent_data
69.1
_undent_value
31.8
_get_key
30.5
CRAP 21.5
« Inline.pm ↑ Summary Inline/Foo.pm »
1 package Inline::denter;
2  
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 sub new {
7 35 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
8 35 bless {width => 4,
9 comma => " : ",
10 level => 0,
11 tabwidth => 8,
12 }, $class;
13 }
14  
15 # Prevent a taint exception being thrown by AutoLoader.pm.
16 # Serves no other purpose.
17 ▶sub DESTROY {
Subroutine DESTROY: not called CC=1 SCAR=0.0
18 }
19  
20 sub undent {
21 22 ▶ local $/ = "\n";
Subroutine undent: called CC=6 SCAR=18.0
Pod undocumented
22 22 my ($o, $text) = @_;
23 22 my ($comma) = $o->{comma};
24 22 my $package = caller;
25 22 ▶ $package = caller(1) if $package eq 'Inline::denter';
Branch: 1 branch
BranchTrueFalseTotal
if $package eq "Inline::denter" 0 22 22
26 22 %{$o->{xref}} = ();
27 22 @{$o->{objects}} = ();
28 22 @{$o->{context}} = ();
29 22 my $glob = '';
30 22 chomp $text;
31 22 @{$o->{lines}} = split $/, $text;
32 22 $o->{level} = 0;
33 22 ▶ $o->{line} ||= 1;
Condition50%1/2
$o->{"line"} ||= 1
l!l
022
MC/DC0%0/1
$o->{"line"} ||= 1
$o->{"line"}
Truth table50%1/2
A
A= $o->{"line"}
Aresult
11
00
34 22 $o->_setup_line;
35 22 ▶ while (not $o->{done}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($o->{"done"}) 110 22 132
36 110 ▶ if ($o->{level} == 0 and
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{"level"} == 0 and $o->{"content"} =~ /^(\w+)\s*$comma\s*(.*)$/) 110 0 110
Condition33%1/3
$o->{"level"} == 0 and $o->{"content"} =~ /^(\w+)\s*$comma\s*(.*)$/
!ll&&!rl&&r
00110
MC/DC0%0/2
$o->{"level"} == 0 and $o->{"content"} =~ /^(\w+)\s*$comma\s*(.*)$/
$o->{"level"} == 0 $o->{"content"} =~ /^(\w+)\s*$comma\s*(.*)$/
Truth table33%1/3
A and B
A= $o->{"level"} == 0B= $o->{"content"} =~ /^(\w+)\s*$comma\s*(.*)$/
ABresult
0X0
100
111
37 $o->{content} =~ /^(\w+)\s*$comma\s*(.*)$/) {
38 110 $o->{content} = $2;
39 10 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
40 110 push @{$o->{objects}}, "$1";
41 }
42 110 push @{$o->{objects}}, $o->_undent_data;
43 }
44 22 return @{$o->{objects}};
45 }
46  
47 sub _undent_data {
48 220 ▶ my $o = shift;
Subroutine _undent_data: called CC=12 SCAR=33.6
49 220 my ($obj, $class) = ('', '');
50 220 my @refs;
51 my %refs;
52 220 ▶ while ($o->{content} =~ s/^\\(?:\((\w+)\))?((\%|\@|\$|\\).*)/$2/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{"content"} =~ s/^\\(?:\((\w+)\))?((\%|\@|\$|\\).*)/$2/) 0 220 220
53 0 push @refs, $1;
54 0 $refs{$1} = scalar @refs;
55 }
56 220 ▶ if ($o->{content} =~ /^([\%\@\$])
Branch: 2 branches
BranchTrueFalseTotal
if ($o->{'content'} =~ /^([\%\@\$]) (\w(?:\w|::)*)? \s*$/x) { } 88 132 220
elsif ($o->{'content'} =~ /^\?\s*$/) { } 0 132 132
57 (\w(?:\w|::)*)?
58 \s*$/x
59 ) {
60 88 my $foo;
61 88 ▶ $obj = ($1 eq '%') ? {} : ($1 eq '@') ? [] : \$foo;
Branch: 2 branches
BranchTrueFalseTotal
$1 eq '%' ? : 88 0 88
$1 eq '@' ? : 0 0 0
62 88 ▶ $class = $2 || '';
Condition50%1/2
$2 || ''
l!l
088
MC/DC0%0/1
$2 || ''
$2
Truth table50%1/2
A
A= $2
Aresult
11
00
63 88 ▶ if ($1 eq '%') {
Branch: 2 branches
BranchTrueFalseTotal
if ($1 eq '%') { } 88 0 88
elsif ($1 eq '@') { } 0 0 0
64 88 %$obj = $o->_undent_hash;
65 }
66 elsif ($1 eq '@') {
67 0 @$obj = $o->_undent_array;
68 }
69 else {
70 0 $$obj = $o->_undent_scalar;
71 }
72 88 ▶ bless $obj, $class if length $class;
Branch: 1 branch
BranchTrueFalseTotal
if length $class 0 88 88
73 }
74 elsif ($o->{content} =~ /^\?\s*$/) {
75 0 $obj = $o->_undent_undef;
76 }
77 else {
78 132 $obj = $o->_undent_value;
79 }
80 220 ▶ while (@refs) {
Branch: 1 branch
BranchTrueFalseTotal
if (@refs) 0 220 220
81 0 my $ref = pop @refs;
82 0 my $copy = $obj;
83 0 $obj = \ $copy;
84 0 ▶ $o->{xref}{$ref} = $obj if $ref;
Branch: 1 branch
BranchTrueFalseTotal
if $ref 0 0 0
85 }
86 220 return $obj;
87 }
88  
89 sub _undent_value {
90 132 ▶ my $o = shift;
Subroutine _undent_value: called CC=8 SCAR=34.6
91 132 my $value = '';
92 132 ▶ if ($o->{content} =~ /^\<\<(\w+)(\-?)\s*$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($o->{'content'} =~ /^\<\<(\w+)(\-?)\s*$/) { } 0 132 132
elsif ($o->{'content'} =~ /^\"/) { } 0 132 132
93 0 my ($marker, $chomp) = ($1, $2);
94 0 my $line = $o->{line};
95 0 $o->_next_line;
96 0 ▶ while (not $o->{done} and
Branch: 1 branch
BranchTrueFalseTotal
if (not $o->{"done"} and $o->{"lines"}[0] ne $marker) 0 0 0
Condition0%0/3
not $o->{"done"} and $o->{"lines"}[0] ne $marker
!ll&&!rl&&r
000
MC/DC0%0/2
not $o->{"done"} and $o->{"lines"}[0] ne $marker
not $o->{"done"} $o->{"lines"}[0] ne $marker
Truth table0%0/3
not(A) and B
A= not $o->{"done"}B= $o->{"lines"}[0] ne $marker
ABresult
0X0
100
111
97 $o->{lines}[0] ne $marker) {
98 0 $value .= $o->{lines}[0] . "\n";
99 0 $o->_next_line;
100 }
101 0 ▶ croak M03_no_value_end_marker($marker, $line) if $o->{done};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"done"} 0 0 0
102 0 ▶ chomp $value if $chomp;
Branch: 1 branch
BranchTrueFalseTotal
if $chomp 0 0 0
103 }
104 elsif ($o->{content} =~ /^\"/) {
105 0 ▶ croak $o->M04_mismatched_quotes unless $o->{content} =~ /^\".*\"\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $o->{"content"} =~ /^\".*\"\s*$/ 0 0 0
106 0 ($value = $o->{content}) =~ s/^\"|\"\s*$//g;
107 }
108 else {
109 132 $value = $o->{content};
110 }
111 132 $o->_next_line;
112 132 $o->_setup_line;
113 132 return $value;
114 }
115  
116 sub _undent_hash {
117 88 ▶ my @values;
Subroutine _undent_hash: called CC=5 SCAR=16.4
118 88 my $o = shift;
119 88 my $level = $o->{level} + 1;
120 88 $o->_next_line;
121 88 $o->_setup_line;
122 88 ▶ while ($o->{level} == $level) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{"level"} == $level) 110 88 198
123 110 my ($key, $value) = split $o->{comma}, $o->{content};
124 110 ▶ croak $o->M05_invalid_key_value unless (defined $key and defined $value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $key and defined $value 0 110 110
Condition33%1/3
defined $key and defined $value
!ll&&!rl&&r
00110
MC/DC0%0/2
defined $key and defined $value
defined $key defined $value
Truth table33%1/3
A and B
A= defined $keyB= defined $value
ABresult
0X0
100
111
125 110 $o->{content} = $value;
126 110 push @values, $o->_get_key($key), $o->_undent_data;;
127 }
128 88 ▶ croak $o->M06_invalid_indent_level if $o->{level} > $level;
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"level"} > $level 0 88 88
129 88 return @values;
130 }
131  
132 sub _get_key {
133 110 ▶ my ($o, $key) = @_;
Subroutine _get_key: called CC=6 SCAR=34.2
134 110 ▶ return $key unless $key =~ /^\<\<(\w+)(\-?)/;
Branch: 1 branch
BranchTrueFalseTotal
unless $key =~ /^\<\<(\w+)(\-?)/ 110 0 110
135 0 my ($marker, $chomp) = ($1, $2);
136 0 $key = '';
137 0 my $line = $o->{line};
138 0 $o->_next_line;
139 0 ▶ while (not $o->{done} and
Branch: 1 branch
BranchTrueFalseTotal
if (not $o->{"done"} and $o->{"lines"}[0] ne $marker) 0 0 0
Condition0%0/3
not $o->{"done"} and $o->{"lines"}[0] ne $marker
!ll&&!rl&&r
000
MC/DC0%0/2
not $o->{"done"} and $o->{"lines"}[0] ne $marker
not $o->{"done"} $o->{"lines"}[0] ne $marker
Truth table0%0/3
not(A) and B
A= not $o->{"done"}B= $o->{"lines"}[0] ne $marker
ABresult
0X0
100
111
140 $o->{lines}[0] ne $marker) {
141 0 $key .= $o->{lines}[0] . "\n";
142 0 $o->_next_line;
143 }
144 0 ▶ croak M02_no_key_end_marker($marker, $line) if $o->{done};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"done"} 0 0 0
145 0 ▶ chomp $key if $chomp;
Branch: 1 branch
BranchTrueFalseTotal
if $chomp 0 0 0
146 0 $o->_next_line;
147 0 $o->_setup_line;
148 0 return $key;
149 }
150  
151 sub _undent_array {
152 0 ▶ my @values;
Subroutine _undent_array: not called CC=3 SCAR=24.8
153 0 my $o = shift;
154 0 my $level = $o->{level} + 1;
155 0 $o->_next_line;
156 0 $o->_setup_line;
157 0 ▶ while ($o->{level} == $level) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{"level"} == $level) 0 0 0
158 0 push @values, $o->_undent_data;
159 }
160 0 ▶ croak $o->M06_invalid_indent_level if $o->{level} > $level;
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"level"} > $level 0 0 0
161 0 return @values;
162 }
163  
164 sub _undent_scalar {
165 0 ▶ my $values;
Subroutine _undent_scalar: not called CC=4 SCAR=30.0
166 0 my $o = shift;
167 0 my $level = $o->{level} + 1;
168 0 $o->_next_line;
169 0 $o->_setup_line;
170 0 ▶ croak $o->M06_invalid_indent_level if $o->{level} != $level;
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"level"} != $level 0 0 0
171 0 ▶ croak $o->M07_invalid_scalar_value if $o->{content} =~ /^[\%\@\$\\]/;
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"content"} =~ /^[\%\@\$\\]/ 0 0 0
172 0 ▶ return $o->_undent_undef if $o->{content} =~ /^\?/;
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"content"} =~ /^\?/ 0 0 0
173 0 return $o->_undent_value;
174 }
175  
176 sub _undent_undef {
177 0 ▶ my $o = shift;
Subroutine _undent_undef: not called CC=1 SCAR=6.9
178 0 $o->_next_line;
179 0 $o->_setup_line;
180 0 return undef;
181 }
182  
183 sub _next_line {
184 220 ▶ my $o = shift;
Subroutine _next_line: called CC=2 SCAR=7.0
185 220 ▶ $o->{done}++, $o->{level} = -1, return unless @{$o->{lines}};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$o->{"lines"};} 0 220 220
186 220 local $_ = shift @{$o->{lines}};
187 220 $o->{line}++;
188 }
189  
190 sub _setup_line {
191 242 ▶ my $o = shift;
Subroutine _setup_line: called CC=5 SCAR=16.4
192 242 ▶ $o->{done}++, $o->{level} = -1, return unless @{$o->{lines}};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$o->{"lines"};} 22 220 242
193 220 my ($width, $tabwidth) = @{$o}{qw(width tabwidth)};
194 220 while (1) {
195 220 local $_ = $o->{lines}[0];
196 # expand tabs in leading whitespace;
197 220 ▶ $o->next_line, next if /^(\s*$|\#)/; # skip comments and blank lines
Branch: 1 branch
BranchTrueFalseTotal
if /^(\s*$|\#)/ 0 220 220
198 220 ▶ while (s{^( *)(\t+)}
Branch: 1 branch
BranchTrueFalseTotal
if (s/^( *)(\t+)/" " x (length($1) + length($2) * $tabwidth - length($1) % $tabwidth);/e) 0 220 220
199 0 {' ' x (length($1) + length($2) * $tabwidth -
200 length($1) % $tabwidth)}e){}
201 220 ▶ croak $o->M01_invalid_indent_width unless /^(( {$width})*)(\S.*)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless /^(( {$width})*)(\S.*)$/ 0 220 220
202 220 $o->{level} = length($1) / $width;
203 220 $o->{content} = $3;
204 220 last;
205 }
206 }
207  
208 sub indent {
209 13 ▶ my $o = shift;
Subroutine indent: called CC=4 SCAR=14.1
Pod undocumented
210 13 my $package = caller;
211 13 ▶ $package = caller(1) if $package eq 'Inline::denter';
Branch: 1 branch
BranchTrueFalseTotal
if $package eq "Inline::denter" 0 13 13
212 13 my $stream = '';
213 13 $o->{key} = '';
214 13 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 130 13 143
215 130 local $_ = shift;
216 130 ▶ $stream .= $o->indent_name($_, shift), next
Branch: 1 branch
BranchTrueFalseTotal
if /^\*$package\::\w+$/ 130 0 130
217 if (/^\*$package\::\w+$/);
218 0 $stream .= $o->indent_data($_);
219 }
220 13 return $stream;
221 }
222  
223 sub indent_data {
224 286 ▶ my $o = shift;
Subroutine indent_data: called CC=13 SCAR=42.4
Pod undocumented
225 286 local $_ = shift;
226 286 ▶ return $o->indent_undef($_)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 13 273 286
227 if not defined;
228 273 ▶ return $o->indent_value($_)
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_ 247 26 273
229 if (not ref);
230 26 ▶ return $o->indent_hash($_)
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ eq "HASH" and not /=/ or /=HASH/ 26 0 26
Condition33%2/6
ref $_ eq "HASH" and not /=/ or /=HASH/
l!l&&r!l&&!r
2600
ref $_ eq "HASH" and not /=/
!ll&&!rl&&r
0026
MC/DC0%0/3
ref $_ eq "HASH" and not /=/ or /=HASH/
ref $_ eq "HASH" not /=/ /=HASH/
Truth table20%1/5
A and not(B) or C
A= ref $_ eq "HASH"B= not /=/C= /=HASH/
ABCresult
11X1
0X11
1011
0X00
1000
231 if (ref eq 'HASH' and not /=/ or /=HASH/);
232 0 ▶ return $o->indent_array($_)
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ eq "ARRAY" and not /=/ or /=ARRAY/ 0 0 0
Condition0%0/6
ref $_ eq "ARRAY" and not /=/ or /=ARRAY/
l!l&&r!l&&!r
000
ref $_ eq "ARRAY" and not /=/
!ll&&!rl&&r
000
MC/DC0%0/3
ref $_ eq "ARRAY" and not /=/ or /=ARRAY/
ref $_ eq "ARRAY" not /=/ /=ARRAY/
Truth table0%0/5
A and not(B) or C
A= ref $_ eq "ARRAY"B= not /=/C= /=ARRAY/
ABCresult
11X1
0X11
1011
0X00
1000
233 if (ref eq 'ARRAY' and not /=/ or /=ARRAY/);
234 0 ▶ return $o->indent_scalar($_)
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ eq "SCALAR" and not /=/ or /=SCALAR/ 0 0 0
Condition0%0/6
ref $_ eq "SCALAR" and not /=/ or /=SCALAR/
l!l&&r!l&&!r
000
ref $_ eq "SCALAR" and not /=/
!ll&&!rl&&r
000
MC/DC0%0/3
ref $_ eq "SCALAR" and not /=/ or /=SCALAR/
ref $_ eq "SCALAR" not /=/ /=SCALAR/
Truth table0%0/5
A and not(B) or C
A= ref $_ eq "SCALAR"B= not /=/C= /=SCALAR/
ABCresult
11X1
0X11
1011
0X00
1000
235 if (ref eq 'SCALAR' and not /=/ or /=SCALAR/);
236 0 ▶ return $o->indent_ref($_)
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ eq "REF" 0 0 0
237 if (ref eq 'REF');
238 0 return "$_\n";
239 }
240  
241 sub indent_value {
242 247 ▶ my ($o, $data) = @_;
Subroutine indent_value: called CC=11 SCAR=34.0
Pod undocumented
243 247 my $stream;
244 247 ▶ if ($data =~ /\n/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($data =~ /\n/) { } 0 247 247
elsif ($data =~ /^[\s\%\@\$\\?\"]|\s$/ or $data =~ /\Q$o->{'comma'}\E/ or $data =~ /[\x00-\x1f]/ or $data eq '') { } 13 234 247
245 0 my $marker = 'EOV';
246 0 ▶ $marker++ while $data =~ /^$marker$/m;
Branch: 1 branch
BranchTrueFalseTotal
$data =~ /^$marker$/m and do { ++$marker } 0 0 0
247 0 ▶ my $chomp = ($data =~ s/\n\Z//) ? '' : '-';
Branch: 1 branch
BranchTrueFalseTotal
$data =~ s/\n\Z// ? : 0 0 0
248 0 $stream = "<<$marker$chomp\n";
249 0 ▶ $stream .= $o->{key}, $o->{key} = '' if $o->{key};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"key"} 0 0 0
250 0 $stream .= "$data\n$marker\n";
251 }
252 ▶ elsif ($data =~ /^[\s\%\@\$\\?\"]|\s$/ or
Condition44%4/9
$data =~ /^[\s\%\@\$\\?\"]|\s$/ or $data =~ /\Q$o->{"comma"}\E/ or $data =~ /[\x00-\x1f]/ or $data eq ""
l!l&&r!l&&!r
013234
$data =~ /^[\s\%\@\$\\?\"]|\s$/ or $data =~ /\Q$o->{"comma"}\E/ or $data =~ /[\x00-\x1f]/
l!l&&r!l&&!r
00247
$data =~ /^[\s\%\@\$\\?\"]|\s$/ or $data =~ /\Q$o->{"comma"}\E/
l!l&&r!l&&!r
00247
MC/DC25%1/4
$data =~ /^[\s\%\@\$\\?\"]|\s$/ or $data =~ /\Q$o->{"comma"}\E/ or $data =~ /[\x00-\x1f]/ or $data eq ""
$data =~ /^[\s\%\@\$\\?\"]|\s$/ $data =~ /\Q$o->{"comma"}\E/ $data =~ /[\x00-\x1f]/ $data eq ""
Truth table40%2/5
A or B or C or D
A= $data =~ /^[\s\%\@\$\\?\"]|\s$/B= $data =~ /\Q$o->{"comma"}\E/C= $data =~ /[\x00-\x1f]/D= $data eq ""
ABCDresult
1XXX1
01XX1
001X1
00011
00000
253 $data =~ /\Q$o->{comma}\E/ or
254 $data =~ /[\x00-\x1f]/ or
255 $data eq '') {
256 13 $stream = qq{"$data"\n};
257 13 ▶ $stream .= $o->{key}, $o->{key} = '' if $o->{key};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"key"} 0 13 13
258 }
259 else {
260 234 $stream = "$data\n";
261 234 ▶ $stream .= $o->{key}, $o->{key} = '' if $o->{key};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"key"} 0 234 234
262 }
263 247 return $stream;
264 }
265  
266 sub indent_hash {
267 26 ▶ my ($o, $data) = @_;
Subroutine indent_hash: called CC=8 SCAR=27.7
Pod undocumented
268 26 my $stream = $o->_print_ref($data, '%', 'HASH');
269 26 ▶ return $$stream if ref $stream;
Branch: 1 branch
BranchTrueFalseTotal
if ref $stream 0 26 26
270 26 my $indent = ++$o->{level} * $o->{width};
271 26 for my $key (sort keys %$data) {
272 156 my $key_out = $key;
273 156 ▶ if ($key =~ /\n/ or
Branch: 2 branches
BranchTrueFalseTotal
if ($key =~ /\n/ or $key =~ /\Q$o->{'comma'}\E/) { } 0 156 156
elsif ($data =~ /^[\s\%\@\$\\?\"]|\s$/) { } 0 156 156
Condition33%1/3
$key =~ /\n/ or $key =~ /\Q$o->{"comma"}\E/
l!l&&r!l&&!r
00156
MC/DC0%0/2
$key =~ /\n/ or $key =~ /\Q$o->{"comma"}\E/
$key =~ /\n/ $key =~ /\Q$o->{"comma"}\E/
Truth table33%1/3
A or B
A= $key =~ /\n/B= $key =~ /\Q$o->{"comma"}\E/
ABresult
1X1
011
000
274 $key =~ /\Q$o->{comma}\E/) {
275 0 my $marker = 'EOK';
276 0 ▶ $marker++ while $key =~ /^$marker$/m;
Branch: 1 branch
BranchTrueFalseTotal
$key =~ /^$marker$/m and do { ++$marker } 0 0 0
277 0 ▶ my $chomp = (($o->{key} = $key) =~ s/\n\Z//m) ? '' : '-';
Branch: 1 branch
BranchTrueFalseTotal
($o->{'key'} = $key) =~ s/\n\Z//m ? : 0 0 0
278 0 $o->{key} .= "\n$marker\n";
279 0 $key_out = "<<$marker$chomp";
280 }
281 elsif ($data =~ /^[\s\%\@\$\\?\"]|\s$/) {
282 0 $key_out = qq{"$key"};
283 }
284 156 $stream .= ' ' x $indent . $key_out . $o->{comma};
285 156 $stream .= $o->indent_data($data->{$key});
286 }
287 26 $o->{level}--;
288 26 return $stream;
289 }
290  
291 sub indent_array {
292 0 ▶ my ($o, $data) = @_;
Subroutine indent_array: not called CC=3 SCAR=24.8
Pod undocumented
293 0 my $stream = $o->_print_ref($data, '@', 'ARRAY');
294 0 ▶ return $$stream if ref $stream;
Branch: 1 branch
BranchTrueFalseTotal
if ref $stream 0 0 0
295 0 my $indent = ++$o->{level} * $o->{width};
296 0 for my $datum (@$data) {
297 0 $stream .= ' ' x $indent;
298 0 $stream .= $o->indent_data($datum);
299 }
300 0 $o->{level}--;
301 0 return $stream;
302 }
303  
304 sub indent_scalar {
305 0 ▶ my ($o, $data) = @_;
Subroutine indent_scalar: not called CC=2 SCAR=17.9
Pod undocumented
306 0 my $stream = $o->_print_ref($data, q{$}, 'SCALAR');
307 0 ▶ return $$stream if ref $stream;
Branch: 1 branch
BranchTrueFalseTotal
if ref $stream 0 0 0
308 0 my $indent = ($o->{level} + 1) * $o->{width};
309 0 $stream .= ' ' x $indent;
310 0 $stream .= $o->indent_data($$data);
311 0 return $stream;
312 }
313  
314 sub indent_ref {
315 0 ▶ my ($o, $data) = @_;
Subroutine indent_ref: not called CC=2 SCAR=17.9
Pod undocumented
316 0 my $stream = $o->_print_ref($data, '\\', 'SCALAR');
317 0 ▶ return $$stream if ref $stream;
Branch: 1 branch
BranchTrueFalseTotal
if ref $stream 0 0 0
318 0 chomp $stream;
319 0 return $stream . $o->indent_data($$data);
320 }
321  
322 sub indent_undef {
323 13 ▶ my ($o, $data) = @_;
Subroutine indent_undef: called CC=2 SCAR=7.0
Pod undocumented
324 13 my $stream = "?\n";
325 13 ▶ $stream .= $o->{key}, $o->{key} = '' if $o->{key};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"key"} 0 13 13
326 13 return $stream;
327 }
328  
329 sub indent_name {
330 130 ▶ my ($o, $name, $value) = @_;
Subroutine indent_name: called CC=1 SCAR=0.0
Pod undocumented
331 130 $name =~ s/^.*:://;
332 130 my $stream = $name . $o->{comma};
333 130 $stream .= $o->indent_data($value);
334 130 return $stream;
335 }
336  
337 sub _print_ref {
338 26 ▶ my ($o, $data, $symbol, $type) = @_;
Subroutine _print_ref: called CC=5 SCAR=16.7
339 26 ▶ $data =~ /^(([\w:]+)=)?$type\(0x([0-9a-f]+)\)$/
Branch: 1 branch
BranchTrueFalseTotal
$data =~ /^(([\w:]+)=)?$type\(0x([0-9a-f]+)\)$/ or croak("Invalid reference: $data\n") 0 26 26
340 or croak "Invalid reference: $data\n";
341 26 my $stream = $symbol;
342 26 ▶ $stream .= $2 if defined $2;
Branch: 1 branch
BranchTrueFalseTotal
if defined $2 0 26 26
343 26 $o->{xref}{$3}++;
344 croak "Inline::denter does not handle duplicate references"
345 26 ▶ if $o->{xref}{$3} > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"xref"}{$3} > 1 0 26 26
346 26 $stream .= "\n";
347 26 ▶ $stream .= $o->{key}, $o->{key} = '' if $o->{key};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"key"} 0 26 26
348 26 return $stream;
349 }
350  
351 # Undent error messages
352 sub M01_invalid_indent_width {
353 0 ▶ my $o = shift;
Subroutine M01_invalid_indent_width: not called CC=1 SCAR=6.9
Pod undocumented
354 0 "Invalid indent width detected at line $o->{line}\n";
355 }
356  
357 sub M02_no_key_end_marker {
358 0 ▶ my ($marker, $line) = @_;
Subroutine M02_no_key_end_marker: not called CC=1 SCAR=6.9
Pod undocumented
359 0 "No terminating marker '$marker' found for key at line $line\n";
360 }
361  
362 sub M03_no_value_end_marker {
363 0 ▶ my ($marker, $line) = @_;
Subroutine M03_no_value_end_marker: not called CC=1 SCAR=6.9
Pod undocumented
364 0 "No terminating marker '$marker' found for value at line $line\n";
365 }
366  
367 sub M04_mismatched_quotes {
368 0 ▶ my $o = shift;
Subroutine M04_mismatched_quotes: not called CC=1 SCAR=6.9
Pod undocumented
369 0 "Mismatched double quotes for value at line $o->{line}\n";
370 }
371  
372 sub M05_invalid_key_value {
373 0 ▶ my $o = shift;
Subroutine M05_invalid_key_value: not called CC=1 SCAR=6.9
Pod undocumented
374 0 "Missing or invalid hash key/value pair at $o->{line}\n";
375 }
376  
377 sub M06_invalid_indent_level {
378 0 ▶ my $o = shift;
Subroutine M06_invalid_indent_level: not called CC=1 SCAR=6.9
Pod undocumented
379 0 "Invalid indentation level at $o->{line}\n";
380 }
381  
382 sub M07_invalid_scalar_value {
383 0 ▶ my $o = shift;
Subroutine M07_invalid_scalar_value: not called CC=1 SCAR=6.9
Pod undocumented
384 0 "Invalid value for scalar ref context at $o->{line}\n";
385 }
386  
387 10 1;
388 __END__
« Inline.pm ↑ Summary Inline/Foo.pm »