line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
19
|
|
|
19
|
|
222
|
use 5.10.1; |
|
19
|
|
|
|
|
59
|
|
2
|
19
|
|
|
19
|
|
106
|
use strict; |
|
19
|
|
|
|
|
33
|
|
|
19
|
|
|
|
|
362
|
|
3
|
19
|
|
|
19
|
|
80
|
use warnings; |
|
19
|
|
|
|
|
28
|
|
|
19
|
|
|
|
|
4496
|
|
4
|
|
|
|
|
|
|
package Data::Processor::Transformer; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# XXX document this with pod. (if standalone) |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
194
|
|
|
194
|
0
|
336
|
my $class = shift; |
10
|
|
|
|
|
|
|
|
11
|
194
|
|
|
|
|
279
|
my $self = {}; |
12
|
194
|
|
|
|
|
296
|
bless ($self, $class); |
13
|
194
|
|
|
|
|
1010
|
return $self; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub transform { |
17
|
275
|
|
|
275
|
0
|
372
|
my $self = shift; |
18
|
275
|
|
|
|
|
349
|
my $key = shift; |
19
|
275
|
|
|
|
|
321
|
my $schema_key = shift; |
20
|
275
|
|
|
|
|
309
|
my $section = shift; |
21
|
275
|
100
|
|
|
|
549
|
if (exists $section->{schema}{$schema_key}{transformer}){ |
22
|
7
|
|
|
|
|
11
|
my $return_value; |
23
|
7
|
|
|
|
|
19
|
eval { |
24
|
7
|
|
|
|
|
29
|
local $SIG{__DIE__}; |
25
|
|
|
|
|
|
|
$return_value = |
26
|
7
|
|
|
|
|
24
|
$section->{schema}{$schema_key}{transformer}($section->{data}{$key},$section->{data}); |
27
|
|
|
|
|
|
|
}; |
28
|
7
|
100
|
|
|
|
87
|
if (my $err = $@) { |
29
|
2
|
50
|
33
|
|
|
18
|
if (ref $err eq 'HASH' && defined $err->{msg}){ |
30
|
2
|
|
|
|
|
6
|
$err = $err->{msg}; |
31
|
|
|
|
|
|
|
} |
32
|
2
|
|
|
|
|
11
|
return "error transforming '$key': $err"; |
33
|
|
|
|
|
|
|
} |
34
|
5
|
|
|
|
|
10
|
$section->{data}{$key} = $return_value; |
35
|
|
|
|
|
|
|
} |
36
|
273
|
|
|
|
|
511
|
return undef; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1 |