line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Provision::TraitFor::EnvControl; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
401
|
use namespace::autoclean; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
60
|
use Class::Usul::Constants qw( FALSE NUL OK TRUE ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
6
|
1
|
|
|
1
|
|
539
|
use Class::Usul::Functions qw( emit env_prefix ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
7
|
1
|
|
|
1
|
|
1192
|
use Moo::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
requires qw( next_argv project ); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Public methods |
12
|
|
|
|
|
|
|
sub trace : method { |
13
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
14
|
0
|
|
0
|
|
|
|
my $token = $self->next_argv // NUL; |
15
|
0
|
|
|
|
|
|
my $prefix = env_prefix $self->project; |
16
|
0
|
|
|
|
|
|
my @keys = ( 'DBIC_TRACE', "${prefix}_DEBUG", "${prefix}_TRACE", ); |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my ($key, $value); |
19
|
|
|
|
|
|
|
|
20
|
0
|
0
|
|
|
|
|
if ($token eq 'show') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
emit "PATH = ".$ENV{PATH}; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
for my $k (grep { m{ PERL }mx } sort keys %ENV) { |
|
0
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
emit "${k} = ".$ENV{ $k }; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
0
|
|
|
|
for my $k (@keys) { emit "${k} = ".($ENV{ $k } // NUL) } |
|
0
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
elsif ($token eq 'dbic') { |
30
|
0
|
0
|
|
|
|
|
$key = 'DBIC_TRACE'; $value = $ENV{ $key } ? FALSE : TRUE; |
|
0
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
elsif ($token) { |
33
|
0
|
|
|
|
|
|
$key = "${prefix}_TRACE"; |
34
|
0
|
0
|
0
|
|
|
|
$value = $token eq ($ENV{ $key } // NUL) ? '""' : $token; |
35
|
|
|
|
|
|
|
} |
36
|
0
|
0
|
|
|
|
|
else { $key = "${prefix}_DEBUG"; $value = $ENV{ $key } ? FALSE : TRUE } |
|
0
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
|
$key and emit "${key}=${value}; export ${key}"; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
return OK; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=pod |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=encoding utf-8 |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 Name |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Module::Provision::TraitFor::EnvControl - Environment Control |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 Synopsis |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
use Module::Provision::TraitFor::EnvControl; |
58
|
|
|
|
|
|
|
# Brief but working code examples |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 Description |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Toggles environment variables used to control application trace output |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 Configuration and Environment |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Defines the following attributes; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=over 3 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=back |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 Subroutines/Methods |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 C<trace> - Toggles environment variables |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$exit_code = $self->trace; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Toggles environment variables |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 Diagnostics |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
None |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 Dependencies |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=over 3 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item L<Class::Usul> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=back |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 Incompatibilities |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
There are no known incompatibilities in this module |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 Bugs and Limitations |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
There are no known bugs in this module. Please report problems to |
99
|
|
|
|
|
|
|
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Module-Provision. |
100
|
|
|
|
|
|
|
Patches are welcome |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 Acknowledgements |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Larry Wall - For the Perl programming language |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 Author |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Peter Flanigan, C<< <pjfl@cpan.org> >> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 License and Copyright |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Copyright (c) 2017 Peter Flanigan. All rights reserved |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
115
|
|
|
|
|
|
|
under the same terms as Perl itself. See L<perlartistic> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
118
|
|
|
|
|
|
|
but WITHOUT WARRANTY; without even the implied warranty of |
119
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# Local Variables: |
124
|
|
|
|
|
|
|
# mode: perl |
125
|
|
|
|
|
|
|
# tab-width: 3 |
126
|
|
|
|
|
|
|
# End: |
127
|
|
|
|
|
|
|
# vim: expandtab shiftwidth=3: |