File Coverage

blib/lib/Kelp/Module/Config/ConfigGeneral.pm
Criterion Covered Total %
statement 24 24 100.0
branch 5 6 83.3
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 35 36 97.2


line stmt bran cond sub pod time code
1             package Kelp::Module::Config::ConfigGeneral;
2 5     5   2160 use strict;
  5         6  
  5         106  
3 5     5   79 use 5.008_005;
  5         11  
4 5     5   16 use Kelp::Base 'Kelp::Module::Config';
  5         5  
  5         23  
5 5     5   48177 use Config::General;
  5         57228  
  5         1032  
6              
7             our $VERSION = '0.03';
8              
9             attr ext => 'conf';
10              
11             sub load {
12 9     9 1 1763 my ( $self, $filename ) = @_;
13              
14 9         39 my $conf = Config::General->new(
15             -ConfigFile => $filename,
16             -ForceArray => 1,
17             -IncludeAgain => 1,
18             -InterPolateVars => 1,
19             );
20 9         12756 my %config = $conf->getall;
21              
22             # Hack for using default Log::Dispatch
23 9 100       69 if ( exists $config{modules_init}{Logger} ) {
24 2         3 my $outputs = $config{modules_init}{Logger}{outputs};
25            
26             my @outputs = map {
27 2         3 my ( $k, $v ) = ($_, $outputs->{$_});
  2         4  
28 2         3 my @res;
29 2 50       8 push @res, ( ref $v eq 'ARRAY' ) ? map { [ $k, %$_ ] } @$v
  2 100       7  
30             : ( ref $v eq 'HASH' ) ? [ $k, %$v ]
31             : [];
32 2         5 @res;
33             } keys %$outputs;
34 2         7 $config{modules_init}{Logger}{outputs} = \@outputs;
35             }
36            
37 9         101 return \%config;
38             }
39              
40             1;
41             __END__