ASP4/ConfigFinder.pm

filter: Statementstmt 75.0% 15 / 20 Branchbran 16.6% 1 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 58.3% 21 / 36 CC 6 SCAR 24.4
CC
6
Cov
59%
config_path
16.7
BEGIN
1.0
BEGIN
1.0
CRAP 11.4
« ASP4/HandlerResolver.pm ↑ Summary ASP4/ConfigNode/Web.pm »
1  
2 package ASP4::ConfigFinder;
3  
4 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use warnings 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use Cwd 'cwd';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 9 our $CONFIGFILE = 'asp4-config.json';
9  
10  
11 sub config_path
12 {
13 4 ▶ my $path = $CONFIGFILE;
Subroutine config_path: called CC=6 SCAR=28.1
Pod undocumented
14
15 4 ▶ my $root = $ENV{DOCUMENT_ROOT} || cwd();
Condition33%1/3
$ENV{'DOCUMENT_ROOT'} || cwd()
l!l&&r!l&&!r
040
MC/DC0%0/2
$ENV{'DOCUMENT_ROOT'} || cwd()
$ENV{'DOCUMENT_ROOT'} cwd()
Truth table33%1/3
A || B
A= $ENV{'DOCUMENT_ROOT'}B= cwd()
ABresult
1X1
011
000
16
17 # Try test dir:
18 4 ▶ if( -f "$root/t/conf/$CONFIGFILE" )
Branch: 1 branch
BranchTrueFalseTotal
if (-f "$root/t/conf/$ASP4::ConfigFinder::CONFIGFILE") 4 0 4
19 {
20 4 return "$root/t/conf/$CONFIGFILE";
21 }# end if()
22
23 # Start moving up:
24 0 for( 1...10 )
25 {
26 0 my $path = "$root/conf/$CONFIGFILE";
27 0 ▶ return $path if -f $path;
Branch: 1 branch
BranchTrueFalseTotal
if -f $path 0 0 0
28 0 ▶ $root =~ s/\/[^\/]+$//
Branch: 1 branch
BranchTrueFalseTotal
$root =~ s[/[^/]+$][] or last 0 0 0
29 or last;
30 }# end for()
31
32 0 die "CANNOT FIND '$CONFIGFILE' anywhere under '$root'";
33 }# end config_path()
34  
35 9 1;# return true:
36  
« ASP4/HandlerResolver.pm ↑ Summary ASP4/ConfigNode/Web.pm »