| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Workflow::Config::YAML; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
305976
|
use warnings; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
220
|
|
|
4
|
2
|
|
|
2
|
|
15
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
67
|
|
|
5
|
2
|
|
|
2
|
|
37
|
use v5.14.0; |
|
|
2
|
|
|
|
|
10
|
|
|
6
|
2
|
|
|
2
|
|
13
|
use parent qw( Workflow::Config ); |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
19
|
|
|
7
|
2
|
|
|
2
|
|
175
|
use Log::Any qw( $log ); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
15
|
|
|
8
|
2
|
|
|
2
|
|
2441
|
use Workflow::Exception qw( configuration_error ); |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
147
|
|
|
9
|
2
|
|
|
2
|
|
13
|
use Carp qw(croak); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
99
|
|
|
10
|
2
|
|
|
2
|
|
453
|
use Syntax::Keyword::Try; |
|
|
2
|
|
|
|
|
2342
|
|
|
|
2
|
|
|
|
|
13
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$Workflow::Config::YAML::VERSION = '2.09'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $YAML_REQUIRED = 0; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub parse { |
|
17
|
1
|
|
|
1
|
1
|
55
|
my ( $self, $type, @items ) = @_; |
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
10
|
$self->_check_config_type($type); |
|
20
|
1
|
|
|
|
|
4
|
my @config_items = Workflow::Config::_expand_refs(@items); |
|
21
|
1
|
50
|
|
|
|
6
|
return () unless ( scalar @config_items ); |
|
22
|
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
3
|
my @config = (); |
|
24
|
1
|
|
|
|
|
3
|
foreach my $item (@config_items) { |
|
25
|
4
|
50
|
|
|
|
14
|
my $file_name = ( ref $item ) ? '[scalar ref]' : $item; |
|
26
|
4
|
|
|
|
|
27
|
$log->info("Will parse '$type' YAML config file '$file_name'"); |
|
27
|
4
|
|
|
|
|
17
|
my $this_config = do { |
|
28
|
|
|
|
|
|
|
try { |
|
29
|
|
|
|
|
|
|
$self->_translate_yaml( $type, $item ); |
|
30
|
|
|
|
|
|
|
} |
|
31
|
4
|
|
|
|
|
12
|
catch ($error) { |
|
32
|
|
|
|
|
|
|
croak $log->error("Processing $file_name: ", $error); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
}; |
|
35
|
4
|
|
|
|
|
117421
|
$log->info("Parsed YAML '$file_name' ok"); |
|
36
|
4
|
|
|
|
|
49
|
my $key = $self->get_config_type_tag($type); |
|
37
|
4
|
100
|
33
|
|
|
39
|
if ( exists $this_config->{'type'} ) { |
|
|
|
50
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
6
|
push @config, $this_config; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
elsif ( $type eq 'persister' |
|
41
|
|
|
|
|
|
|
and ref $this_config->{'persister'} eq 'ARRAY' ) { |
|
42
|
0
|
|
|
|
|
0
|
push @config, @{ $this_config->{'persister'} }; |
|
|
0
|
|
|
|
|
0
|
|
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
else { |
|
45
|
3
|
|
|
|
|
13
|
push @config, $this_config; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
} |
|
48
|
1
|
|
|
|
|
67
|
return @config; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _translate_yaml { |
|
52
|
4
|
|
|
4
|
|
78
|
my ( $self, $type, $item ) = @_; |
|
53
|
|
|
|
|
|
|
|
|
54
|
4
|
100
|
|
|
|
18
|
unless ( $YAML_REQUIRED ) { |
|
55
|
1
|
|
|
|
|
2214
|
require YAML; |
|
56
|
1
|
|
|
|
|
15924
|
YAML->import( qw( Load LoadFile ) ); |
|
57
|
1
|
|
|
|
|
3
|
$YAML_REQUIRED++; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
4
|
50
|
|
|
|
20
|
if ( ref $item ) { |
|
61
|
0
|
|
|
|
|
0
|
return Load( $$item ); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
else { |
|
64
|
4
|
|
|
|
|
18
|
return LoadFile( $item ); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=pod |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 NAME |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Workflow::Config::YAML - Parse workflow configurations as YAML data structures |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 VERSION |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This documentation describes version 2.09 of this package |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# either of these is acceptable |
|
86
|
|
|
|
|
|
|
my $parser = Workflow::Config->new( 'yaml' ); |
|
87
|
|
|
|
|
|
|
my $parser = Workflow::Config->new( 'yml' ); |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $conf = $parser->parse( 'condition', |
|
90
|
|
|
|
|
|
|
'my_conditions.yml', 'your_conditions.yaml' ); |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Implementation of configuration parser for serialized YAML data |
|
95
|
|
|
|
|
|
|
structures from files/data. See L<Workflow::Config> for C<parse()> |
|
96
|
|
|
|
|
|
|
description. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 METHODS |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 parse |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This method is required implemented by L<Workflow::Config>. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
It takes two arguments: |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=over |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item * a string indicating the type of configuration. For a complete list of |
|
109
|
|
|
|
|
|
|
types please refer to L<Workflow::Config> |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item * a list of filenames containing at least a single file name |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=back |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
The method returns a list of configuration parameters. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=over |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * L<Workflow::Config> |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=back |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Copyright (c) 2004-2021 Chris Winters. All rights reserved. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
130
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Please see the F<LICENSE> |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 AUTHORS |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Please see L<Workflow> |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |