ASP/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 100% 1 / 1 totaltotal 61.1% 22 / 36 CC 6 SCAR 24.4
CC
6
Cov
59%
config_path
16.7
BEGIN
1.0
BEGIN
1.0
CRAP 11.4
« ASP/Request.pm ↑ Summary ASP/Response.pm »
1  
2 package Apache2::ASP::ConfigFinder;
3  
4 25 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 25 ▶use warnings 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 25 ▶use Cwd 'cwd';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 25 our $CONFIGFILE = 'apache2-asp-config.xml';
9  
10 #==============================================================================
11 sub config_path
12 {
13 7 ▶ my $path = $CONFIGFILE;
Subroutine config_path: called CC=6 SCAR=28.1
Pod documented
14
15 7 ▶ my $root = $ENV{DOCUMENT_ROOT} || cwd();
Condition33%1/3
$ENV{'DOCUMENT_ROOT'} || cwd()
l!l&&r!l&&!r
070
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 7 ▶ if( -f "$root/t/conf/$CONFIGFILE" )
Branch: 1 branch
BranchTrueFalseTotal
if (-f "$root/t/conf/$Apache2::ASP::ConfigFinder::CONFIGFILE") 7 0 7
19 {
20 7 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 25 1;# return true:
36  
37 __END__
« ASP/Request.pm ↑ Summary ASP/Response.pm »