blib/lib/Dancer/Config.pm

filter: Statementstmt 95.9% 164 / 171 Branchbran 81.2% 39 / 48 Conditioncond 44.1% 38 / 86 MC/DCmcdc 2.5% 1 / 40 Subroutinesub 94.8% 37 / 39 Podpod 0.0% 0 / 11 totaltotal 70.6% 279 / 395 SCAR 45.4
CC
60
Cov
79%
load_default_settings
114.7
load
8.0
__ANON__
6.0
CRAP 93.3
« blib/lib/Dancer/Request.pm ↑ Summary blib/lib/Dancer.pm »
1 package Dancer::Config;
2 233 our $AUTHORITY = 'cpan:SUKRIA';
3 #ABSTRACT: how to configure Dancer to suit your needs
4 233 $Dancer::Config::VERSION = '1.3520';
5 233 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 233 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 233 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 233 ▶use vars '@EXPORT_OK';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 233 ▶use Hash::Merge::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 233 ▶use Dancer::Config::Object 'hashref_to_object';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 233 ▶use Dancer::Deprecation;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 233 ▶use Dancer::Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 233 ▶use Dancer::ModuleLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 233 ▶use Dancer::FileUtils 'path';
Subroutine BEGIN: called CC=1 SCAR=0.0
16 233 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 233 ▶use Dancer::Exception qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 233 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 233 @EXPORT_OK = qw(setting);
22  
23 233 my $SETTINGS = {};
24  
25 # mergeable settings
26 233 my %MERGEABLE = map { ($_ => 1) } qw( plugins handlers );
27 233 my %_LOADED;
28  
29 637 ▶sub settings {$SETTINGS}
Subroutine settings: called CC=1 SCAR=0.0
Pod undocumented
30  
31 my $setters = {
32 logger => sub {
33 103 ▶ my ($setting, $value) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
34 103 require Dancer::Logger;
35 103 Dancer::Logger->init($value, settings());
36 },
37 log_file => sub {
38 2 ▶ require Dancer::Logger;
Subroutine __ANON__: called CC=1 SCAR=0.0
39 2 Dancer::Logger->init(setting("logger"), settings());
40 },
41 session => sub {
42 96 ▶ my ($setting, $value) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
43 96 require Dancer::Session;
44 96 Dancer::Session->init($value, settings());
45 },
46 template => sub {
47 245 ▶ my ($setting, $value) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
48 245 require Dancer::Template;
49 245 Dancer::Template->init($value, settings());
50 },
51 route_cache => sub {
52 2 ▶ my ($setting, $value) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
53 2 require Dancer::Route::Cache;
54 2 Dancer::Route::Cache->reset();
55 },
56 serializer => sub {
57 21 ▶ my ($setting, $value) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
58 21 require Dancer::Serializer;
59 21 Dancer::Serializer->init($value);
60 },
61 # This setting has been deprecated in favor of global_warnings.
62 import_warnings => sub {
63 0 ▶ my ($setting, $value) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
64  
65 0 Dancer::Deprecation->deprecated(
66 message => "import_warnings has been deprecated, please use global_warnings instead."
67 );
68  
69 0 ▶ $^W = $value ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 0 0 0
70 },
71 global_warnings => sub {
72 3 ▶ my ($setting, $value) = @_;
Subroutine __ANON__: called CC=2 SCAR=6.9
73 3 ▶ $^W = $value ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 2 1 3
74 },
75 traces => sub {
76 10 ▶ my ($setting, $traces) = @_;
Subroutine __ANON__: called CC=2 SCAR=6.9
77 10 ▶ $Dancer::Exception::Verbose = $traces ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$traces ? : 1 9 10
78 },
79 233 };
80 233 $setters->{log_path} = $setters->{log_file};
81  
82 my $normalizers = {
83 charset => sub {
84 6 ▶ my ($setting, $charset) = @_;
Subroutine __ANON__: called CC=5 SCAR=16.5
85 6 ▶ length($charset || '')
Branch: 1 branch
BranchTrueFalseTotal
length($charset || "") or return $charset 0 6 6
Condition50%1/2
$charset || ''
l!l
60
MC/DC0%0/1
$charset || ''
$charset
Truth table50%1/2
A
A= $charset
Aresult
11
00
86 or return $charset;
87 6 my $encoding = Encode::find_encoding($charset);
88 6 ▶ defined $encoding
Branch: 1 branch
BranchTrueFalseTotal
defined $encoding or &raise("core_config", "Charset defined in configuration is wrong : couldn't identify '${charset}'") 0 6 6
89 or raise core_config => "Charset defined in configuration is wrong : couldn't identify '$charset'";
90 6 my $name = $encoding->name;
91 # Perl makes a distinction between the usual perl utf8, and the strict
92 # utf8 charset. But we don't want to make this distinction
93 6 ▶ $name eq 'utf-8-strict'
Branch: 1 branch
BranchTrueFalseTotal
$name eq "utf-8-strict" and $name = "utf-8" 3 3 6
94 and $name = 'utf-8';
95 6 return $name;
96 },
97 session_same_site => sub {
98 0 ▶ my ($setting, $same_site_setting) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
99 0 ▶ if ($same_site_setting =~ m{^(strict|lax|none)$}i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($same_site_setting =~ /^(strict|lax|none)$/i) { } 0 0 0
100 0 return ucfirst lc $same_site_setting;
101 } else {
102 0 raise core_config => "Invalid session_same_site value $same_site_setting";
103 }
104 },
105 233 };
106  
107 sub normalize_setting {
108 1998 ▶ my ($class, $setting, $value) = @_;
Subroutine normalize_setting: called CC=2 SCAR=6.9
Pod undocumented
109  
110 $value = $normalizers->{$setting}->($setting, $value)
111 1998 ▶ if exists $normalizers->{$setting};
Branch: 1 branch
BranchTrueFalseTotal
if exists $normalizers->{$setting} 6 1992 1998
112  
113 1998 return $value;
114 }
115  
116 # public accessor for get/set
117 sub setting {
118 14068 ▶ if (@_ == 1) {
Subroutine setting: called CC=4 SCAR=13.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 12158 1910 14068
119 12158 return _get_setting(shift @_);
120 }
121 else {
122 # can be useful for debug! Use Logger, instead?
123 1910 ▶ die "Odd number in 'set' assignment" unless scalar @_ % 2 == 0;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @_ % 2 == 0 0 1910 1910
124  
125 1910 my $count = 0;
126 1910 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1928 1905 3833
127 1928 my $setting = shift;
128 1928 my $value = shift;
129  
130 1928 _set_setting ($setting, $value);
131  
132 # At the moment, with any kind of hierarchical setter,
133 # there is no case where the same trigger will be run more
134 # than once. If/when a hierarchical setter is implemented,
135 # we should create a list of the hooks that should be run,
136 # and run them at the end of this while, only (efficiency
137 # purposes).
138 1928 _trigger_hooks($setting, $value);
139 1923 $count++
140 }
141 1905 return $count; # just to return anything, the number of items set.
142 }
143 }
144  
145 sub _trigger_hooks {
146 1930 ▶ my ($setting, $value) = @_;
Subroutine _trigger_hooks: called CC=2 SCAR=6.9
147  
148 1930 ▶ $setters->{$setting}->(@_) if defined $setters->{$setting};
Branch: 1 branch
BranchTrueFalseTotal
if defined $setters->{$setting} 454 1476 1930
149 }
150  
151 sub _set_setting {
152 1929 ▶ my ($setting, $value) = @_;
Subroutine _set_setting: called CC=2 SCAR=7.0
153  
154 1929 ▶ return unless @_ == 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 1929 1929
155  
156 # normalize the value if needed
157 1929 $value = Dancer::Config->normalize_setting($setting, $value);
158 1929 $SETTINGS->{$setting} = $value;
159 1929 return $value;
160 }
161  
162 sub _get_setting {
163 12159 ▶ my $setting = shift;
Subroutine _get_setting: called CC=1 SCAR=0.0
164  
165 12159 return $SETTINGS->{$setting};
166 }
167  
168 225 ▶sub conffile { path(setting('confdir') || setting('appdir'), 'config.yml') }
Subroutine conffile: called CC=2 SCAR=7.2
Pod undocumented
Condition66%2/3
setting('confdir') || setting('appdir')
l!l&&r!l&&!r
22230
MC/DC0%0/2
setting('confdir') || setting('appdir')
setting('confdir') setting('appdir')
Truth table66%2/3
A || B
A= setting('confdir')B= setting('appdir')
ABresult
1X1
011
000
169  
170 sub environment_file {
171 17 ▶ my $env = setting('environment');
Subroutine environment_file: called CC=2 SCAR=7.0
Pod undocumented
172 # XXX for compatibility reason, we duplicate the code from `init_envdir` here
173 # we don't know how if some application don't already do some weird stuff like
174 # the test in `t/15_plugins/02_config.t`.
175 17 ▶ my $envdir = setting('envdir') || path(setting('appdir'), 'environments');
Condition66%2/3
setting('envdir') || path(setting('appdir'), 'environments')
l!l&&r!l&&!r
1610
MC/DC0%0/2
setting('envdir') || path(setting('appdir'), 'environments')
setting('envdir') path(setting('appdir'), 'environments')
Truth table66%2/3
A || B
A= setting('envdir')B= path(setting('appdir'), 'environments')
ABresult
1X1
011
000
176 17 return path($envdir, "$env.yml");
177 }
178  
179 sub init_confdir {
180 201 ▶ return setting('confdir') if setting('confdir');
Subroutine init_confdir: called CC=3 SCAR=11.1
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if setting("confdir") 197 4 201
181 4 ▶ setting confdir => $ENV{DANCER_CONFDIR} || setting('appdir');
Condition66%2/3
$ENV{'DANCER_CONFDIR'} || setting('appdir')
l!l&&r!l&&!r
031
MC/DC50%1/2
$ENV{'DANCER_CONFDIR'} || setting('appdir')
$ENV{'DANCER_CONFDIR'} setting('appdir')
Truth table66%2/3
A || B
A= $ENV{'DANCER_CONFDIR'}B= setting('appdir')
ABresult
1X1
011
000
182 }
183  
184 sub init_envdir {
185 201 ▶ return setting('envdir') if setting('envdir');
Subroutine init_envdir: called CC=4 SCAR=14.2
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if setting("envdir") 72 129 201
186 129 ▶ my $appdirpath = defined setting('appdir') ?
Branch: 1 branch
BranchTrueFalseTotal
defined setting('appdir') ? : 128 1 129
187 path( setting('appdir'), 'environments' ) :
188 path('environments');
189  
190 129 ▶ setting envdir => $ENV{DANCER_ENVDIR} || $appdirpath;
Condition33%1/3
$ENV{'DANCER_ENVDIR'} || $appdirpath
l!l&&r!l&&!r
01290
MC/DC0%0/2
$ENV{'DANCER_ENVDIR'} || $appdirpath
$ENV{'DANCER_ENVDIR'} $appdirpath
Truth table33%1/3
A || B
A= $ENV{'DANCER_ENVDIR'}B= $appdirpath
ABresult
1X1
011
000
191 }
192  
193 sub load {
194 201 ▶ init_confdir();
Subroutine load: called CC=8 SCAR=20.8
Pod undocumented
195 201 init_envdir();
196  
197 # look for the conffile
198 201 ▶ return 1 unless -f conffile;
Branch: 1 branch
BranchTrueFalseTotal
unless -f conffile() 190 11 201
199  
200 # load YAML
201 11 my $module = load_yaml_module();
202  
203 10 ▶ unless ($_LOADED{conffile()}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_LOADED{conffile()}) 5 5 10
204 5 load_settings_from_yaml(conffile, $module);
205 5 $_LOADED{conffile()}++;
206 }
207  
208 10 my $env = environment_file;
209  
210 # don't load the same env twice
211 10 ▶ unless( $_LOADED{$env} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_LOADED{$env}) 10 0 10
212 10 ▶ if (-f $env ) {
Branch: 2 branches
BranchTrueFalseTotal
if (-f $env) { } 4 6 10
elsif (setting('require_environment')) { } 1 5 6
213 4 load_settings_from_yaml($env, $module);
214 4 $_LOADED{$env}++;
215 }
216 elsif (setting('require_environment')) {
217 # failed to load the env file, and the main config said we needed it.
218 1 confess "Could not load environment file '$env', and require_environment is set";
219 }
220 }
221  
222 9 foreach my $key (grep { $setters->{$_} } keys %$SETTINGS) {
223 28 $setters->{$key}->($key, $SETTINGS->{$key});
224 }
225 9 ▶ if ( $SETTINGS->{strict_config} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($SETTINGS->{"strict_config"}) 2 7 9
226 2 $SETTINGS = hashref_to_object($SETTINGS);
227 }
228  
229 9 return 1;
230 }
231  
232 sub load_settings_from_yaml {
233 14 ▶ my ($file, $module) = @_;
Subroutine load_settings_from_yaml: called CC=3 SCAR=11.0
Pod undocumented
234  
235 14 ▶ $module ||= load_yaml_module();
Condition66%2/3
$module ||= load_yaml_module()
l!l&&r!l&&!r
1310
MC/DC0%0/2
$module ||= load_yaml_module()
$module load_yaml_module()
Truth table66%2/3
A ||= B
A= $moduleB= load_yaml_module()
ABresult
1X1
011
000
236  
237 14 my $config;
238 {
239 233 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
240 14 ▶ $config = eval { &{ $module . '::LoadFile' }($file) }
Branch: 1 branch
BranchTrueFalseTotal
$config = eval { do { &{$module . '::LoadFile';}($file) } } or confess("Unable to parse the configuration file: ${file}: $@") 5 9 14
241 or confess "Unable to parse the configuration file: $file: $@";
242 }
243  
244 $SETTINGS = Hash::Merge::Simple::merge( $SETTINGS, {
245 map {
246 9 $_ => Dancer::Config->normalize_setting( $_, $config->{$_} )
247 } keys %$config
248 } );
249  
250 9 return scalar keys %$config;
251 }
252  
253 sub load_yaml_module {
254 12 ▶ my ($module) = @_;
Subroutine load_yaml_module: called CC=4 SCAR=14.0
Pod undocumented
255  
256 12 ▶ $module ||= $SETTINGS->{engines}{YAML}{module} || 'YAML';
Condition60%3/5
$module ||= $SETTINGS->{"engines"}{"YAML"}{"module"} || "YAML"
l!l&&r!l&&!r
0120
$SETTINGS->{'engines'}{'YAML'}{'module'} || 'YAML'
l!l
93
MC/DC0%0/2
$module ||= $SETTINGS->{"engines"}{"YAML"}{"module"} || "YAML"
$module $SETTINGS->{'engines'}{'YAML'}{'module'}
Truth table33%1/3
A ||= B
A= $moduleB= $SETTINGS->{'engines'}{'YAML'}{'module'}
ABresult
1X1
011
000
257  
258 12 my ( $result, $error ) = Dancer::ModuleLoader->load($module);
259 12 ▶ confess "Could not load $module: $error"
Branch: 1 branch
BranchTrueFalseTotal
unless $result 1 11 12
260 unless $result;
261  
262 11 return $module;
263 }
264  
265 sub load_default_settings {
266 233 ▶ $SETTINGS->{server} ||= $ENV{DANCER_SERVER} || '0.0.0.0';
Subroutine load_default_settings: called CC=27 SCAR=47.4
Pod undocumented
Condition40%2/5
$SETTINGS->{"server"} ||= $ENV{"DANCER_SERVER"} || "0.0.0.0"
l!l&&r!l&&!r
02330
$ENV{'DANCER_SERVER'} || '0.0.0.0'
l!l
0233
MC/DC0%0/2
$SETTINGS->{"server"} ||= $ENV{"DANCER_SERVER"} || "0.0.0.0"
$SETTINGS->{"server"} $ENV{'DANCER_SERVER'}
Truth table0%0/3
A ||= B
A= $SETTINGS->{"server"}B= $ENV{'DANCER_SERVER'}
ABresult
1X1
011
000
267 233 ▶ $SETTINGS->{port} ||= $ENV{DANCER_PORT} || '3000';
Condition40%2/5
$SETTINGS->{"port"} ||= $ENV{"DANCER_PORT"} || 3000
l!l&&r!l&&!r
02330
$ENV{'DANCER_PORT'} || '3000'
l!l
0233
MC/DC0%0/2
$SETTINGS->{"port"} ||= $ENV{"DANCER_PORT"} || 3000
$SETTINGS->{"port"} $ENV{'DANCER_PORT'}
Truth table0%0/3
A ||= B
A= $SETTINGS->{"port"}B= $ENV{'DANCER_PORT'}
ABresult
1X1
011
000
268 233 ▶ $SETTINGS->{content_type} ||= $ENV{DANCER_CONTENT_TYPE} || 'text/html';
Condition40%2/5
$SETTINGS->{"content_type"} ||= $ENV{"DANCER_CONTENT_TYPE"} || "text/html"
l!l&&r!l&&!r
02330
$ENV{'DANCER_CONTENT_TYPE'} || 'text/html'
l!l
0233
MC/DC0%0/2
$SETTINGS->{"content_type"} ||= $ENV{"DANCER_CONTENT_TYPE"} || "text/html"
$SETTINGS->{"content_type"} $ENV{'DANCER_CONTENT_TYPE'}
Truth table0%0/3
A ||= B
A= $SETTINGS->{"content_type"}B= $ENV{'DANCER_CONTENT_TYPE'}
ABresult
1X1
011
000
269 233 ▶ $SETTINGS->{charset} ||= $ENV{DANCER_CHARSET} || '';
Condition40%2/5
$SETTINGS->{"charset"} ||= $ENV{"DANCER_CHARSET"} || ""
l!l&&r!l&&!r
00233
$ENV{'DANCER_CHARSET'} || ''
l!l
0233
MC/DC0%0/2
$SETTINGS->{"charset"} ||= $ENV{"DANCER_CHARSET"} || ""
$SETTINGS->{"charset"} $ENV{'DANCER_CHARSET'}
Truth table33%1/3
A ||= B
A= $SETTINGS->{"charset"}B= $ENV{'DANCER_CHARSET'}
ABresult
1X1
011
000
270 233 ▶ $SETTINGS->{startup_info} ||= !$ENV{DANCER_NO_STARTUP_INFO};
Condition33%1/3
$SETTINGS->{"startup_info"} ||= !$ENV{"DANCER_NO_STARTUP_INFO"}
l!l&&r!l&&!r
02330
MC/DC0%0/2
$SETTINGS->{"startup_info"} ||= !$ENV{"DANCER_NO_STARTUP_INFO"}
$SETTINGS->{"startup_info"} !$ENV{"DANCER_NO_STARTUP_INFO"}
Truth table33%1/3
A ||= not(B)
A= $SETTINGS->{"startup_info"}B= !$ENV{"DANCER_NO_STARTUP_INFO"}
ABresult
1X1
011
000
271 233 ▶ $SETTINGS->{daemon} ||= $ENV{DANCER_DAEMON} || 0;
Condition40%2/5
$SETTINGS->{"daemon"} ||= $ENV{"DANCER_DAEMON"} || 0
l!l&&r!l&&!r
00233
$ENV{'DANCER_DAEMON'} || 0
l!l
0233
MC/DC0%0/2
$SETTINGS->{"daemon"} ||= $ENV{"DANCER_DAEMON"} || 0
$SETTINGS->{"daemon"} $ENV{'DANCER_DAEMON'}
Truth table33%1/3
A ||= B
A= $SETTINGS->{"daemon"}B= $ENV{'DANCER_DAEMON'}
ABresult
1X1
011
000
272 233 ▶ $SETTINGS->{apphandler} ||= $ENV{DANCER_APPHANDLER} || 'Standalone';
Condition40%2/5
$SETTINGS->{"apphandler"} ||= $ENV{"DANCER_APPHANDLER"} || "Standalone"
l!l&&r!l&&!r
02330
$ENV{'DANCER_APPHANDLER'} || 'Standalone'
l!l
0233
MC/DC0%0/2
$SETTINGS->{"apphandler"} ||= $ENV{"DANCER_APPHANDLER"} || "Standalone"
$SETTINGS->{"apphandler"} $ENV{'DANCER_APPHANDLER'}
Truth table0%0/3
A ||= B
A= $SETTINGS->{"apphandler"}B= $ENV{'DANCER_APPHANDLER'}
ABresult
1X1
011
000
273 233 ▶ $SETTINGS->{warnings} ||= $ENV{DANCER_WARNINGS} || 0;
Condition40%2/5
$SETTINGS->{"warnings"} ||= $ENV{"DANCER_WARNINGS"} || 0
l!l&&r!l&&!r
00233
$ENV{'DANCER_WARNINGS'} || 0
l!l
0233
MC/DC0%0/2
$SETTINGS->{"warnings"} ||= $ENV{"DANCER_WARNINGS"} || 0
$SETTINGS->{"warnings"} $ENV{'DANCER_WARNINGS'}
Truth table33%1/3
A ||= B
A= $SETTINGS->{"warnings"}B= $ENV{'DANCER_WARNINGS'}
ABresult
1X1
011
000
274 233 ▶ $SETTINGS->{auto_reload} ||= $ENV{DANCER_AUTO_RELOAD} || 0;
Condition40%2/5
$SETTINGS->{"auto_reload"} ||= $ENV{"DANCER_AUTO_RELOAD"} || 0
l!l&&r!l&&!r
00233
$ENV{'DANCER_AUTO_RELOAD'} || 0
l!l
0233
MC/DC0%0/2
$SETTINGS->{"auto_reload"} ||= $ENV{"DANCER_AUTO_RELOAD"} || 0
$SETTINGS->{"auto_reload"} $ENV{'DANCER_AUTO_RELOAD'}
Truth table33%1/3
A ||= B
A= $SETTINGS->{"auto_reload"}B= $ENV{'DANCER_AUTO_RELOAD'}
ABresult
1X1
011
000
275 233 ▶ $SETTINGS->{traces} ||= $ENV{DANCER_TRACES} || 0;
Condition40%2/5
$SETTINGS->{"traces"} ||= $ENV{"DANCER_TRACES"} || 0
l!l&&r!l&&!r
00233
$ENV{'DANCER_TRACES'} || 0
l!l
0233
MC/DC0%0/2
$SETTINGS->{"traces"} ||= $ENV{"DANCER_TRACES"} || 0
$SETTINGS->{"traces"} $ENV{'DANCER_TRACES'}
Truth table33%1/3
A ||= B
A= $SETTINGS->{"traces"}B= $ENV{'DANCER_TRACES'}
ABresult
1X1
011
000
276 233 ▶ $SETTINGS->{server_tokens} ||= !$ENV{DANCER_NO_SERVER_TOKENS};
Condition33%1/3
$SETTINGS->{"server_tokens"} ||= !$ENV{"DANCER_NO_SERVER_TOKENS"}
l!l&&r!l&&!r
02330
MC/DC0%0/2
$SETTINGS->{"server_tokens"} ||= !$ENV{"DANCER_NO_SERVER_TOKENS"}
$SETTINGS->{"server_tokens"} !$ENV{"DANCER_NO_SERVER_TOKENS"}
Truth table33%1/3
A ||= not(B)
A= $SETTINGS->{"server_tokens"}B= !$ENV{"DANCER_NO_SERVER_TOKENS"}
ABresult
1X1
011
000
277 233 ▶ $SETTINGS->{logger} ||= $ENV{DANCER_LOGGER} || 'file';
Condition40%2/5
$SETTINGS->{"logger"} ||= $ENV{"DANCER_LOGGER"} || "file"
l!l&&r!l&&!r
02330
$ENV{'DANCER_LOGGER'} || 'file'
l!l
0233
MC/DC0%0/2
$SETTINGS->{"logger"} ||= $ENV{"DANCER_LOGGER"} || "file"
$SETTINGS->{"logger"} $ENV{'DANCER_LOGGER'}
Truth table0%0/3
A ||= B
A= $SETTINGS->{"logger"}B= $ENV{'DANCER_LOGGER'}
ABresult
1X1
011
000
278 $SETTINGS->{environment} ||=
279 $ENV{DANCER_ENVIRONMENT}
280 || $ENV{PLACK_ENV}
281 233 ▶ || 'development';
Condition37%3/8
$SETTINGS->{"environment"} ||= $ENV{"DANCER_ENVIRONMENT"} || $ENV{"PLACK_ENV"} || "development"
l!l&&r!l&&!r
02330
$ENV{'DANCER_ENVIRONMENT'} || $ENV{'PLACK_ENV'} || 'development'
l!l
0233
$ENV{"DANCER_ENVIRONMENT"} or $ENV{"PLACK_ENV"}
l!l&&r!l&&!r
00233
MC/DC0%0/3
$SETTINGS->{"environment"} ||= $ENV{"DANCER_ENVIRONMENT"} || $ENV{"PLACK_ENV"} || "development"
$SETTINGS->{"environment"} $ENV{"DANCER_ENVIRONMENT"} $ENV{"PLACK_ENV"}
Truth table0%0/4
A ||= B or C
A= $SETTINGS->{"environment"}B= $ENV{"DANCER_ENVIRONMENT"}C= $ENV{"PLACK_ENV"}
ABCresult
1XX1
01X1
0011
0000
282  
283 233 setting $_ => {} for keys %MERGEABLE;
284 233 setting template => 'simple';
285 }
286  
287 233 load_default_settings();
288  
289 233 1;
290  
291 __END__
« blib/lib/Dancer/Request.pm ↑ Summary blib/lib/Dancer.pm »