line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
4
|
|
|
4
|
|
88092
|
|
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
22
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2019'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Moo; |
7
|
4
|
|
|
4
|
|
25
|
use Catmandu::Util::Path qw(as_path); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
18
|
|
8
|
4
|
|
|
4
|
|
2252
|
use Clone qw(clone); |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
181
|
|
9
|
4
|
|
|
4
|
|
24
|
use namespace::clean; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
159
|
|
10
|
4
|
|
|
4
|
|
22
|
use Catmandu::Fix::Has; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
15
|
|
11
|
4
|
|
|
4
|
|
2004
|
|
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
21
|
|
12
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has old_path => (fix_arg => 1); |
15
|
|
|
|
|
|
|
has new_path => (fix_arg => 1); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my ($self) = @_; |
18
|
|
|
|
|
|
|
my $old_path = as_path($self->old_path); |
19
|
7
|
|
|
7
|
|
50
|
my $new_path = as_path($self->new_path); |
20
|
7
|
|
|
|
|
35
|
my $getter = $old_path->getter; |
21
|
7
|
|
|
|
|
1031
|
my $deleter = $old_path->deleter; |
22
|
7
|
|
|
|
|
105
|
my $creator = $new_path->creator; |
23
|
7
|
|
|
|
|
25
|
|
24
|
7
|
|
|
|
|
124
|
sub { |
25
|
|
|
|
|
|
|
my $data = $_[0]; |
26
|
|
|
|
|
|
|
my $values = [map {clone($_)} @{$getter->($data)}]; |
27
|
7
|
|
|
7
|
|
11
|
$deleter->($data); |
28
|
7
|
|
|
|
|
11
|
while (@$values) { |
|
7
|
|
|
|
|
53
|
|
|
7
|
|
|
|
|
100
|
|
29
|
7
|
|
|
|
|
114
|
$data = $creator->($data, shift @$values); |
30
|
7
|
|
|
|
|
22
|
} |
31
|
7
|
|
|
|
|
120
|
$data; |
32
|
|
|
|
|
|
|
}; |
33
|
7
|
|
|
|
|
99
|
} |
34
|
7
|
|
|
|
|
60
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=pod |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 NAME |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Catmandu::Fix::move_field - move a field to another place in the data structure |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Move single fields |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Move 'foo.bar' to 'bar.foo' |
49
|
|
|
|
|
|
|
move_field(foo.bar, bar.foo) |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Move multipe fields |
52
|
|
|
|
|
|
|
# Data: |
53
|
|
|
|
|
|
|
# a: |
54
|
|
|
|
|
|
|
# b: test1 |
55
|
|
|
|
|
|
|
# c: test2 |
56
|
|
|
|
|
|
|
move_field(a,z) # -> Move all the 'a' to 'z' |
57
|
|
|
|
|
|
|
# z: |
58
|
|
|
|
|
|
|
# b: test1 |
59
|
|
|
|
|
|
|
# c: test2 |
60
|
|
|
|
|
|
|
# Data: |
61
|
|
|
|
|
|
|
# a: |
62
|
|
|
|
|
|
|
# b: test1 |
63
|
|
|
|
|
|
|
# c: test2 |
64
|
|
|
|
|
|
|
move_field(a,.) # -> Move the fields 'b' and 'c' to the root |
65
|
|
|
|
|
|
|
# b: test1 |
66
|
|
|
|
|
|
|
# c: test2 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 SEE ALSO |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
L<Catmandu::Fix> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |