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
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use strict; |
9
|
1
|
|
|
1
|
|
128053
|
use warnings; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
24
|
|
10
|
1
|
|
|
1
|
|
4
|
use English; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
11
|
1
|
|
|
1
|
|
4
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
12
|
1
|
|
|
1
|
|
345
|
use Data::Dumper; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
16
|
|
13
|
1
|
|
|
1
|
|
509
|
|
|
1
|
|
|
|
|
5747
|
|
|
1
|
|
|
|
|
49
|
|
14
|
|
|
|
|
|
|
use Moose; |
15
|
1
|
|
|
1
|
|
433
|
extends 'Connector::Builtin'; |
|
1
|
|
|
|
|
388784
|
|
|
1
|
|
|
|
|
5
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has '+LOCATION' => ( required => 0 ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has prefix => ( |
20
|
|
|
|
|
|
|
is => 'rw', |
21
|
|
|
|
|
|
|
isa => 'Str', |
22
|
|
|
|
|
|
|
default => '' |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
my $key = shift; |
28
|
6
|
|
|
6
|
1
|
15
|
my $val = $self->_get_node( $key ); |
29
|
6
|
|
|
|
|
11
|
|
30
|
6
|
|
|
|
|
12
|
if (!defined $val) { |
31
|
|
|
|
|
|
|
return $self->_node_not_exists( $key ); |
32
|
6
|
100
|
|
|
|
13
|
} |
33
|
2
|
|
|
|
|
9
|
|
34
|
|
|
|
|
|
|
return $val; |
35
|
|
|
|
|
|
|
|
36
|
4
|
|
|
|
|
14
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $self = shift; |
39
|
|
|
|
|
|
|
return { TYPE => "scalar" }; |
40
|
|
|
|
|
|
|
} |
41
|
0
|
|
|
0
|
1
|
0
|
|
42
|
0
|
|
|
|
|
0
|
|
43
|
|
|
|
|
|
|
my $self = shift; |
44
|
|
|
|
|
|
|
my $val = $self->_get_node( shift ); |
45
|
|
|
|
|
|
|
return defined $val; |
46
|
|
|
|
|
|
|
|
47
|
4
|
|
|
4
|
1
|
7
|
} |
48
|
4
|
|
|
|
|
7
|
|
49
|
4
|
|
|
|
|
14
|
|
50
|
|
|
|
|
|
|
my $self = shift; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $prefix = $self->prefix(); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $key = shift; |
55
|
10
|
|
|
10
|
|
10
|
# We expect only a scalar key, so this is a fast and valid conversion |
56
|
|
|
|
|
|
|
$key = $key->[0] if (ref $key eq 'ARRAY'); |
57
|
10
|
|
|
|
|
287
|
|
58
|
|
|
|
|
|
|
return $ENV{$prefix.$key}; |
59
|
10
|
|
|
|
|
15
|
|
60
|
|
|
|
|
|
|
} |
61
|
10
|
100
|
|
|
|
22
|
|
62
|
|
|
|
|
|
|
no Moose; |
63
|
10
|
|
|
|
|
27
|
__PACKAGE__->meta->make_immutable; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
1
|
|
6354
|
=head1 Name |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Connector::Builtin::Env |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 Description |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Return the contents of a environment value. |
74
|
|
|
|
|
|
|
The value of LOCATION is not used. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 Configuration |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Connector::Builtin::Env->new({ |
79
|
|
|
|
|
|
|
'LOCATION' => 'Not Used' |
80
|
|
|
|
|
|
|
'prefix' => 'optional prefix to be prepended to all keys', |
81
|
|
|
|
|
|
|
}); |
82
|
|
|
|
|
|
|
|