line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
1
|
|
|
1
|
|
86377
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2018'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Moo; |
7
|
1
|
|
|
1
|
|
6
|
use Catmandu::Util::Path qw(as_path); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
8
|
1
|
|
|
1
|
|
646
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
9
|
1
|
|
|
1
|
|
6
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
10
|
1
|
|
|
1
|
|
573
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
11
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has paths => (fix_arg => 'collect', default => sub {[]},); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my ($self) = @_; |
16
|
|
|
|
|
|
|
my $paths = [map {as_path($_)} @{$self->paths}]; |
17
|
3
|
|
|
3
|
|
26
|
my $getters = [map {$_->getter} @$paths]; |
18
|
3
|
|
|
|
|
6
|
my $creators = [map {$_->creator} @$paths]; |
|
4
|
|
|
|
|
37
|
|
|
3
|
|
|
|
|
10
|
|
19
|
3
|
|
|
|
|
1040
|
|
|
4
|
|
|
|
|
11
|
|
20
|
3
|
|
|
|
|
9
|
sub { |
|
4
|
|
|
|
|
70
|
|
21
|
|
|
|
|
|
|
my $data = $_[0]; |
22
|
|
|
|
|
|
|
my $temp = {}; |
23
|
3
|
|
|
3
|
|
5
|
for (my $i = 0; $i < @$getters; $i++) { |
24
|
3
|
|
|
|
|
5
|
my $getter = $getters->[$i]; |
25
|
3
|
|
|
|
|
7
|
my $creator = $creators->[$i]; |
26
|
4
|
|
|
|
|
7
|
my $values = $getter->($data); |
27
|
4
|
|
|
|
|
5
|
while (@$values) { |
28
|
4
|
|
|
|
|
63
|
$creator->($temp, shift @$values); |
29
|
4
|
|
|
|
|
12
|
} |
30
|
3
|
|
|
|
|
47
|
} |
31
|
|
|
|
|
|
|
undef %$data; |
32
|
|
|
|
|
|
|
for my $key (keys %$temp) { |
33
|
3
|
|
|
|
|
8
|
$data->{$key} = $temp->{$key}; |
34
|
3
|
|
|
|
|
7
|
} |
35
|
3
|
|
|
|
|
7
|
$data; |
36
|
|
|
|
|
|
|
}; |
37
|
3
|
|
|
|
|
46
|
} |
38
|
3
|
|
|
|
|
28
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=pod |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 NAME |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Catmandu::Fix::retain - delete everything except the paths given |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 SYNOPSIS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Keep the field _id , name , title |
51
|
|
|
|
|
|
|
retain(_id , name, title) |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Delete everything except foo.bar |
54
|
|
|
|
|
|
|
# {bar => { x => 1} , foo => {bar => 1, y => 2}} |
55
|
|
|
|
|
|
|
# to |
56
|
|
|
|
|
|
|
# {foo => {bar => 1}} |
57
|
|
|
|
|
|
|
retain(foo.bar) |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 SEE ALSO |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
L<Catmandu::Fix> |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |