line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Connector::Builtin::Env |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Read values from the environment |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Written by Oliver Welter for the OpenXPKI project 2014 |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
package Connector::Builtin::Env; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
156698
|
use strict; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
38
|
|
10
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
11
|
1
|
|
|
1
|
|
5
|
use English; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
12
|
1
|
|
|
1
|
|
465
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
13
|
1
|
|
|
1
|
|
645
|
use Data::Dumper; |
|
1
|
|
|
|
|
7107
|
|
|
1
|
|
|
|
|
65
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
521
|
use Moose; |
|
1
|
|
|
|
|
481096
|
|
|
1
|
|
|
|
|
6
|
|
16
|
|
|
|
|
|
|
extends 'Connector::Builtin'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has '+LOCATION' => ( required => 0 ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has prefix => ( |
21
|
|
|
|
|
|
|
is => 'rw', |
22
|
|
|
|
|
|
|
isa => 'Str', |
23
|
|
|
|
|
|
|
default => '' |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub get { |
27
|
|
|
|
|
|
|
|
28
|
6
|
|
|
6
|
1
|
21
|
my $self = shift; |
29
|
6
|
|
|
|
|
11
|
my $key = shift; |
30
|
6
|
|
|
|
|
16
|
my $val = $self->_get_node( $key ); |
31
|
|
|
|
|
|
|
|
32
|
6
|
100
|
|
|
|
15
|
if (!defined $val) { |
33
|
2
|
|
|
|
|
13
|
return $self->_node_not_exists( $key ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
4
|
|
|
|
|
34
|
return $val; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get_meta { |
41
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
42
|
0
|
|
|
|
|
0
|
return { TYPE => "scalar" }; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub exists { |
46
|
|
|
|
|
|
|
|
47
|
4
|
|
|
4
|
1
|
9
|
my $self = shift; |
48
|
4
|
|
|
|
|
11
|
my $val = $self->_get_node( shift ); |
49
|
4
|
|
|
|
|
23
|
return defined $val; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _get_node { |
54
|
|
|
|
|
|
|
|
55
|
10
|
|
|
10
|
|
18
|
my $self = shift; |
56
|
|
|
|
|
|
|
|
57
|
10
|
|
|
|
|
337
|
my $prefix = $self->prefix(); |
58
|
|
|
|
|
|
|
|
59
|
10
|
|
|
|
|
18
|
my $key = shift; |
60
|
|
|
|
|
|
|
# We expect only a scalar key, so this is a fast and valid conversion |
61
|
10
|
100
|
|
|
|
31
|
$key = $key->[0] if (ref $key eq 'ARRAY'); |
62
|
|
|
|
|
|
|
|
63
|
10
|
|
|
|
|
36
|
return $ENV{$prefix.$key}; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
1
|
|
8084
|
no Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
68
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
__END__ |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 Name |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Connector::Builtin::Env |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 Description |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Return the contents of a environment value. |
80
|
|
|
|
|
|
|
The value of LOCATION is not used. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 Configuration |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Connector::Builtin::Env->new({ |
85
|
|
|
|
|
|
|
'LOCATION' => 'Not Used' |
86
|
|
|
|
|
|
|
'prefix' => 'optional prefix to be prepended to all keys', |
87
|
|
|
|
|
|
|
}); |
88
|
|
|
|
|
|
|
|