File Coverage

blib/lib/Apache2/ASP/ConfigLoader.pm
Criterion Covered Total %
statement 22 24 91.6
branch 1 2 50.0
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 31 34 91.1


line stmt bran cond sub pod time code
1              
2             package Apache2::ASP::ConfigLoader;
3              
4 24     24   633 use strict;
  24         33  
  24         710  
5 24     24   94 use warnings 'all';
  24         32  
  24         846  
6 24     24   108 use Carp 'confess';
  24         30  
  24         1650  
7 24     24   9039 use Apache2::ASP::ConfigFinder;
  24         40  
  24         635  
8 24     24   8949 use Apache2::ASP::ConfigParser;
  24         47  
  24         667  
9 24     24   18930 use XML::Simple ();
  24         203300  
  24         4045  
10             $XML::Simple::PREFERRED_PARSER = 'XML::Parser';
11              
12             our $Configs = { };
13              
14              
15             #==============================================================================
16             sub load
17             {
18 24     24 1 5695 my ($s) = @_;
19            
20 24         198 my $path = Apache2::ASP::ConfigFinder->config_path;
21 24 50       351 return $Configs->{$path} if $Configs->{$path};
22            
23 24         459 my $doc = XML::Simple::XMLin( $path,
24             SuppressEmpty => '',
25             ForceArray => [qw/ var setting location /],
26             KeyAttr => { },
27             );
28            
29 0           (my $where = $path) =~ s/\/conf\/[^\/]+$//;
30 0           return $Configs->{$path} = Apache2::ASP::ConfigParser->new->parse( $doc, $where );
31             }# end parse()
32              
33             1;# return true:
34              
35             __END__