line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BioX::Workflow::Command::run::Rules::Directives::Types::Config; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1744
|
use Moose::Role; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
4
|
1
|
|
|
1
|
|
4308
|
use namespace::autoclean; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
7
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
with 'BioX::Workflow::Command::run::Rules::Directives::Types::Roles::File'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
74
|
use Config::Any; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
9
|
1
|
|
|
1
|
|
6
|
use Try::Tiny; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
294
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
after 'BUILD' => sub { |
12
|
|
|
|
|
|
|
my $self = shift; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$self->set_register_types( |
15
|
|
|
|
|
|
|
'config', |
16
|
|
|
|
|
|
|
{ |
17
|
|
|
|
|
|
|
builder => 'create_reg_attr', |
18
|
|
|
|
|
|
|
lookup => [ |
19
|
|
|
|
|
|
|
'.*_json$', '.*_yaml$', '.*_yml$', '.*_jsn$', |
20
|
|
|
|
|
|
|
'.*_config', '.*_conf$' |
21
|
|
|
|
|
|
|
] |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$self->set_register_process_directives( |
26
|
|
|
|
|
|
|
'config', |
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
builder => 'process_directive_config', |
29
|
|
|
|
|
|
|
lookup => [ |
30
|
|
|
|
|
|
|
'.*_json$', '.*_yaml$', '.*_yml$', '.*_jsn$', |
31
|
|
|
|
|
|
|
'.*_config', '.*_conf$' |
32
|
|
|
|
|
|
|
] |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
}; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head3 process_directive_config |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
##TODO Think about adding in multiple files - supported by Config::Any |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
This only takes the argument file |
43
|
|
|
|
|
|
|
For now only one file per entry is supported |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub process_directive_config { |
48
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
49
|
0
|
|
|
|
|
|
my $k = shift; |
50
|
0
|
|
|
|
|
|
my $v = shift; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $file = $self->check_file_exists( $k, $v ); |
53
|
0
|
0
|
|
|
|
|
return unless $file; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $cfg; |
56
|
0
|
|
|
|
|
|
my $valid = 1; |
57
|
|
|
|
|
|
|
try { |
58
|
0
|
|
|
0
|
|
|
$cfg = Config::Any->load_files( { files => [$file], use_ext => 1 } ); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
catch { |
61
|
0
|
|
|
0
|
|
|
$self->app_log->warn( |
62
|
|
|
|
|
|
|
"Unable to load the config with '. $k .' The following error was received.\n" |
63
|
|
|
|
|
|
|
); |
64
|
0
|
|
|
|
|
|
$self->app_log->warn("$_\n"); |
65
|
0
|
|
|
|
|
|
$valid = 0; |
66
|
0
|
|
|
|
|
|
}; |
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
if ( !$valid ) { |
69
|
0
|
|
|
|
|
|
$self->$k($v); |
70
|
0
|
|
|
|
|
|
return; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
$cfg = $cfg->[0]; |
74
|
0
|
|
|
|
|
|
my $config = $cfg->{$file}; |
75
|
0
|
|
|
|
|
|
$self->$k($config); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |