line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BioX::Workflow::Command::run::Rules::Directives::Walk; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
42631
|
use Moose::Role; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
5611
|
use namespace::autoclean; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
17
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
111
|
use Data::Walk; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
94
|
|
7
|
1
|
|
|
1
|
|
12
|
use Path::Tiny; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
500
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub walk_process_data { |
10
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
11
|
0
|
|
|
|
|
|
my $keys = shift; |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
|
|
|
foreach my $k ( @{$keys} ) { |
|
0
|
|
|
|
|
|
|
14
|
0
|
0
|
|
|
|
|
next if ref($k); |
15
|
0
|
|
|
|
|
|
my $v = $self->$k; |
16
|
|
|
|
|
|
|
##Leftover of backwards compatibility |
17
|
0
|
0
|
|
|
|
|
if ( $k eq 'find_by_dir' ) { |
|
|
0
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
$self->process_directive( $k, $v ); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
elsif($self->search_registered_process_directives($k, $v)){ |
21
|
0
|
|
|
|
|
|
next; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
else { |
24
|
0
|
|
|
|
|
|
$self->process_directive( $k, $v ); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
##TODO Combine this with search_registered_types |
30
|
|
|
|
|
|
|
sub search_registered_process_directives { |
31
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
32
|
0
|
|
|
|
|
|
my $k = shift; |
33
|
0
|
|
|
|
|
|
my $v = shift; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
foreach my $key ( keys %{ $self->register_process_directives } ) { |
|
0
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
next unless exists $self->register_process_directives->{$key}->{lookup}; |
37
|
|
|
|
|
|
|
next |
38
|
0
|
0
|
|
|
|
|
unless exists $self->register_process_directives->{$key}->{builder}; |
39
|
0
|
|
|
|
|
|
my $lookup_ref = $self->register_process_directives->{$key}->{lookup}; |
40
|
0
|
|
|
|
|
|
my $builder = $self->register_process_directives->{$key}->{builder}; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
foreach my $lookup ( @{$lookup_ref} ) { |
|
0
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
if ( $k =~ m/$lookup/ ) { |
44
|
0
|
|
|
|
|
|
$self->$builder( $k, $v ); |
45
|
0
|
|
|
|
|
|
return 1; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return 0; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head3 process_directive |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub process_directive { |
58
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
59
|
0
|
|
|
|
|
|
my $k = shift; |
60
|
0
|
|
|
|
|
|
my $v = shift; |
61
|
0
|
|
|
|
|
|
my $path = shift; |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
if ( ref($v) ) { |
64
|
|
|
|
|
|
|
walk { |
65
|
0
|
|
|
0
|
|
|
wanted => sub { $self->walk_directives( @_ ) } |
66
|
|
|
|
|
|
|
}, |
67
|
0
|
|
|
|
|
|
$self->$k; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
else { |
70
|
0
|
|
|
|
|
|
my $text = ''; |
71
|
0
|
0
|
|
|
|
|
$text = $self->interpol_directive($v) if $v; |
72
|
0
|
|
|
|
|
|
$self->$k($text); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head3 walk_directives |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Invoke with |
79
|
|
|
|
|
|
|
walk { wanted => sub { $self->directives(@_) } }, $self->other_thing; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Acts funny with $self->some_other_thing is not a reference |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub walk_directives { |
86
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
87
|
0
|
|
|
|
|
|
my $ref = shift; |
88
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
return if ref($ref); |
90
|
0
|
0
|
|
|
|
|
return unless $ref; |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
my $text = ''; |
93
|
0
|
0
|
|
|
|
|
$text = $self->interpol_directive($ref) if $ref; |
94
|
0
|
|
|
|
|
|
$self->update_directive($text); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head3 update_directive |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Take the values from walk_directive and update the directive |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub update_directive { |
104
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
105
|
0
|
|
|
|
|
|
my $text = shift; |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
my ( $key, $container, $index ); |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
$container = $Data::Walk::container; |
110
|
0
|
|
|
|
|
|
$key = $Data::Walk::key; |
111
|
0
|
|
|
|
|
|
$index = $Data::Walk::index; |
112
|
|
|
|
|
|
|
|
113
|
0
|
0
|
0
|
|
|
|
if ( $Data::Walk::type eq 'HASH' && $key ) { |
|
|
0
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
$container->{$key} = $text; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
elsif ( $Data::Walk::type eq 'ARRAY' ) { |
117
|
0
|
|
|
|
|
|
$container->[$index] = $text; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
else { |
120
|
|
|
|
|
|
|
#We are getting the whole hash, just return |
121
|
0
|
|
|
|
|
|
return; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; |