line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::eval; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
107563
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
7
|
use Moo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
8
|
1
|
|
|
1
|
|
440
|
use List::Util qw(all); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
65
|
|
9
|
1
|
|
|
1
|
|
575
|
use Catmandu::Fix; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
42
|
|
10
|
1
|
|
|
1
|
|
7
|
use Catmandu::Util qw(is_string is_array_ref); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
61
|
|
11
|
1
|
|
|
1
|
|
464
|
use Catmandu::Util::Path qw(as_path); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
57
|
|
12
|
1
|
|
|
1
|
|
7
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
13
|
1
|
|
|
1
|
|
769
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _build_fixer { |
20
|
5
|
|
|
5
|
|
61
|
my ($self) = @_; |
21
|
5
|
|
|
|
|
69
|
my $getter = as_path($self->path)->getter; |
22
|
|
|
|
|
|
|
sub { |
23
|
5
|
|
|
5
|
|
10
|
my $data = $_[0]; |
24
|
5
|
|
|
|
|
9
|
for my $fixes (@{$getter->($data)}) { |
|
5
|
|
|
|
|
86
|
|
25
|
4
|
100
|
|
|
|
15
|
$fixes = [$fixes] unless is_array_ref($fixes); |
26
|
4
|
100
|
66
|
|
|
29
|
next unless @$fixes && all {is_string($_)} @$fixes; |
|
5
|
|
|
|
|
25
|
|
27
|
3
|
|
|
|
|
66
|
my $fixer = Catmandu::Fix->new(fixes => $fixes); |
28
|
3
|
|
|
|
|
63
|
$data = $fixer->fix($data); |
29
|
|
|
|
|
|
|
} |
30
|
5
|
|
|
|
|
106
|
$data; |
31
|
5
|
|
|
|
|
50
|
}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=pod |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 NAME |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Catmandu::Fix::eval - eval and execute fixes defined in a field |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# {fixes => 'add_field(foo,bar)'} |
47
|
|
|
|
|
|
|
eval(fixes) |
48
|
|
|
|
|
|
|
# {fixes => 'add_field(foo,bar)', foo => 'bar'} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# {fixes => ['add_field(foo,bar)','upcase(foo)'], foo => 'bar'} |
51
|
|
|
|
|
|
|
eval(fixes) |
52
|
|
|
|
|
|
|
# {fixes => ['add_field(foo,bar)','upcase(foo)'], foo => 'BAR'} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 SEE ALSO |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
L<Catmandu::Fix> |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |