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