lib/Text/AsciidocDown/Include.pm

filter: Statementstmt 92.8% 181 / 195 Branchbran 77.3% 82 / 106 Conditioncond 53.0% 26 / 49 MC/DCmcdc 30.0% 9 / 30 Subroutinesub 94.1% 16 / 17 Podpod 100% 1 / 1 totaltotal 79.1% 315 / 398 CC 80 SCAR 25.0
CC
80
Cov
83%
_expand_text
22.4
expand_includes
15.4
_is_under_base
12.0
CRAP 12.2
« lib/Text/AsciidocDown/Parser.pm ↑ Summary lib/Text/AsciidocDown/Refs.pm »
1 package Text::AsciidocDown::Include;
2  
3 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 18 our $VERSION = '0.1.3';
7  
8 18 ▶use Cwd qw(abs_path getcwd);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 18 ▶use File::Basename qw(dirname);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 18 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 18 ▶use Text::AsciidocDown::Subs ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub expand_includes
15 109 ▶{
Subroutine expand_includes: called CC=14 SCAR=27.4
Pod documented
16 109 my ($text, $opts) = @_;
17 109 ▶ $text = '' unless defined $text;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $text 0 109 109
18 109 ▶ $opts ||= {};
Condition50%1/2
$opts ||= {}
l!l
1090
MC/DC0%0/1
$opts ||= {}
$opts
Truth table50%1/2
A
A= $opts
Aresult
11
00
19  
20 109 ▶ my $include = ref($opts->{include}) eq 'HASH' ? $opts->{include} : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $opts->{'include'} eq 'HASH' ? : 21 88 109
21 109 ▶ return $text unless $include->{enabled};
Branch: 1 branch
BranchTrueFalseTotal
unless $include->{"enabled"} 88 21 109
22  
23 21 ▶ my $base_dir = defined($include->{base_dir}) ? $include->{base_dir} : getcwd();
Branch: 1 branch
BranchTrueFalseTotal
defined $include->{'base_dir'} ? : 0 21 21
24 21 ▶ $base_dir = abs_path($base_dir) || $base_dir;
Condition33%1/3
abs_path($base_dir) || $base_dir
l!l&&r!l&&!r
2100
MC/DC0%0/2
abs_path($base_dir) || $base_dir
abs_path($base_dir) $base_dir
Truth table33%1/3
A || B
A= abs_path($base_dir)B= $base_dir
ABresult
1X1
011
000
25  
26 my $ctx = {
27 include => {
28 max_depth => defined($include->{max_depth}) ? int($include->{max_depth}) : 64,
29 on_missing => $include->{on_missing} || 'error',
30 on_cycle => $include->{on_cycle} || 'error',
31 on_missing_tag => $include->{on_missing_tag} || 'error',
32 on_bad_selector => $include->{on_bad_selector} || 'error',
33 restrict_to_base_dir => $include->{restrict_to_base_dir} ? 1 : 0,
34 base_dir => $base_dir,
35 },
36 attributes => ref($opts->{attributes}) eq 'HASH' ? $opts->{attributes} : {},
37 21 ▶ };
Branch: 3 branches
BranchTrueFalseTotal
defined $include->{'max_depth'} ? : 1 20 21
$include->{'restrict_to_base_dir'} ? : 0 21 21
ref $opts->{'attributes'} eq 'HASH' ? : 0 21 21
Condition100%8/8
$include->{'on_missing'} || 'error'
l!l
318
$include->{'on_cycle'} || 'error'
l!l
120
$include->{'on_missing_tag'} || 'error'
l!l
417
$include->{'on_bad_selector'} || 'error'
l!l
219
MC/DC100%1/1
$include->{'on_missing'} || 'error'
$include->{'on_missing'}
MC/DC100%1/1
$include->{'on_cycle'} || 'error'
$include->{'on_cycle'}
MC/DC100%1/1
$include->{'on_missing_tag'} || 'error'
$include->{'on_missing_tag'}
MC/DC100%1/1
$include->{'on_bad_selector'} || 'error'
$include->{'on_bad_selector'}
Truth table100%2/2
A
A= $include->{'on_missing'}
Aresult
11
00
Truth table100%2/2
A
A= $include->{'on_cycle'}
Aresult
11
00
Truth table100%2/2
A
A= $include->{'on_missing_tag'}
Aresult
11
00
Truth table100%2/2
A
A= $include->{'on_bad_selector'}
Aresult
11
00
38  
39 return
40 _expand_text(
41 $text, $ctx,
42 {
43 source_path => $opts->{source_path},
44 21 depth => 0,
45 stack => [],
46 }
47 );
48 }
49  
50 sub _expand_text
51 40 ▶{
Subroutine _expand_text: called CC=21 SCAR=31.1
52 40 my ($text, $ctx, $state) = @_;
53  
54 40 ▶ if ($state->{depth} > $ctx->{include}{max_depth})
Branch: 1 branch
BranchTrueFalseTotal
if ($state->{"depth"} > $ctx->{"include"}{"max_depth"}) 1 39 40
55 {
56 1 die "include recursion depth exceeded at " . _where($state->{source_path}, 0) . "\n";
57 }
58  
59 39 my @lines = split /\n/, $text, -1;
60 39 my @out;
61 39 ▶ my %attrs = %{$ctx->{attributes} || {}};
Condition50%1/2
$ctx->{'attributes'} || {}
l!l
390
MC/DC0%0/1
$ctx->{'attributes'} || {}
$ctx->{'attributes'}
Truth table50%1/2
A
A= $ctx->{'attributes'}
Aresult
11
00
62  
63 39 for my $idx (0 .. $#lines)
64 {
65 212 my $line = $lines[$idx];
66  
67 212 ▶ if ($line =~ /^:([^:-][^:]*):(?:\s(.*))?$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^:([^:-][^:]*):(?:\s(.*))?$/) 1 211 212
68 {
69 1 ▶ my ($name, $value) = ($1, defined($2) ? $2 : '');
Branch: 1 branch
BranchTrueFalseTotal
defined $2 ? : 1 0 1
70 1 $attrs{$name} = Text::AsciidocDown::Subs::substitute_attributes($value, \%attrs);
71 1 push @out, $line;
72 1 next;
73 }
74  
75 211 ▶ if ($line =~ /^\\include::([^[]+)\[(.*)\]$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\\include::([^[]+)\[(.*)\]$/) 1 210 211
76 {
77 1 push @out, $line;
78 1 next;
79 }
80  
81 210 ▶ unless ($line =~ /^include::([^[]+)\[(.*)\]$/)
Branch: 1 branch
BranchTrueFalseTotal
unless ($line =~ /^include::([^[]+)\[(.*)\]$/) 187 23 210
82 {
83 187 push @out, $line;
84 187 next;
85 }
86  
87 23 my ($target_raw, $attrlist) = ($1, $2);
88 23 my $target = Text::AsciidocDown::Subs::substitute_attributes($target_raw, \%attrs);
89 23 my $selectors = _parse_selector_attrlist($attrlist, \%attrs);
90  
91 23 ▶ if ($target =~ m{^[a-z]+://}i)
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ m[^[a-z]+://]i) 0 23 23
92 {
93 0 push @out, $line;
94 0 next;
95 }
96  
97 23 my $resolved = _resolve_target($target, $state->{source_path}, $ctx->{include}{base_dir});
98 23 ▶ unless (defined $resolved && -f $resolved)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $resolved and -f $resolved) 3 20 23
Condition66%2/3
defined $resolved and -f $resolved
!ll&&!rl&&r
0320
MC/DC50%1/2
defined $resolved and -f $resolved
defined $resolved -f $resolved
Truth table66%2/3
A and B
A= defined $resolvedB= -f $resolved
ABresult
0X0
100
111
99 {
100 3 my $mode = $ctx->{include}{on_missing};
101 3 ▶ if ($mode eq 'keep')
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "keep") 1 2 3
102 {
103 1 push @out, $line;
104 1 next;
105 }
106 2 ▶ if ($mode eq 'drop')
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "drop") 1 1 2
107 {
108 1 next;
109 }
110 1 die "missing include target '$target' resolved to '$resolved' at " . _where($state->{source_path}, $idx + 1) . "\n";
111 }
112  
113 20 ▶ if ($ctx->{include}{restrict_to_base_dir} && !_is_under_base($resolved, $ctx->{include}{base_dir}))
Branch: 1 branch
BranchTrueFalseTotal
if ($ctx->{"include"}{"restrict_to_base_dir"} and not _is_under_base($resolved, $ctx->{"include"}{"base_dir"})) 0 20 20
Condition33%1/3
$ctx->{"include"}{"restrict_to_base_dir"} and not _is_under_base($resolved, $ctx->{"include"}{"base_dir"})
!ll&&!rl&&r
2000
MC/DC0%0/2
$ctx->{"include"}{"restrict_to_base_dir"} and not _is_under_base($resolved, $ctx->{"include"}{"base_dir"})
$ctx->{"include"}{"restrict_to_base_dir"} not _is_under_base($resolved, $ctx->{"include"}{"base_dir"})
Truth table33%1/3
A and not(B)
A= $ctx->{"include"}{"restrict_to_base_dir"}B= not _is_under_base($resolved, $ctx->{"include"}{"base_dir"})
ABresult
0X0
100
111
114 {
115 die "include target '$resolved' is outside base dir '$ctx->{include}{base_dir}' at " .
116 0 _where($state->{source_path}, $idx + 1) . "\n";
117 }
118  
119 20 ▶ if (grep { $_ eq $resolved } @{$state->{stack}})
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq $resolved;} @{$$state{"stack"};}) 1 19 20
120 {
121 1 my $mode = $ctx->{include}{on_cycle};
122 1 ▶ if ($mode eq 'keep')
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "keep") 0 1 1
123 {
124 0 push @out, $line;
125 0 next;
126 }
127 1 ▶ if ($mode eq 'drop')
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "drop") 0 1 1
128 {
129 0 next;
130 }
131 1 my $chain = join(' -> ', @{$state->{stack}}, $resolved);
132 1 die "include cycle detected: $chain at " . _where($state->{source_path}, $idx + 1) . "\n";
133 }
134  
135 19 my $content = _read_file($resolved);
136 my $expanded = _expand_text(
137 $content, $ctx,
138 {
139 source_path => $resolved,
140 depth => $state->{depth} + 1,
141 19 stack => [@{$state->{stack}}, $resolved],
142 }
143 );
144  
145 16 my ($ok, $selected, $action) = _apply_selectors($expanded, $selectors, $ctx, $line, $state, $idx + 1);
146 16 ▶ if (!$ok)
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 6 10 16
147 {
148 6 ▶ if ($action eq 'keep')
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "keep") 3 3 6
149 {
150 3 push @out, $line;
151 3 next;
152 }
153 3 ▶ if ($action eq 'drop')
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "drop") 1 2 3
154 {
155 1 next;
156 }
157 2 die $selected;
158 }
159  
160 10 push @out, split /\n/, $selected, -1;
161 }
162  
163 32 return join("\n", @out);
164 }
165  
166 sub _parse_selector_attrlist
167 23 ▶{
Subroutine _parse_selector_attrlist: called CC=7 SCAR=20.2
168 23 my ($attrlist, $attrs) = @_;
169 23 my %s;
170 23 ▶ return \%s unless defined $attrlist && $attrlist ne '';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $attrlist and $attrlist ne "" 11 12 23
Condition66%2/3
defined $attrlist and $attrlist ne ""
!ll&&!rl&&r
01112
MC/DC50%1/2
defined $attrlist and $attrlist ne ""
defined $attrlist $attrlist ne ""
Truth table66%2/3
A and B
A= defined $attrlistB= $attrlist ne ""
ABresult
0X0
100
111
171  
172 12 for my $tok (split /,/, $attrlist)
173 {
174 13 $tok =~ s/^\s+|\s+$//g;
175 13 ▶ next if $tok eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $tok eq "" 0 13 13
176 13 my ($k, $v) = split /=/, $tok, 2;
177 13 ▶ next unless defined $k && defined $v;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $k and defined $v 0 13 13
Condition33%1/3
defined $k and defined $v
!ll&&!rl&&r
0013
MC/DC0%0/2
defined $k and defined $v
defined $k defined $v
Truth table33%1/3
A and B
A= defined $kB= defined $v
ABresult
0X0
100
111
178 13 $v = Text::AsciidocDown::Subs::substitute_attributes($v, $attrs);
179 13 $s{$k} = $v;
180 }
181 12 return \%s;
182 }
183  
184 sub _apply_selectors
185 16 ▶{
Subroutine _apply_selectors: called CC=9 SCAR=22.0
186 16 my ($text, $selectors, $ctx, $line, $state, $line_no) = @_;
187 16 ▶ $selectors ||= {};
Condition50%1/2
$selectors ||= {}
l!l
160
MC/DC0%0/1
$selectors ||= {}
$selectors
Truth table50%1/2
A
A= $selectors
Aresult
11
00
188  
189 16 my $work = $text;
190  
191 16 ▶ if (exists $selectors->{tags} || exists $selectors->{tag})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $selectors->{"tags"} or exists $selectors->{"tag"}) 7 9 16
Condition100%3/3
exists $selectors->{"tags"} or exists $selectors->{"tag"}
l!l&&r!l&&!r
169
MC/DC100%2/2
exists $selectors->{"tags"} or exists $selectors->{"tag"}
exists $selectors->{"tags"} exists $selectors->{"tag"}
Truth table100%3/3
A or B
A= exists $selectors->{"tags"}B= exists $selectors->{"tag"}
ABresult
1X1
011
000
192 {
193 7 ▶ my @tags = exists($selectors->{tags}) ? split(/;/, $selectors->{tags}) : ($selectors->{tag});
Branch: 1 branch
BranchTrueFalseTotal
exists $selectors->{'tags'} ? : 1 6 7
194 7 ▶ @tags = map { my $x = $_; $x =~ s/^\s+|\s+$//g; $x } grep { defined && $_ ne '' } @tags;
Condition33%1/3
defined $_ && $_ ne ''
!ll&&!rl&&r
008
MC/DC0%0/2
defined $_ && $_ ne ''
defined $_ $_ ne ''
Truth table33%1/3
A && B
A= defined $_B= $_ ne ''
ABresult
0X0
100
111
195 7 my ($ok, $res, $action) = _filter_by_tags($work, \@tags, $ctx, $state, $line_no);
196 7 ▶ return ($ok, $res, $action) unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 4 3 7
197 3 $work = $res;
198 }
199  
200 12 ▶ if (exists $selectors->{lines})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $selectors->{"lines"}) 6 6 12
201 {
202 6 my ($ok, $res, $action) = _filter_by_lines($work, $selectors->{lines}, $ctx, $state, $line_no);
203 6 ▶ return ($ok, $res, $action) unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 2 4 6
204 4 $work = $res;
205 }
206  
207 10 return (1, $work, '');
208 }
209  
210 sub _filter_by_tags
211 7 ▶{
Subroutine _filter_by_tags: called CC=11 SCAR=24.7
212 7 my ($text, $tags, $ctx, $state, $line_no) = @_;
213 7 my %wanted = map { $_ => 1 } @{$tags};
214 7 my %regions;
215 my @stack;
216  
217 7 my @lines = split /\n/, $text, -1;
218 7 for my $line (@lines)
219 {
220 70 ▶ if ($line =~ /^tag::([A-Za-z0-9_.:-]+)\[\]$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^tag::([A-Za-z0-9_.:-]+)\[\]$/) 14 56 70
221 {
222 14 my $name = $1;
223 0 ▶ if (grep { $_ eq $name } @stack)
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq $name;} @stack) 0 14 14
224 {
225 0 return _selector_error('nested same-name tag not supported', $ctx->{include}{on_bad_selector}, $state, $line_no);
226 }
227 14 push @stack, $name;
228 14 next;
229 }
230 56 ▶ if ($line =~ /^end::([A-Za-z0-9_.:-]+)\[\]$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^end::([A-Za-z0-9_.:-]+)\[\]$/) 14 42 56
231 {
232 14 my $name = $1;
233 14 ▶ if (!@stack || $stack[-1] ne $name)
Branch: 1 branch
BranchTrueFalseTotal
if (not @stack or $stack[-1] ne $name) 0 14 14
Condition33%1/3
not @stack or $stack[-1] ne $name
l!l&&r!l&&!r
0014
MC/DC0%0/2
not @stack or $stack[-1] ne $name
not @stack $stack[-1] ne $name
Truth table33%1/3
not(A) or B
A= not @stackB= $stack[-1] ne $name
ABresult
1X1
011
000
234 {
235 0 return _selector_error("mismatched tag terminator '$name'", $ctx->{include}{on_bad_selector}, $state, $line_no);
236 }
237 14 pop @stack;
238 14 next;
239 }
240 42 for my $name (@stack)
241 {
242 28 push @{$regions{$name}}, $line;
243 }
244 }
245  
246 7 ▶ if (@stack)
Branch: 1 branch
BranchTrueFalseTotal
if (@stack) 0 7 7
247 {
248 0 return _selector_error('unclosed tag region', $ctx->{include}{on_bad_selector}, $state, $line_no);
249 }
250  
251 7 my @out;
252 7 for my $name (@{$tags})
253 {
254 8 ▶ if (!exists $regions{$name})
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $regions{$name}) 4 4 8
255 {
256 4 return _selector_error("missing tag '$name'", $ctx->{include}{on_missing_tag}, $state, $line_no);
257 }
258 4 push @out, @{$regions{$name}};
259 }
260  
261 3 return (1, join("\n", @out), '');
262 }
263  
264 sub _filter_by_lines
265 6 ▶{
Subroutine _filter_by_lines: called CC=11 SCAR=24.3
266 6 my ($text, $expr, $ctx, $state, $line_no) = @_;
267 6 my @lines = split /\n/, $text, -1;
268 6 my @picked;
269  
270 6 for my $range (split /;/, $expr)
271 {
272 6 $range =~ s/^\s+|\s+$//g;
273 6 ▶ next if $range eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $range eq "" 0 6 6
274 6 ▶ if ($range !~ /^(-?\d*)\.\.(-?\d*)$/)
Branch: 1 branch
BranchTrueFalseTotal
unless ($range =~ /^(-?\d*)\.\.(-?\d*)$/) 2 4 6
275 {
276 2 return _selector_error("invalid lines selector '$range'", $ctx->{include}{on_bad_selector}, $state, $line_no);
277 }
278 4 my ($s, $e) = ($1, $2);
279 4 ▶ my $start = ($s eq '') ? 1 : int($s);
Branch: 1 branch
BranchTrueFalseTotal
$s eq '' ? : 1 3 4
280 4 ▶ my $end = ($e eq '') ? scalar(@lines) : int($e);
Branch: 1 branch
BranchTrueFalseTotal
$e eq '' ? : 0 4 4
281 4 ▶ $end = scalar(@lines) if $end == -1;
Branch: 1 branch
BranchTrueFalseTotal
if $end == -1 1 3 4
282 4 ▶ $start = 1 if $start < 1;
Branch: 1 branch
BranchTrueFalseTotal
if $start < 1 0 4 4
283 4 ▶ $end = scalar(@lines) if $end > scalar(@lines);
Branch: 1 branch
BranchTrueFalseTotal
if $end > scalar @lines 0 4 4
284 4 ▶ next if $start > $end;
Branch: 1 branch
BranchTrueFalseTotal
if $start > $end 0 4 4
285  
286 4 for my $i ($start .. $end)
287 {
288 11 push @picked, $lines[$i - 1];
289 }
290 }
291  
292 4 return (1, join("\n", @picked), '');
293 }
294  
295 sub _selector_error
296 6 ▶{
Subroutine _selector_error: called CC=3 SCAR=11.0
297 6 my ($msg, $policy, $state, $line_no) = @_;
298 6 ▶ if ($policy eq 'keep')
Branch: 1 branch
BranchTrueFalseTotal
if ($policy eq "keep") 3 3 6
299 {
300 3 return (0, $msg, 'keep');
301 }
302 3 ▶ if ($policy eq 'drop')
Branch: 1 branch
BranchTrueFalseTotal
if ($policy eq "drop") 1 2 3
303 {
304 1 return (0, $msg, 'drop');
305 }
306 2 return (0, $msg . ' at ' . _where($state->{source_path}, $line_no), 'error');
307 }
308  
309 sub _resolve_target
310 23 ▶{
Subroutine _resolve_target: called CC=4 SCAR=15.2
311 23 my ($target, $source_path, $base_dir) = @_;
312 23 ▶ return abs_path($target) if File::Spec->file_name_is_absolute($target);
Branch: 1 branch
BranchTrueFalseTotal
if "File::Spec"->file_name_is_absolute($target) 0 23 23
313  
314 23 ▶ my $dir = defined($source_path) ? dirname($source_path) : $base_dir;
Branch: 1 branch
BranchTrueFalseTotal
defined $source_path ? : 23 0 23
315 23 my $path = File::Spec->catfile($dir, $target);
316 23 ▶ return abs_path($path) || $path;
Condition33%1/3
abs_path($path) || $path
l!l&&r!l&&!r
2300
MC/DC0%0/2
abs_path($path) || $path
abs_path($path) $path
Truth table33%1/3
A || B
A= abs_path($path)B= $path
ABresult
1X1
011
000
317 }
318  
319 sub _read_file
320 19 ▶{
Subroutine _read_file: called CC=3 SCAR=11.2
321 19 my ($path) = @_;
322 19 ▶ open my $fh, '<:encoding(UTF-8)', $path or die "cannot read include file '$path': $!\n";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<:encoding(UTF-8)", $path or die "cannot read include file '${path}': $!\n" 19 0 19
323 19 local $/;
324 19 my $content = <$fh>;
325 19 close $fh;
326 19 ▶ return defined($content) ? $content : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $content ? : 19 0 19
327 }
328  
329 sub _is_under_base
330 0 ▶{
Subroutine _is_under_base: not called CC=3 SCAR=24.8
331 0 my ($path, $base) = @_;
332 0 ▶ my $p = abs_path($path) || $path;
Condition0%0/3
abs_path($path) || $path
l!l&&r!l&&!r
000
MC/DC0%0/2
abs_path($path) || $path
abs_path($path) $path
Truth table0%0/3
A || B
A= abs_path($path)B= $path
ABresult
1X1
011
000
333 0 ▶ my $b = abs_path($base) || $base;
Condition0%0/3
abs_path($base) || $base
l!l&&r!l&&!r
000
MC/DC0%0/2
abs_path($base) || $base
abs_path($base) $base
Truth table0%0/3
A || B
A= abs_path($base)B= $base
ABresult
1X1
011
000
334 0 return index($p, $b) == 0;
335 }
336  
337 sub _where
338 5 ▶{
Subroutine _where: called CC=4 SCAR=13.9
339 5 my ($source_path, $line_no) = @_;
340 5 ▶ $line_no ||= 0;
Condition100%2/2
$line_no ||= 0
l!l
41
MC/DC100%1/1
$line_no ||= 0
$line_no
Truth table100%2/2
A
A= $line_no
Aresult
11
00
341 5 ▶ return (defined($source_path) ? $source_path : '<input>') . ($line_no ? ':' . $line_no : '');
Branch: 2 branches
BranchTrueFalseTotal
defined $source_path ? : 5 0 5
$line_no ? : 4 1 5
342 }
343  
344 18 1;
345  
346 __END__
« lib/Text/AsciidocDown/Parser.pm ↑ Summary lib/Text/AsciidocDown/Refs.pm »