MVP/Reader/Hash.pm

filter: Statementstmt 100% 22 / 22 Branchbran 75.0% 3 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 3 / 3 Podpod 100% 1 / 1 totaltotal 88.5% 31 / 35 CC 7 SCAR 17.4
CC
7
Cov
93%
read_into_assembler
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.7
↑ Summary MVP/Assembler/WithBundles.pm »
1 package Config::MVP::Reader::Hash 2.200015;
2 # ABSTRACT: a reader that tries to cope with a plain old hashref
3  
4 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 extends 'Config::MVP::Reader';
6  
7 #pod =head1 SYNOPSIS
8 #pod
9 #pod my $sequence = Config::MVP::Reader::Hash->new->read_config( \%config );
10 #pod
11 #pod =head1 DESCRIPTION
12 #pod
13 #pod In some ways, this is the L<Config::MVP::Reader> of last resort. Given a
14 #pod hashref, it attempts to interpret it as a Config::MVP::Sequence. Because
15 #pod hashes are generally unordered, order can't be relied upon unless the hash tied
16 #pod to have order (presumably with L<Tie::IxHash>). The hash keys are assumed to
17 #pod be section names and will be used as the section package moniker unless a
18 #pod L<__package> entry is found.
19 #pod
20 #pod =cut
21  
22 3 ▶sub read_into_assembler {
Subroutine read_into_assembler: called CC=7 SCAR=19.5
Pod documented
23 3 my ($self, $location, $assembler) = @_;
24  
25 3 ▶ confess "no hash given to $self" unless my $hash = $location;
Branch: 1 branch
BranchTrueFalseTotal
unless my $hash = $location 0 3 3
26  
27 3 for my $name (keys %$hash) {
28 6 my $payload = { %{ $hash->{ $name } } };
29 6 ▶ my $package = delete($payload->{__package}) || $name;
Condition66%2/3
delete $payload->{'__package'} || $name
l!l&&r!l&&!r
150
MC/DC0%0/2
delete $payload->{'__package'} || $name
delete $payload->{'__package'} $name
Truth table66%2/3
A || B
A= delete $payload->{'__package'}B= $name
ABresult
1X1
011
000
30  
31 6 $assembler->begin_section($package, $name);
32  
33 6 for my $key (%$payload) {
34 16 my $val = $payload->{ $key };
35 16 ▶ my @values = ref $val ? @$val : $val;
Branch: 1 branch
BranchTrueFalseTotal
ref $val ? : 2 14 16
36 16 $assembler->add_value($key => $_) for @values;
37 }
38  
39 6 $assembler->end_section;
40 }
41  
42 3 return $assembler->sequence;
43 }
44  
45 2 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 2 __PACKAGE__->meta->make_immutable;
47 2 1;
48  
49 __END__
↑ Summary MVP/Assembler/WithBundles.pm »