line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Build::Hopen::Scope::Environment - a hopen Scope for %ENV |
2
|
|
|
|
|
|
|
package Build::Hopen::Scope::Environment; |
3
|
3
|
|
|
3
|
|
1409
|
use Build::Hopen::Base; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
24
|
|
4
|
3
|
|
|
3
|
|
629
|
use Build::Hopen qw(hlog); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
182
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.000006'; # TRIAL |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
16
|
use parent 'Build::Hopen::Scope'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
17
|
|
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
145
|
use Build::Hopen::Arrrgs; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
102
|
|
11
|
3
|
|
|
3
|
|
14
|
use Set::Scalar; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
1021
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Docs {{{1 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Build::Hopen::Scope::Environment - a Build::Hopen::Scope of %ENV |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
This is a thin wrapper around C<%ENV>, implemented as a |
22
|
|
|
|
|
|
|
L. It only supports one set of data |
23
|
|
|
|
|
|
|
(L), which is named C<0> for consistency |
24
|
|
|
|
|
|
|
with L. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 METHODS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# }}}1 |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
### Protected functions ### |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Don't support -set, but permit `-set=>0` for the sake of code calling |
35
|
|
|
|
|
|
|
# through the Scope interface. Call as `_set0($set)`. |
36
|
|
|
|
|
|
|
# Returns truthy of OK, falsy if not. |
37
|
|
|
|
|
|
|
# Better a readily-obvious crash than a subtle bug! |
38
|
|
|
|
|
|
|
sub _set0 { |
39
|
11
|
|
|
11
|
|
18
|
my $set = shift; |
40
|
11
|
50
|
33
|
|
|
26
|
return false if defined($set) && $set ne '0'; |
41
|
11
|
|
|
|
|
27
|
return true; |
42
|
|
|
|
|
|
|
} #_set0() |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 _find_here |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Find a named data item in C<%ENV> and return it. Returns undef on |
47
|
|
|
|
|
|
|
failure. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _find_here { |
52
|
9
|
|
|
9
|
|
30
|
my ($self, %args) = parameters('self', [qw(name ; set)], @_); |
53
|
9
|
50
|
|
|
|
27
|
_set0 $args{set} or croak 'I only support set 0'; |
54
|
|
|
|
|
|
|
return $ENV{$args{name}} |
55
|
9
|
|
|
|
|
56
|
} #_find_here() |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 add |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Updates the corresponding environment variables, in order, by setting C<$ENV{}>. |
60
|
|
|
|
|
|
|
Returns the instance. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub add { |
65
|
1
|
|
|
1
|
1
|
1055
|
my $self = shift; |
66
|
1
|
50
|
|
|
|
5
|
croak "Got an odd number of parameters" if @_%2; |
67
|
1
|
|
|
|
|
5
|
while(@_) { |
68
|
1
|
|
|
|
|
3
|
my $k = shift; |
69
|
1
|
|
|
|
|
10
|
$ENV{$k} = shift; |
70
|
|
|
|
|
|
|
} |
71
|
1
|
|
|
|
|
3
|
return $self; |
72
|
|
|
|
|
|
|
} #add() |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 _names_here |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Add the names in C<%ENV> to the given L. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _names_here { |
81
|
2
|
|
|
2
|
|
8
|
my ($self, %args) = parameters('self', [qw(retval ; set)], @_); |
82
|
2
|
50
|
|
|
|
7
|
_set0 $args{set} or croak 'I only support set 0'; |
83
|
2
|
|
|
0
|
|
13
|
hlog { __PACKAGE__ . '::_names_here' }; |
|
0
|
|
|
|
|
0
|
|
84
|
2
|
|
|
|
|
23
|
$args{retval}->insert(keys %ENV); |
85
|
2
|
|
|
0
|
|
415
|
hlog { Dumper $args{retval} }; |
|
0
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
} #_names_here() |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
__END__ |