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