lib/Mojolicious/Plugin/ConfigSimple.pm

filter: Statementstmt 92.0% 23 / 25 Branchbran 80.0% 8 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 50.0% 1 / 2 totaltotal 87.8% 36 / 41 CC 7 SCAR 16.7
CC
7
Cov
89%
register
7.2
BEGIN
1.0
BEGIN
1.0
CRAP 5.3
↑ Summary
1 package Mojolicious::Plugin::ConfigSimple;
2 1 ▶use Mojo::Base 'Mojolicious::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Config::Simple::Extended;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '0.06';
6  
7 4 ▶sub register {
Subroutine register: called CC=7 SCAR=19.7
Pod documented
8 4 my ($self, $app, $args) = @_;
9 4 my $cfg;
10 4 ▶ if(exists($args->{'config_file'})){
Branch: 2 branches
BranchTrueFalseTotal
if (exists $args->{'config_file'}) { } 1 3 4
elsif (exists $args->{'config_files'}) { } 3 0 3
11 1 ▶ unless( ref $args->{'config_file'} eq 'SCALAR' ){
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $args->{"config_file"} eq "SCALAR") 1 0 1
12 1 die 'config_file key requires a SCALAR';
13 }
14 $cfg = Config::Simple->new(
15 0 $args->{'config_file'} );
16 } elsif(exists($args->{'config_files'})){
17 3 ▶ unless( ref $args->{'config_files'} eq 'ARRAY' ){
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $args->{"config_files"} eq "ARRAY") 1 2 3
18 1 die 'config_files key requires an ARRAYREF';
19 }
20 2 undef($cfg);
21 2 foreach my $file (@{$args->{'config_files'}}){
22 2 $cfg = Config::Simple::Extended->inherit({
23 base_config => $cfg,
24 filename => $file });
25 }
26 } else {
27 0 die "Constructor invoked with no Confirguration File, see perldoc for details."
28 }
29 2 ▶ return wantarray ? ( \%{$cfg->vars}, $cfg ) : \%{$cfg->vars};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 1 2
30 }
31  
32 1 ▶sub version {
Subroutine version: called CC=1 SCAR=0.0
Pod undocumented
33 1 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 1;
42 __END__
↑ Summary