line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::ConfigSimple; |
2
|
1
|
|
|
1
|
|
726
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
3
|
1
|
|
|
1
|
|
655
|
use Config::Simple::Extended; |
|
1
|
|
|
|
|
12121
|
|
|
1
|
|
|
|
|
11
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub register { |
8
|
4
|
|
|
4
|
1
|
1766
|
my ($self, $app, $args) = @_; |
9
|
4
|
|
|
|
|
4
|
my $cfg; |
10
|
4
|
100
|
|
|
|
13
|
if(exists($args->{'config_file'})){ |
|
|
50
|
|
|
|
|
|
11
|
1
|
50
|
|
|
|
4
|
unless( ref $args->{'config_file'} eq 'SCALAR' ){ |
12
|
1
|
|
|
|
|
15
|
die 'config_file key requires a SCALAR'; |
13
|
|
|
|
|
|
|
} |
14
|
0
|
|
|
|
|
0
|
$cfg = Config::Simple->new( |
15
|
|
|
|
|
|
|
$args->{'config_file'} ); |
16
|
|
|
|
|
|
|
} elsif(exists($args->{'config_files'})){ |
17
|
3
|
100
|
|
|
|
11
|
unless( ref $args->{'config_files'} eq 'ARRAY' ){ |
18
|
1
|
|
|
|
|
7
|
die 'config_files key requires an ARRAYREF'; |
19
|
|
|
|
|
|
|
} |
20
|
2
|
|
|
|
|
2
|
undef($cfg); |
21
|
2
|
|
|
|
|
2
|
foreach my $file (@{$args->{'config_files'}}){ |
|
2
|
|
|
|
|
4
|
|
22
|
2
|
|
|
|
|
11
|
$cfg = Config::Simple::Extended->inherit({ |
23
|
|
|
|
|
|
|
base_config => $cfg, |
24
|
|
|
|
|
|
|
filename => $file }); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} else { |
27
|
0
|
|
|
|
|
0
|
die "Constructor invoked with no Confirguration File, see perldoc for details." |
28
|
|
|
|
|
|
|
} |
29
|
2
|
100
|
|
|
|
1474
|
return wantarray ? ( \%{$cfg->vars}, $cfg ) : \%{$cfg->vars}; |
|
1
|
|
|
|
|
25
|
|
|
1
|
|
|
|
|
8
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub version { |
33
|
1
|
|
|
1
|
0
|
3220
|
return <<"END"; |
34
|
|
|
|
|
|
|
Config::Simple => $Config::Simple::VERSION |
35
|
|
|
|
|
|
|
Config::Simple::Extended => $Config::Simple::Extended::VERSION |
36
|
|
|
|
|
|
|
Mojolicious::Plugin::ConfigSimple => $VERSION |
37
|
|
|
|
|
|
|
END |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
__END__ |