| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::Pipeline::Action::Regex; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2713
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
with 'Data::Pipeline::Action'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has rules => ( |
|
7
|
|
|
|
|
|
|
is => 'ro', |
|
8
|
|
|
|
|
|
|
isa => 'ArrayRef', |
|
9
|
|
|
|
|
|
|
lazy => 1, |
|
10
|
|
|
|
|
|
|
default => sub { [ ] }, |
|
11
|
|
|
|
|
|
|
predicate => 'has_rules', |
|
12
|
|
|
|
|
|
|
); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub map_item { |
|
15
|
|
|
|
|
|
|
my($self, $item) = @_; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
return $item unless $self -> has_rules; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my($target_hash, $target_e); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
for(my $i = 0; $i < @{$self -> rules}; $i += 2) { |
|
22
|
|
|
|
|
|
|
($target_hash, $target_e) = $self -> _decompose($self -> rules -> [$i], $item); |
|
23
|
|
|
|
|
|
|
local($_) = $target_hash -> {$target_e}; |
|
24
|
|
|
|
|
|
|
$self -> rules -> [$i+1] -> ( $target_hash -> {$target_e} ); |
|
25
|
|
|
|
|
|
|
$target_hash -> {$target_e} = $_; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
return $item; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _decompose { |
|
32
|
|
|
|
|
|
|
my($self, $path, $hash) = @_; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my($root, $rest) = split(/\./, $path, 2); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
if( !defined( $rest ) || $rest == '' ) { |
|
37
|
|
|
|
|
|
|
return($hash, $root); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
if( !exists( $hash -> {$root} ) ) { |
|
41
|
|
|
|
|
|
|
$hash -> {$root} = { }; |
|
42
|
|
|
|
|
|
|
return $self -> _decompose( $rest, $hash -> {$root} ); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
if( is_HashRef( $hash -> {$root} ) ) { |
|
46
|
|
|
|
|
|
|
return $self -> _decompose( $rest, $hash -> {$root} ); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
return( undef, undef ); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |
|
55
|
|
|
|
|
|
|
|