blib/lib/App/Netdisco/Environment.pm untested

filter: Statementstmt 0.0% 0 / 43 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 39 MC/DCmcdc 0.0% 0 / 24 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 120 CC 3 SCAR 15.5
CC
3
Cov
0%
BEGIN
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 4.7
1 package App::Netdisco::Environment;
2  
3 use strict;
4 use warnings;
5  
6 use File::ShareDir 'dist_dir';
7 use Path::Class;
8 use FindBin;
9  
10 BEGIN {
11 if (not ($ENV{DANCER_APPDIR} || '')
12 or not -f file($ENV{DANCER_APPDIR}, 'config.yml')) {
13  
14 FindBin::again();
15 my $me = File::Spec->catfile($FindBin::RealBin, $FindBin::RealScript);
16 my $uid = (stat($me))[4] || 0;
17 my $home = ($ENV{NETDISCO_HOME} || (getpwuid($uid))[7] || $ENV{HOME});
18 $ENV{NETDISCO_HOME} ||= $home;
19  
20 $ENV{NETDISCO_DO} ||= File::Spec->catfile($FindBin::RealBin, 'netdisco-do');
21  
22 my $auto = dir(dist_dir('App-Netdisco'))->absolute;
23  
24 $ENV{DANCER_APPDIR} ||= $auto->stringify;
25 $ENV{DANCER_CONFDIR} ||= $auto->stringify;
26  
27 my $test_envdir = dir($home, 'environments')->stringify;
28 $ENV{DANCER_ENVDIR} ||= (-d $test_envdir
29 ? $test_envdir : $auto->subdir('environments')->stringify);
30  
31 $ENV{DANCER_ENVIRONMENT} ||= 'deployment';
32 $ENV{PLACK_ENV} ||= $ENV{DANCER_ENVIRONMENT};
33  
34 $ENV{DANCER_PUBLIC} ||= $auto->subdir('public')->stringify;
35 $ENV{DANCER_VIEWS} ||= $auto->subdir('views')->stringify;
36 }
37  
38 {
39 # Dancer 1 uses the broken YAML.pm module
40 # This is a global sledgehammer - could just apply to Dancer::Config
41 use YAML;
42 use YAML::XS;
43 no warnings 'redefine';
44 *YAML::LoadFile = sub { goto \&YAML::XS::LoadFile };
45 }
46 }
47  
48 1;