blib/lib/Config/Merged.pm

filter: Statementstmt 96.4% 27 / 28 Branchbran 83.3% 5 / 6 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 95.8% 46 / 48 CC 7 SCAR 10.5
CC
7
Cov
95%
_merge
4.1
_merge_hash
4.0
BEGIN
1.0
CRAP 2.9
↑ Summary
1 package Config::Merged;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 require 5.006;
7  
8 2 ▶use base qw( Config::Any );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 2 our $VERSION = '0.05';
12  
13  
14 2 ▶sub load_files { _merge( shift->SUPER::load_files( @_ ) ) }
Subroutine load_files: called CC=1 SCAR=0.0
Pod documented
15  
16 2 ▶sub load_stems { _merge( shift->SUPER::load_stems( @_ ) ) }
Subroutine load_stems: called CC=1 SCAR=0.0
Pod documented
17  
18 4 ▶sub _merge {
Subroutine _merge: called CC=4 SCAR=14.0
19 4 my ( $mixed ) = @_;
20  
21 4 my ( $config, @configs );
22  
23 4 ▶ if( ref $mixed eq 'ARRAY' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $mixed eq 'ARRAY') { } 2 2 4
elsif (ref $mixed eq 'HASH') { } 2 0 2
24 2 ( $config, @configs ) = map { (%$_)[1] } @$mixed;
25 }
26 elsif( ref $mixed eq 'HASH' ) {
27 2 ( $config, @configs ) = values %$mixed;
28 }
29 else {
30 0 die "Config::Any returned something unexpected. Please contact the author and report this as a bug\n";
31 }
32  
33 _merge_hash( $config, $_ )
34 4 for @configs;
35  
36 4 return $config;
37 }
38  
39 10 ▶sub _merge_hash {
Subroutine _merge_hash: called CC=4 SCAR=13.9
40 10 my ( $left, $right ) = @_;
41  
42 10 for my $key ( keys %$right ) {
43 16 ▶ if( ref $right->{$key} eq 'HASH' && ref $left->{$key} eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $right->{$key} eq 'HASH' and ref $left->{$key} eq 'HASH') { } 6 10 16
Condition100%3/3
ref $right->{$key} eq "HASH" and ref $left->{$key} eq "HASH"
!ll&&!rl&&r
826
MC/DC100%2/2
ref $right->{$key} eq "HASH" and ref $left->{$key} eq "HASH"
ref $right->{$key} eq "HASH" ref $left->{$key} eq "HASH"
Truth table100%3/3
A and B
A= ref $right->{$key} eq "HASH"B= ref $left->{$key} eq "HASH"
ABresult
0X0
100
111
44 6 _merge_hash( $left->{$key}, $right->{$key} );
45 }
46 else {
47 10 $left->{$key} = $right->{$key};
48 }
49 }
50 }
51  
52  
53 2 1
54 __END__
↑ Summary