blib/lib/ASP4/ConfigFinder.pm

filter: Statementstmt 76.1% 16 / 21 Branchbran 25.0% 2 / 8 Conditioncond 20.0% 1 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 54.7% 23 / 42 CC 8 SCAR 29.4
CC
8
Cov
56%
config_path
25.8
BEGIN
1.0
BEGIN
1.0
CRAP 19.0
« blib/lib/ASP4/Error.pm ↑ Summary blib/lib/ASP4/Config.pm »
1  
2 package
3 ASP4::ConfigFinder;
4  
5 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 15 ▶use warnings 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 15 ▶use Cwd 'fastcwd';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 15 our $CONFIGFILE = 'asp4-config.json';
10  
11  
12 sub config_path
13 31020 ▶{
Subroutine config_path: called CC=8 SCAR=32.5
Pod undocumented
14 31020 my $path = $CONFIGFILE;
15
16 31020 ▶ my $root = do { ($ENV{REMOTE_ADDR} || '') eq '' ? fastcwd() : $ENV{DOCUMENT_ROOT} || fastcwd() };
Branch: 1 branch
BranchTrueFalseTotal
($ENV{'REMOTE_ADDR'} || '') eq '' ? : 31020 0 31020
Condition20%1/5
$ENV{'REMOTE_ADDR'} || ''
l!l
031020
$ENV{"DOCUMENT_ROOT"} or fastcwd()
l!l&&r!l&&!r
000
MC/DC0%0/1
$ENV{'REMOTE_ADDR'} || ''
$ENV{'REMOTE_ADDR'}
MC/DC0%0/2
$ENV{"DOCUMENT_ROOT"} or fastcwd()
$ENV{"DOCUMENT_ROOT"} fastcwd()
Truth table50%1/2
A
A= $ENV{'REMOTE_ADDR'}
Aresult
11
00
Truth table0%0/3
A or B
A= $ENV{"DOCUMENT_ROOT"}B= fastcwd()
ABresult
1X1
011
000
17
18 # Try test dir:
19 31020 ▶ if( -f "$root/t/conf/$CONFIGFILE" )
Branch: 1 branch
BranchTrueFalseTotal
if (-f "$root/t/conf/$ASP4::ConfigFinder::CONFIGFILE") 31020 0 31020
20 {
21 31020 return "$root/t/conf/$CONFIGFILE";
22 }# end if()
23
24 # Start moving up:
25 0 for( 1...10 )
26 {
27 0 my $path = "$root/conf/$CONFIGFILE";
28 0 ▶ return $path if -f $path;
Branch: 1 branch
BranchTrueFalseTotal
if -f $path 0 0 0
29 0 ▶ $root =~ s/\/[^\/]+$//
Branch: 1 branch
BranchTrueFalseTotal
$root =~ s[/[^/]+$][] or last 0 0 0
30 or last;
31 }# end for()
32
33 0 die "CANNOT FIND '$CONFIGFILE' anywhere under '$root'";
34 }# end config_path()
35  
36 15 1;# return true:
37  
« blib/lib/ASP4/Error.pm ↑ Summary blib/lib/ASP4/Config.pm »