line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Connector::Proxy::YAML |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Proxy class for reading YAML configuration |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Written by Scott Hardin and Martin Bartosch for the OpenXPKI project 2012 |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
package Connector::Proxy::YAML; |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
112503
|
use strict; |
|
4
|
|
|
|
|
18
|
|
|
4
|
|
|
|
|
134
|
|
10
|
4
|
|
|
4
|
|
23
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
126
|
|
11
|
4
|
|
|
4
|
|
20
|
use English; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
39
|
|
12
|
4
|
|
|
4
|
|
3167
|
use YAML; |
|
4
|
|
|
|
|
24817
|
|
|
4
|
|
|
|
|
246
|
|
13
|
4
|
|
|
4
|
|
740
|
use Data::Dumper; |
|
4
|
|
|
|
|
7136
|
|
|
4
|
|
|
|
|
189
|
|
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
|
638
|
use Moose; |
|
4
|
|
|
|
|
468276
|
|
|
4
|
|
|
|
|
28
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
extends 'Connector::Builtin::Memory'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# set Location required (unset by parent class) |
20
|
|
|
|
|
|
|
has '+LOCATION' => ( required => 1 ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _build_config { |
23
|
6
|
|
|
6
|
|
21
|
my $self = shift; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# File not exist or not readable |
26
|
6
|
|
|
|
|
18
|
my $config; |
27
|
6
|
|
|
|
|
173
|
my $file = $self->LOCATION(); |
28
|
6
|
50
|
33
|
|
|
258
|
if ( ( -e $file ) && ( -r $file ) ) { |
29
|
6
|
|
|
|
|
22
|
eval { |
30
|
6
|
|
|
|
|
65
|
$config = YAML::LoadFile( $file ); |
31
|
|
|
|
|
|
|
}; |
32
|
6
|
50
|
|
|
|
69517
|
if ($@) { |
33
|
0
|
|
|
|
|
0
|
$self->log()->error('Proxy::Yaml error parsing file '.$file); |
34
|
0
|
|
|
|
|
0
|
$self->log()->debug( Dumper( $@ ) ); |
35
|
0
|
|
|
|
|
0
|
return $self->_node_not_exists( $file ); |
36
|
|
|
|
|
|
|
} |
37
|
6
|
|
|
|
|
221
|
$self->log()->debug('Proxy::Yaml loading configuration from file '.$file); |
38
|
|
|
|
|
|
|
} else { |
39
|
0
|
|
|
|
|
0
|
$self->log()->warn('Proxy::Yaml configuration file '.$file.' not found or not readable'); |
40
|
|
|
|
|
|
|
} |
41
|
6
|
|
|
|
|
202
|
$self->_config($config); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
0
|
1
|
|
sub set { shift; die "No set() method defined"; }; |
|
0
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
4
|
|
|
4
|
|
31271
|
no Moose; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
34
|
|
47
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
__END__ |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 Name |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Connector::Proxy::YAML |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 Description |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Reads a yaml file from the path given as LOCATION and makes its structure |
59
|
|
|
|
|
|
|
available via the accessor methods. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
If the file could not be loaded this connector returns undef for all requests. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
B<Note>: Changes made to the YAML file after the connector was first |
64
|
|
|
|
|
|
|
initialized will not be visible as the file is read once on startup and |
65
|
|
|
|
|
|
|
persited into memory. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 Parameters |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=over |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item LOCATION |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
The location of the yaml file. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=back |