Catmandu/Fix/collapse.pm

filter: Statementstmt 100% 30 / 30 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 97.5% 39 / 40 CC 3 SCAR 5.1
CC
3
Cov
100%
fix
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.7
« Catmandu/Fix/expand.pm ↑ Summary Catmandu/Hits.pm »
1 package Catmandu::Fix::collapse;
2  
3 2 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 our $VERSION = '1.2025';
6  
7 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Catmandu::Expander ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 with 'Catmandu::Fix::Inlineable';
13  
14 2 ▶has sep => (fix_opt => 1, default => sub {undef});
Subroutine __ANON__: called CC=1 SCAR=0.0
15  
16 3 ▶sub fix {
Subroutine fix: called CC=3 SCAR=11.0
Pod undocumented
17 3 my ($self, $data) = @_;
18 3 my $ref = Catmandu::Expander->collapse_hash($data);
19  
20 3 ▶ if (defined(my $char = $self->sep)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $char = $self->sep)) 1 2 3
21 1 my $new_ref = {};
22 1 for my $key (keys %$ref) {
23 2 my $val = $ref->{$key};
24 2 $key =~ s{\.}{$char}g;
25 2 $new_ref->{$key} = $val;
26 }
27 1 $ref = $new_ref;
28 }
29  
30 3 $ref;
31 }
32  
33 2 1;
34  
35 __END__
« Catmandu/Fix/expand.pm ↑ Summary Catmandu/Hits.pm »