line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
1
|
|
|
1
|
|
86961
|
use Catmandu::Util::Path qw(as_path); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
4
|
1
|
|
|
1
|
|
479
|
use Catmandu::Util qw(is_array_ref); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
5
|
1
|
|
|
1
|
|
6
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
6
|
1
|
|
|
1
|
|
5
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
334
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
8
|
1
|
|
|
1
|
|
676
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has old_path => (fix_arg => 1); |
12
|
|
|
|
|
|
|
has new_path => (fix_arg => 1); |
13
|
|
|
|
|
|
|
has key_name => (fix_arg => 1); |
14
|
|
|
|
|
|
|
has value_name => (fix_arg => 1); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my ($self) = @_; |
17
|
|
|
|
|
|
|
my $key_name = $self->key_name; |
18
|
3
|
|
|
3
|
|
28
|
my $val_name = $self->value_name; |
19
|
3
|
|
|
|
|
48
|
my $getter = as_path($self->old_path)->getter; |
20
|
3
|
|
|
|
|
11
|
my $creator = as_path($self->new_path)->creator; |
21
|
3
|
|
|
|
|
17
|
as_path($self->new_path)->creator( |
22
|
3
|
|
|
|
|
29
|
sub { |
23
|
|
|
|
|
|
|
my ($arr, $data) = @_; |
24
|
|
|
|
|
|
|
if (is_array_ref($arr //= [])) { |
25
|
3
|
|
|
3
|
|
8
|
for my $hash (@{$getter->($data)}) { |
26
|
3
|
100
|
100
|
|
|
17
|
for my $key (sort keys %$hash) { |
27
|
2
|
|
|
|
|
4
|
push @$arr, |
|
2
|
|
|
|
|
73
|
|
28
|
2
|
|
|
|
|
15
|
{$key_name => $key, $val_name => $hash->{$key},}; |
29
|
|
|
|
|
|
|
} |
30
|
4
|
|
|
|
|
26
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
$arr; |
33
|
|
|
|
|
|
|
} |
34
|
3
|
|
|
|
|
71
|
); |
35
|
|
|
|
|
|
|
} |
36
|
3
|
|
|
|
|
18
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=pod |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Catmandu::Fix::disassoc - inverse of assoc, transform a hash into an array of key value pairs |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SYNOPSIS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# {fields => {subject => 'Perl', year => 2009}} |
49
|
|
|
|
|
|
|
disassoc(fields, pairs, key, val) |
50
|
|
|
|
|
|
|
# {pairs => [{key => 'year', val => 2009}, {key => 'subject', val => 'Perl'}], fields => ...} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SEE ALSO |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
L<Catmandu::Fix::assoc>, L<Catmandu::Fix> |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |