line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use warnings; |
3
|
3
|
|
|
3
|
|
1481
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
117
|
|
4
|
3
|
|
|
3
|
|
15
|
use base qw( Workflow::Config ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
112
|
|
5
|
3
|
|
|
3
|
|
16
|
use Log::Log4perl qw( get_logger ); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
400
|
|
6
|
3
|
|
|
3
|
|
20
|
use Workflow::Exception qw( configuration_error ); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
27
|
|
7
|
3
|
|
|
3
|
|
183
|
use Data::Dumper qw( Dumper ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
243
|
|
8
|
3
|
|
|
3
|
|
20
|
use English qw( -no_match_vars ); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
163
|
|
9
|
3
|
|
|
3
|
|
29
|
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
20
|
|
10
|
|
|
|
|
|
|
$Workflow::Config::Perl::VERSION = '1.60'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my ( $self, $type, @items ) = @_; |
13
|
|
|
|
|
|
|
my $log ||= get_logger(); |
14
|
26
|
|
|
26
|
1
|
13274
|
|
15
|
26
|
|
33
|
|
|
117
|
$self->_check_config_type($type); |
16
|
|
|
|
|
|
|
|
17
|
26
|
|
|
|
|
2080
|
if ( !scalar @items ) { |
18
|
|
|
|
|
|
|
return @items; |
19
|
25
|
100
|
|
|
|
56
|
} |
20
|
1
|
|
|
|
|
3
|
|
21
|
|
|
|
|
|
|
my @config_items = Workflow::Config::_expand_refs(@items); |
22
|
|
|
|
|
|
|
return () unless ( scalar @config_items ); |
23
|
24
|
|
|
|
|
50
|
|
24
|
24
|
50
|
|
|
|
56
|
my @config = (); |
25
|
|
|
|
|
|
|
foreach my $item (@config_items) { |
26
|
24
|
|
|
|
|
36
|
my ( $file_name, $method ); |
27
|
24
|
|
|
|
|
31
|
if ( ref $item ) { |
28
|
27
|
|
|
|
|
36
|
$method = '_translate_perl'; |
29
|
27
|
50
|
|
|
|
65
|
$file_name = '[scalar ref]'; |
30
|
0
|
|
|
|
|
0
|
} |
31
|
0
|
|
|
|
|
0
|
|
32
|
|
|
|
|
|
|
# $item is a filename... |
33
|
|
|
|
|
|
|
else { |
34
|
|
|
|
|
|
|
$method = '_translate_perl_file'; |
35
|
|
|
|
|
|
|
$file_name = $item; |
36
|
27
|
|
|
|
|
35
|
} |
37
|
27
|
|
|
|
|
32
|
$log->info("Will parse '$type' Perl config file '$file_name'"); |
38
|
|
|
|
|
|
|
my $this_config = $self->$method( $type, $item ); |
39
|
27
|
|
|
|
|
112
|
|
40
|
27
|
|
|
|
|
8120
|
#warn "This config looks like:"; |
41
|
|
|
|
|
|
|
#warn Dumper (\$this_config); |
42
|
|
|
|
|
|
|
$log->info("Parsed Perl '$file_name' ok"); |
43
|
|
|
|
|
|
|
|
44
|
25
|
|
|
|
|
111
|
if ( exists $this_config->{'type'} ) { |
45
|
|
|
|
|
|
|
$log->debug("Adding typed configuration for '$type'"); |
46
|
25
|
100
|
66
|
|
|
7171
|
push @config, $this_config; |
|
|
100
|
|
|
|
|
|
47
|
10
|
|
|
|
|
62
|
} elsif ( $type eq 'persister' |
48
|
10
|
|
|
|
|
2822
|
and ref $this_config->{$type} eq 'ARRAY' ) |
49
|
|
|
|
|
|
|
{ |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# This special exception for persister is required because |
52
|
|
|
|
|
|
|
# the config design for persisters was different from the |
53
|
|
|
|
|
|
|
# other config types. It didn't have a top level 'persister' |
54
|
|
|
|
|
|
|
# element. For backward compatibility, I'm adding this |
55
|
|
|
|
|
|
|
# exception here. |
56
|
|
|
|
|
|
|
$log->debug("Adding multiple configurations for '$type'"); |
57
|
|
|
|
|
|
|
push @config, @{ $this_config->{$type} }; |
58
|
1
|
|
|
|
|
5
|
} else { |
59
|
1
|
|
|
|
|
271
|
$log->debug("Adding single configuration for '$type'"); |
|
1
|
|
|
|
|
3
|
|
60
|
|
|
|
|
|
|
push @config, $this_config; |
61
|
14
|
|
|
|
|
59
|
} |
62
|
14
|
|
|
|
|
3890
|
} |
63
|
|
|
|
|
|
|
return @config; |
64
|
|
|
|
|
|
|
} |
65
|
22
|
|
|
|
|
97
|
|
66
|
|
|
|
|
|
|
my ( $class, $type, $file ) = @_; |
67
|
|
|
|
|
|
|
my $log = get_logger(); |
68
|
|
|
|
|
|
|
|
69
|
27
|
|
|
27
|
|
60
|
local $INPUT_RECORD_SEPARATOR = undef; |
70
|
27
|
|
|
|
|
73
|
open( CONF, '<', $file ) |
71
|
|
|
|
|
|
|
|| configuration_error "Cannot read file '$file': $!"; |
72
|
27
|
|
|
|
|
809
|
my $config = <CONF>; |
73
|
27
|
100
|
|
|
|
1010
|
close(CONF) || configuration_error "Cannot close file '$file': $!"; |
74
|
|
|
|
|
|
|
my $data = $class->_translate_perl( $type, $config, $file ); |
75
|
26
|
|
|
|
|
5843
|
$log->debug( sub { "Translated '$type' '$file' into: ", Dumper($data) } ); |
76
|
26
|
50
|
|
|
|
308
|
return $data; |
77
|
26
|
|
|
|
|
99
|
} |
78
|
25
|
|
|
25
|
|
165
|
|
|
25
|
|
|
|
|
432
|
|
79
|
25
|
|
|
|
|
11636
|
my ( $class, $type, $config, $file ) = @_; |
80
|
|
|
|
|
|
|
my $log = get_logger(); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
no strict 'vars'; |
83
|
26
|
|
|
26
|
|
85
|
my $data = eval $config; |
84
|
26
|
|
|
|
|
73
|
if ($EVAL_ERROR) { |
85
|
|
|
|
|
|
|
configuration_error "Cannot evaluate perl data structure ", |
86
|
3
|
|
|
3
|
|
2893
|
"in '$file': $EVAL_ERROR"; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
299
|
|
87
|
26
|
|
|
|
|
3563
|
} |
88
|
26
|
100
|
|
|
|
105
|
return $data; |
89
|
1
|
|
|
|
|
6
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
25
|
|
|
|
|
49
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=pod |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 NAME |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Workflow::Config::Perl - Parse workflow configurations as Perl data structures |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 VERSION |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This documentation describes version 1.60 of this package |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SYNOPSIS |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# either of these is acceptable |
107
|
|
|
|
|
|
|
my $parser = Workflow::Config->new( 'perl' ); |
108
|
|
|
|
|
|
|
my $parser = Workflow::Config->new( 'pl' ); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
my $conf = $parser->parse( 'condition', |
111
|
|
|
|
|
|
|
'my_conditions.pl', 'your_conditions.perl' ); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 DESCRIPTION |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Implementation of configuration parser for serialized Perl data |
116
|
|
|
|
|
|
|
structures from files/data. See L<Workflow::Config> for C<parse()> |
117
|
|
|
|
|
|
|
description. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 METHODS |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 parse |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This method is required implemented by L<Workflow::Config>. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
It takes two arguments: |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=over |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * a string indicating the type of configuration. For a complete list of |
130
|
|
|
|
|
|
|
types please refer to L<Workflow::Config> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item * a list of filenames containing at least a single file name |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=back |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
The method returns a list of configuration parameters. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 SEE ALSO |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=over |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item * L<Workflow::Config> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=back |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 COPYRIGHT |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Copyright (c) 2004-2022 Chris Winters. All rights reserved. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
151
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Please see the F<LICENSE> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 AUTHORS |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Please see L<Workflow> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |