line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
10
|
|
|
10
|
|
198
|
use 5.008; |
|
10
|
|
|
|
|
38
|
|
|
10
|
|
|
|
|
392
|
|
2
|
10
|
|
|
10
|
|
53
|
use strict; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
288
|
|
3
|
10
|
|
|
10
|
|
57
|
use warnings; |
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
483
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Hook::Modular::Walker; |
6
|
|
|
|
|
|
|
BEGIN { |
7
|
10
|
|
|
10
|
|
213
|
$Hook::Modular::Walker::VERSION = '1.101050'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
# ABSTRACT: Methods that walk over the workflow |
10
|
10
|
|
|
10
|
|
56
|
use Carp; |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
721
|
|
11
|
10
|
|
|
10
|
|
82
|
use Scalar::Util qw(blessed); |
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
834
|
|
12
|
10
|
|
|
10
|
|
15861
|
use UNIVERSAL; |
|
10
|
|
|
|
|
138
|
|
|
10
|
|
|
|
|
52
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
12
|
|
|
12
|
1
|
32
|
my $class = shift; |
16
|
12
|
50
|
|
|
|
79
|
my $self = @_ ? {@_} : {}; |
17
|
12
|
|
|
|
|
57
|
bless $self, $class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
*isa = \&UNIVERSAL::isa; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub decode_utf8 { |
22
|
12
|
|
|
12
|
1
|
36
|
my ($self, $stuff) = @_; |
23
|
12
|
50
|
|
|
|
95
|
$self = $self->new(apply_keys => 1) unless ref $self; |
24
|
247
|
100
|
|
247
|
|
1621
|
$self->apply(sub { utf8::decode($_[0]) unless utf8::is_utf8($_[0]) }) |
25
|
12
|
|
|
|
|
117
|
->($stuff); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub apply($&;@) { ## no critic |
29
|
12
|
|
|
12
|
1
|
29
|
my $self = shift; |
30
|
12
|
|
|
|
|
28
|
my $code = shift; |
31
|
12
|
50
|
|
97
|
|
163
|
my $keyapp = $self->{apply_keys} ? sub { $code->(shift) } : sub { shift }; |
|
156
|
|
|
|
|
248
|
|
|
0
|
|
|
|
|
0
|
|
32
|
12
|
|
|
|
|
31
|
my $curry; # recursive so can't init |
33
|
|
|
|
|
|
|
$curry = sub { |
34
|
180
|
|
|
180
|
|
202
|
my @retval; |
35
|
180
|
|
|
|
|
288
|
for my $arg (@_) { |
36
|
184
|
|
|
|
|
266
|
my $class = ref $arg; |
37
|
184
|
50
|
33
|
|
|
964
|
croak 'blessed reference forbidden' |
38
|
|
|
|
|
|
|
if !$self->{apply_blessed} and blessed $arg; |
39
|
156
|
|
|
|
|
283
|
my $val = |
40
|
|
|
|
|
|
|
!$class ? $code->($arg) |
41
|
|
|
|
|
|
|
: isa($arg, 'ARRAY') ? [ $curry->(@$arg) ] |
42
|
|
|
|
|
|
|
: isa($arg, 'HASH') |
43
|
|
|
|
|
|
|
? { map { $keyapp->($_) => $curry->($arg->{$_}) } keys %$arg } |
44
|
0
|
|
|
|
|
0
|
: isa($arg, 'SCALAR') ? \do { $curry->($$arg) } |
45
|
0
|
|
|
|
|
0
|
: isa($arg, 'REF') && $self->{apply_ref} ? \do { $curry->($$arg) } |
|
0
|
|
|
|
|
0
|
|
46
|
184
|
0
|
0
|
|
|
817
|
: isa($arg, 'GLOB') ? *{ $curry->(*$arg) } |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
47
|
|
|
|
|
|
|
: isa($arg, 'CODE') && $self->{apply_code} ? $code->($arg) |
48
|
|
|
|
|
|
|
: croak "I don't know how to apply to $class"; |
49
|
184
|
50
|
|
|
|
548
|
bless $val, $class if blessed $arg; |
50
|
184
|
|
|
|
|
417
|
push @retval, $val; |
51
|
|
|
|
|
|
|
} |
52
|
180
|
100
|
|
|
|
727
|
return wantarray ? @retval : $retval[0]; |
53
|
12
|
|
|
|
|
79
|
}; |
54
|
12
|
50
|
|
|
|
120
|
@_ ? $curry->(@_) : $curry; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub serialize { |
58
|
0
|
|
|
0
|
1
|
|
shift; # we don't need the class |
59
|
0
|
|
|
|
|
|
my $stuff = shift; |
60
|
0
|
|
|
|
|
|
my $curry; |
61
|
|
|
|
|
|
|
$curry = sub { |
62
|
0
|
|
|
0
|
|
|
my @retval; |
63
|
0
|
|
|
|
|
|
for my $arg (@_) { |
64
|
0
|
|
|
|
|
|
my $class = ref $arg; |
65
|
0
|
|
|
|
|
|
my $val = |
66
|
|
|
|
|
|
|
blessed $arg && $arg->can('serialize') ? $arg->serialize |
67
|
|
|
|
|
|
|
: !$class ? $arg |
68
|
|
|
|
|
|
|
: isa($arg, 'ARRAY') ? [ $curry->(@$arg) ] |
69
|
|
|
|
|
|
|
: isa($arg, 'HASH') |
70
|
|
|
|
|
|
|
? { map { $_ => $curry->($arg->{$_}) } keys %$arg } |
71
|
0
|
|
|
|
|
|
: isa($arg, 'SCALAR') ? \do { $curry->($$arg) } |
72
|
0
|
|
|
|
|
|
: isa($arg, 'REF') ? \do { $curry->($$arg) } |
|
0
|
|
|
|
|
|
|
73
|
0
|
0
|
0
|
|
|
|
: isa($arg, 'GLOB') ? *{ $curry->(*$arg) } |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
74
|
|
|
|
|
|
|
: isa($arg, 'CODE') ? $arg |
75
|
|
|
|
|
|
|
: croak "I don't know how to apply to $class"; |
76
|
0
|
|
|
|
|
|
push @retval, $val; |
77
|
|
|
|
|
|
|
} |
78
|
0
|
0
|
|
|
|
|
return wantarray ? @retval : $retval[0]; |
79
|
0
|
|
|
|
|
|
}; |
80
|
0
|
|
|
|
|
|
$curry->($stuff->clone); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |