line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::Builder; |
2
|
|
|
|
|
|
|
|
3
|
99
|
|
|
99
|
|
49639
|
use Catmandu::Sane; |
|
99
|
|
|
|
|
250
|
|
|
99
|
|
|
|
|
659
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
99
|
|
|
99
|
|
34574
|
use Catmandu::Fix; |
|
99
|
|
|
|
|
369
|
|
|
99
|
|
|
|
|
3962
|
|
8
|
99
|
|
|
99
|
|
681
|
use Catmandu::Util qw(is_value require_package); |
|
99
|
|
|
|
|
329
|
|
|
99
|
|
|
|
|
5816
|
|
9
|
99
|
|
|
99
|
|
647
|
use Moo::Role; |
|
99
|
|
|
|
|
264
|
|
|
99
|
|
|
|
|
676
|
|
10
|
99
|
|
|
99
|
|
41844
|
use namespace::clean; |
|
99
|
|
|
|
|
272
|
|
|
99
|
|
|
|
|
667
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Catmandu::Fix::Base'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has fixer => (is => 'lazy'); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub emit { |
17
|
558
|
|
|
558
|
0
|
1335
|
my ($self, $fixer) = @_; |
18
|
558
|
|
|
|
|
11223
|
my $data_var = $fixer->var; |
19
|
558
|
|
|
|
|
13105
|
my $sub_var = $fixer->capture($self->fixer); |
20
|
558
|
|
|
|
|
2110
|
my $val = $self->_emit_call($sub_var, $data_var); |
21
|
558
|
|
|
|
|
1819
|
$self->_emit_assign($data_var, $val); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
1; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
__END__ |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=pod |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 NAME |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Catmandu::Fix::Builder - Base role for Catmandu fixes |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 DESCRIPTION |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
This role expects a C<_build_fixer> method that produces a coderef that |
37
|
|
|
|
|
|
|
transforms the data. Used in combination with L<Catmandu::Path> |
38
|
|
|
|
|
|
|
implementations, data manipulations can be described in a relatively high-level |
39
|
|
|
|
|
|
|
way. Most fixes shipped with Catmandu work this way and can be used as a |
40
|
|
|
|
|
|
|
starting point to write your own fixes. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SYNOPSIS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
package Catmandu::Fix::my_fix; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
use Catmandu::Sane; |
47
|
|
|
|
|
|
|
use Moo; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _build_fixer { |
52
|
|
|
|
|
|
|
sub { |
53
|
|
|
|
|
|
|
my ($data) = @_; |
54
|
|
|
|
|
|
|
$data->{foo} = 'bar'; |
55
|
|
|
|
|
|
|
$data; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |