line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::code; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
738
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
8
|
use Catmandu::Util qw(check_code_ref); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
8
|
1
|
|
|
1
|
|
6
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'Catmandu::Fix::Inlineable'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has code => ( |
13
|
|
|
|
|
|
|
is => 'ro', |
14
|
|
|
|
|
|
|
default => sub { |
15
|
|
|
|
|
|
|
return sub { } |
16
|
|
|
|
|
|
|
}, |
17
|
|
|
|
|
|
|
isa => \&check_code_ref, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
around BUILDARGS => sub { |
21
|
|
|
|
|
|
|
my ($orig, $class, $code) = @_; |
22
|
|
|
|
|
|
|
$orig->($class, code => $code); |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub fix { |
26
|
3
|
|
|
3
|
0
|
76
|
my ($self, $data) = @_; |
27
|
3
|
|
|
|
|
20
|
$self->code->($data); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
__END__ |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=pod |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 NAME |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Catmandu::Fix::code - run arbitrary code as fix |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 SYNOPSIS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $fix = Catmandu::Fix::code->new( sub { |
43
|
|
|
|
|
|
|
my ($data) = @_; |
44
|
|
|
|
|
|
|
# ...do something |
45
|
|
|
|
|
|
|
return $data; |
46
|
|
|
|
|
|
|
}); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 SEE ALSO |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
L<Catmandu::Fix::perlcode>, L<Catmandu::Fix::cmd> |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |