line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::copy_field; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
108826
|
use Catmandu::Sane; |
|
10
|
|
|
|
|
28
|
|
|
10
|
|
|
|
|
77
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
10
|
|
|
10
|
|
84
|
use Moo; |
|
10
|
|
|
|
|
29
|
|
|
10
|
|
|
|
|
72
|
|
8
|
10
|
|
|
10
|
|
5163
|
use Catmandu::Util::Path qw(as_path); |
|
10
|
|
|
|
|
36
|
|
|
10
|
|
|
|
|
588
|
|
9
|
10
|
|
|
10
|
|
65
|
use Clone qw(clone); |
|
10
|
|
|
|
|
38
|
|
|
10
|
|
|
|
|
444
|
|
10
|
10
|
|
|
10
|
|
93
|
use namespace::clean; |
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
72
|
|
11
|
10
|
|
|
10
|
|
5265
|
use Catmandu::Fix::Has; |
|
10
|
|
|
|
|
27
|
|
|
10
|
|
|
|
|
93
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has old_path => (fix_arg => 1); |
16
|
|
|
|
|
|
|
has new_path => (fix_arg => 1); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _build_fixer { |
19
|
29
|
|
|
29
|
|
289
|
my ($self) = @_; |
20
|
29
|
|
|
|
|
135
|
my $old_path = as_path($self->old_path); |
21
|
29
|
|
|
|
|
2733
|
my $new_path = as_path($self->new_path); |
22
|
29
|
|
|
|
|
585
|
my $getter = $old_path->getter; |
23
|
29
|
|
|
|
|
645
|
my $creator = $new_path->creator; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub { |
26
|
55
|
|
|
55
|
|
120
|
my $data = $_[0]; |
27
|
55
|
|
|
|
|
86
|
my $values = [map {clone($_)} @{$getter->($data)}]; |
|
58
|
|
|
|
|
405
|
|
|
55
|
|
|
|
|
990
|
|
28
|
55
|
|
|
|
|
168
|
while (@$values) { |
29
|
58
|
|
|
|
|
1093
|
$data = $creator->($data, shift @$values); |
30
|
|
|
|
|
|
|
} |
31
|
55
|
|
|
|
|
944
|
$data; |
32
|
29
|
|
|
|
|
298
|
}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=pod |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 NAME |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Catmandu::Fix::copy_field - copy the value of one field to a new field |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SYNOPSIS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Copy the values of foo.bar into bar.foo |
48
|
|
|
|
|
|
|
copy_field(foo.bar, bar.foo) |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 SEE ALSO |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
L<Catmandu::Fix> |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |