line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::Condition::Builder; |
2
|
|
|
|
|
|
|
|
3
|
32
|
|
|
34
|
|
16993
|
use Catmandu::Sane; |
|
32
|
|
|
|
|
106
|
|
|
32
|
|
|
|
|
226
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
32
|
|
|
32
|
|
284
|
use Clone qw(clone); |
|
32
|
|
|
|
|
105
|
|
|
32
|
|
|
|
|
1438
|
|
8
|
32
|
|
|
32
|
|
205
|
use Moo::Role; |
|
32
|
|
|
|
|
90
|
|
|
32
|
|
|
|
|
242
|
|
9
|
32
|
|
|
32
|
|
13324
|
use namespace::clean; |
|
32
|
|
|
|
|
89
|
|
|
32
|
|
|
|
|
259
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with 'Catmandu::Fix::Base'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has pass_fixes => (is => 'rw', default => sub {[]}); |
14
|
|
|
|
|
|
|
has fail_fixes => (is => 'rw', default => sub {[]}); |
15
|
|
|
|
|
|
|
has tester => (is => 'lazy'); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub emit { |
18
|
145
|
|
|
145
|
0
|
365
|
my ($self, $fixer) = @_; |
19
|
145
|
|
|
|
|
3054
|
my $sub_var = $fixer->capture($self->tester); |
20
|
145
|
|
|
|
|
2417
|
$self->_emit_branch( |
21
|
|
|
|
|
|
|
$self->_emit_call($sub_var, $fixer->var), |
22
|
|
|
|
|
|
|
$fixer->emit_fixes($self->pass_fixes), |
23
|
|
|
|
|
|
|
$fixer->emit_fixes($self->fail_fixes), |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub import { |
28
|
18
|
|
|
18
|
|
227
|
my $target = caller; |
29
|
18
|
|
|
|
|
299
|
my ($fix, %opts) = @_; |
30
|
|
|
|
|
|
|
|
31
|
18
|
100
|
|
|
|
332
|
if (my $sym = $opts{as}) { |
32
|
|
|
|
|
|
|
my $sub = sub { |
33
|
2
|
|
|
2
|
|
4
|
my $data = shift; |
34
|
2
|
50
|
|
|
|
8
|
if ($opts{clone}) { |
35
|
0
|
|
|
|
|
0
|
$data = clone($data); |
36
|
|
|
|
|
|
|
} |
37
|
2
|
|
|
|
|
50
|
$fix->new(@_)->tester->($data); |
38
|
1
|
|
|
|
|
15
|
}; |
39
|
32
|
|
|
32
|
|
21439
|
no strict 'refs'; |
|
32
|
|
|
|
|
92
|
|
|
32
|
|
|
|
|
3235
|
|
40
|
1
|
|
|
|
|
1
|
*{"${target}::$sym"} = $sub; |
|
1
|
|
|
|
|
2336
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=pod |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 NAME |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Catmandu::Fix::Condition::Builder - Helper role to easily write fix conditions |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |