| 1 | package Run::Env; | ||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use Carp::Clan (); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 7 | 7 | ▶ | use File::Spec (); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use FindBin::Real (); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use List::MoreUtils 'any'; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||
| 11 | 7 | our $VERSION = '0.08'; | |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||
| 14 | 7 | our @running_envs = qw{ | |||||||||||||||||||||||||||||
| 15 | development | ||||||||||||||||||||||||||||||
| 16 | uat | ||||||||||||||||||||||||||||||
| 17 | staging | ||||||||||||||||||||||||||||||
| 18 | production | ||||||||||||||||||||||||||||||
| 19 | }; | ||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||
| 21 | 7 | our @execution_modes = qw{ | |||||||||||||||||||||||||||||
| 22 | cgi | ||||||||||||||||||||||||||||||
| 23 | mod_perl | ||||||||||||||||||||||||||||||
| 24 | shell | ||||||||||||||||||||||||||||||
| 25 | }; | ||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||
| 28 | 7 | my $os_root_dir = File::Spec->rootdir(); | |||||||||||||||||||||||||||||
| 29 | 7 | our @os_conf_location = ($os_root_dir, 'etc'); | |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||
| 31 | 10 | ▶ | sub import { | ||||||||||||||||||||||||||||
|
Subroutine
import: called CC=9 SCAR=25.2
| |||||||||||||||||||||||||||||||
| 32 | 10 | my $class = shift; | |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||
| 34 | 10 | foreach my $env (@_) { | |||||||||||||||||||||||||||||
| 35 | 6 | ▶ | next if not $env; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||
| 37 | $env eq 'testing' ? set_testing() | ||||||||||||||||||||||||||||||
| 38 | : $env eq '-testing' ? clear_testing() | ||||||||||||||||||||||||||||||
| 39 | : $env eq 'debug' ? set_debug() | ||||||||||||||||||||||||||||||
| 40 | : $env eq '-debug' ? clear_debug() | ||||||||||||||||||||||||||||||
| 41 | 4 | ▶ | : any { $env eq $_ } @running_envs | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 42 | ? set($env) | ||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | : any { $env eq $_ } @execution_modes | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 44 | 6 | ▶ | ? set_execution($env) | ||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||
| 45 | : Carp::Clan::croak 'no such env/mode: '.$env | ||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||
| 49 | do { | ||||||||||||||||||||||||||||||
| 50 | 7 | our $running_env = set(detect_running_env()); | |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||
| 52 | 7 | ▶ | sub detect_running_env { | ||||||||||||||||||||||||||||
|
Subroutine
detect_running_env: called CC=5 SCAR=16.7
Pod
documented
| |||||||||||||||||||||||||||||||
| 53 | return $ENV{'RUN_ENV_current'} | ||||||||||||||||||||||||||||||
| 54 | 7 | ▶ | if $ENV{'RUN_ENV_current'}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||
| 56 | 5 | ▶ | return 'development' | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 57 | if (-e File::Spec->catfile(@os_conf_location, 'development-machine')); | ||||||||||||||||||||||||||||||
| 58 | 5 | ▶ | return 'uat' | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 59 | if (-e File::Spec->catfile(@os_conf_location, 'uat-machine')); | ||||||||||||||||||||||||||||||
| 60 | 5 | ▶ | return 'staging' | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 61 | if (-e File::Spec->catfile(@os_conf_location, 'staging-machine')); | ||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||
| 63 | # default is production | ||||||||||||||||||||||||||||||
| 64 | 5 | return 'production'; | |||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||
| 67 | 14 | ▶ | sub _decide { | ||||||||||||||||||||||||||||
|
Subroutine
_decide: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 68 | 14 | ▶ | return 1 if $running_env eq shift; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 69 | 7 | return 0; | |||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||
| 72 | 13 | ▶ | sub _set { | ||||||||||||||||||||||||||||
|
Subroutine
_set: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 73 | 13 | my $set_running_env = shift; | |||||||||||||||||||||||||||||
| 74 | 13 | $running_env = $set_running_env; | |||||||||||||||||||||||||||||
| 75 | 13 | $ENV{'RUN_ENV_current'} = $set_running_env; | |||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||
| 78 | 4 | ▶ | sub current { | ||||||||||||||||||||||||||||
|
Subroutine
current: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 79 | 4 | return $running_env; | |||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||
| 82 | 7 | *dev = *development; | |||||||||||||||||||||||||||||
| 83 | 4 | ▶ | sub development { | ||||||||||||||||||||||||||||
|
Subroutine
development: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 84 | 4 | return _decide('development'); | |||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||
| 87 | 2 | ▶ | sub uat { | ||||||||||||||||||||||||||||
|
Subroutine
uat: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 88 | 2 | return _decide('uat'); | |||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||
| 91 | 7 | *stg = *staging; | |||||||||||||||||||||||||||||
| 92 | 4 | ▶ | sub staging { | ||||||||||||||||||||||||||||
|
Subroutine
staging: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 93 | 4 | return _decide('staging'); | |||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||
| 96 | 7 | *prod = *production; | |||||||||||||||||||||||||||||
| 97 | 4 | ▶ | sub production { | ||||||||||||||||||||||||||||
|
Subroutine
production: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 98 | 4 | return _decide('production'); | |||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||
| 101 | 11 | ▶ | sub set { | ||||||||||||||||||||||||||||
|
Subroutine
set: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||
| 102 | 11 | my $set_running_env = shift; | |||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||
| 104 | 11 | ▶ | if ($set_running_env eq 'development') { | ||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||
| 105 | 1 | set_development(); | |||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||
| 107 | elsif ($set_running_env eq 'uat') { | ||||||||||||||||||||||||||||||
| 108 | 2 | set_uat(); | |||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||
| 110 | elsif ($set_running_env eq 'staging') { | ||||||||||||||||||||||||||||||
| 111 | 2 | set_staging(); | |||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||
| 113 | elsif ($set_running_env eq 'production') { | ||||||||||||||||||||||||||||||
| 114 | 6 | set_production(); | |||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||
| 116 | else { | ||||||||||||||||||||||||||||||
| 117 | 0 | Carp::Clan::croak 'no such running environment: '.$set_running_env; | |||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||
| 121 | 1 | ▶ | sub set_development { | ||||||||||||||||||||||||||||
|
Subroutine
set_development: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 122 | 1 | _set('development'); | |||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||
| 125 | 3 | ▶ | sub set_uat { | ||||||||||||||||||||||||||||
|
Subroutine
set_uat: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 126 | 3 | _set('uat'); | |||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||
| 129 | 3 | ▶ | sub set_staging { | ||||||||||||||||||||||||||||
|
Subroutine
set_staging: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 130 | 3 | _set('staging'); | |||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||
| 133 | 6 | ▶ | sub set_production { | ||||||||||||||||||||||||||||
|
Subroutine
set_production: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 134 | 6 | _set('production'); | |||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||
| 137 | 7 | }; | |||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||
| 139 | do { | ||||||||||||||||||||||||||||||
| 140 | 7 | our $debug_mode = set_debug(detect_debug()); | |||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||
| 142 | 7 | ▶ | sub detect_debug { | ||||||||||||||||||||||||||||
|
Subroutine
detect_debug: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 143 | 7 | ▶ | return 1 if $ENV{'RUN_ENV_debug'}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 144 | 6 | ▶ | return 1 if any { $_ eq '--debug' } @ARGV; | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 145 | 5 | return 0; | |||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||
| 148 | 7 | ▶ | sub debug { | ||||||||||||||||||||||||||||
|
Subroutine
debug: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 149 | 7 | return $debug_mode; | |||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||
| 152 | 11 | ▶ | sub set_debug { | ||||||||||||||||||||||||||||
|
Subroutine
set_debug: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 153 | # turn on debugging when called whitout argument | ||||||||||||||||||||||||||||||
| 154 | 11 | ▶ | return set_debug(1) if (@_ == 0); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||
| 156 | 9 | $debug_mode = shift; | |||||||||||||||||||||||||||||
| 157 | 9 | ▶ | if ($debug_mode) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 158 | 4 | $ENV{'RUN_ENV_debug'} = $debug_mode; | |||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||
| 160 | else { | ||||||||||||||||||||||||||||||
| 161 | 5 | clear_debug(); | |||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||
| 165 | 5 | ▶ | sub clear_debug { | ||||||||||||||||||||||||||||
|
Subroutine
clear_debug: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 166 | 5 | $debug_mode = 0; | |||||||||||||||||||||||||||||
| 167 | 5 | delete $ENV{'RUN_ENV_debug'}; | |||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||
| 169 | 7 | }; | |||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||
| 172 | do { | ||||||||||||||||||||||||||||||
| 173 | 7 | our $execution_mode = set_execution(detect_execution()); | |||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||
| 175 | 9 | ▶ | sub detect_execution { | ||||||||||||||||||||||||||||
|
Subroutine
detect_execution: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 176 | return 'mod_perl' | ||||||||||||||||||||||||||||||
| 177 | 9 | ▶ | if exists $ENV{'MOD_PERL'}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 178 | return 'cgi' | ||||||||||||||||||||||||||||||
| 179 | 8 | ▶ | if exists $ENV{'REQUEST_METHOD'}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 180 | 7 | return 'shell'; | |||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||
| 183 | 1 | ▶ | sub _decide_execution { | ||||||||||||||||||||||||||||
|
Subroutine
_decide_execution: called CC=2 SCAR=9.2
| |||||||||||||||||||||||||||||||
| 184 | 1 | ▶ | return 1 if $execution_mode eq shift; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 185 | 0 | return 0; | |||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||
| 188 | 4 | ▶ | sub execution { | ||||||||||||||||||||||||||||
|
Subroutine
execution: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 189 | 4 | return $execution_mode; | |||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | sub cgi { | ||||||||||||||||||||||||||||
|
Subroutine
cgi: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 193 | 0 | return _decide_execution('cgi'); | |||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | sub mod_perl { | ||||||||||||||||||||||||||||
|
Subroutine
mod_perl: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 197 | 0 | return _decide_execution('mod_perl'); | |||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||
| 200 | 1 | ▶ | sub shell { | ||||||||||||||||||||||||||||
|
Subroutine
shell: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 201 | 1 | return _decide_execution('shell'); | |||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||
| 204 | 7 | ▶ | sub set_execution { | ||||||||||||||||||||||||||||
|
Subroutine
set_execution: called CC=4 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 205 | 7 | my $set_execution = shift; | |||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||
| 207 | 7 | ▶ | if ($set_execution eq 'cgi') { | ||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||
| 208 | 0 | set_cgi(); | |||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||
| 210 | elsif ($set_execution eq 'mod_perl') { | ||||||||||||||||||||||||||||||
| 211 | 0 | set_mod_perl(); | |||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||
| 213 | elsif ($set_execution eq 'shell') { | ||||||||||||||||||||||||||||||
| 214 | 7 | set_shell(); | |||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||
| 216 | else { | ||||||||||||||||||||||||||||||
| 217 | 0 | Carp::Clan::croak 'no such execution mode: '.$set_execution; | |||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | sub set_cgi { | ||||||||||||||||||||||||||||
|
Subroutine
set_cgi: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 222 | 0 | _set_execution('cgi'); | |||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | sub set_mod_perl { | ||||||||||||||||||||||||||||
|
Subroutine
set_mod_perl: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 226 | 0 | _set_execution('mod_perl'); | |||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||
| 229 | 7 | ▶ | sub set_shell { | ||||||||||||||||||||||||||||
|
Subroutine
set_shell: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 230 | 7 | _set_execution('shell'); | |||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||
| 233 | 7 | ▶ | sub _set_execution { | ||||||||||||||||||||||||||||
|
Subroutine
_set_execution: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 234 | 7 | my $set_execution = shift; | |||||||||||||||||||||||||||||
| 235 | 7 | $execution_mode = $set_execution; | |||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||
| 238 | 7 | }; | |||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||
| 240 | do { | ||||||||||||||||||||||||||||||
| 241 | 7 | our $testing = set_testing(detect_testing()); | |||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||
| 243 | 9 | ▶ | sub detect_testing { | ||||||||||||||||||||||||||||
|
Subroutine
detect_testing: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 244 | return 1 | ||||||||||||||||||||||||||||||
| 245 | 9 | ▶ | if $ENV{'RUN_ENV_testing'}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||
| 247 | # testing if current folder is 't' | ||||||||||||||||||||||||||||||
| 248 | 9 | ▶ | my @bin = eval { FindBin::Real::Bin() } || File::Spec->rootdir(); | ||||||||||||||||||||||||||||
|
Condition66%2/3
eval {
do {
FindBin::Real::Bin()
}
} || 'File::Spec'->rootdir
MC/DC0%0/2
eval {
do {
FindBin::Real::Bin()
}
} || 'File::Spec'->rootdir
eval {
do {
FindBin::Real::Bin()
}
}
'File::Spec'->rootdir
Truth table66%2/3
A || B
A= eval {
do {
FindBin::Real::Bin()
}
}B= 'File::Spec'->rootdir
| |||||||||||||||||||||||||||||||
| 249 | 9 | my @current_path = File::Spec->splitdir(@bin); | |||||||||||||||||||||||||||||
| 250 | 9 | ▶ | return 1 | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 251 | if (pop @current_path eq 't'); | ||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||
| 253 | 5 | return 0; | |||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||
| 256 | 7 | ▶ | sub testing { | ||||||||||||||||||||||||||||
|
Subroutine
testing: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 257 | 7 | return $testing; | |||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||
| 260 | 7 | ▶ | sub set_testing { | ||||||||||||||||||||||||||||
|
Subroutine
set_testing: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 261 | # turn on testing when called whitout argument | ||||||||||||||||||||||||||||||
| 262 | 7 | ▶ | return set_testing(1) if (@_ == 0); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||
| 264 | 7 | $testing = shift; | |||||||||||||||||||||||||||||
| 265 | 7 | ▶ | if ($testing) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 266 | 3 | $ENV{'RUN_ENV_testing'} = $testing; | |||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||
| 268 | else { | ||||||||||||||||||||||||||||||
| 269 | 4 | clear_testing(); | |||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||
| 273 | 5 | ▶ | sub clear_testing { | ||||||||||||||||||||||||||||
|
Subroutine
clear_testing: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 274 | 5 | $testing = 0; | |||||||||||||||||||||||||||||
| 275 | 5 | delete $ENV{'RUN_ENV_testing'}; | |||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||
| 277 | 7 | }; | |||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||
| 280 | 7 | qq/ I wonder what is Domm actually listenning to at the moment ;) /; | |||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||
| 283 | __END__ | ||||||||||||||||||||||||||||||