blib/lib/Lemonldap/NG/Portal/Lib/LazyLoadedConfiguration.pm

filter: Statementstmt 86.6% 26 / 30 Branchbran 62.5% 5 / 8 Conditioncond 50.0% 3 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 75.4% 40 / 53 CC 7 SCAR 17.4
CC
7
Cov
77%
lazy_load_config
8.4
BEGIN
1.0
__ANON__
1.0
CRAP 5.7
« blib/lib/Lemonldap/NG/Portal/Plugins/AutoSignin.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Main/Auth.pm »
1 package Lemonldap::NG::Portal::Lib::LazyLoadedConfiguration;
2 24 ▶use Mouse::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 24 requires qw(load_config);
5  
6 31 ▶has config_expires_at => ( is => 'rw', default => sub { {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
7 31 ▶has config_is_loaded => ( is => 'rw', default => sub { {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
8 31 ▶has config_info => ( is => 'rw', default => sub { {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
9  
10 sub lazy_load_config {
11 40 ▶ my ( $self, $config_name ) = @_;
Subroutine lazy_load_config: called CC=7 SCAR=21.2
Pod undocumented
12  
13 40 my $expires_at = $self->config_expires_at->{$config_name};
14 40 my $is_loaded = $self->config_is_loaded->{$config_name};
15 40 ▶ if ( $is_loaded and ( not defined $expires_at or time < $expires_at ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_loaded and !defined($expires_at) || &CORE::GLOBAL::time() < $expires_at) { } 7 33 40
Condition50%3/6
$is_loaded and !defined($expires_at) || &CORE::GLOBAL::time() < $expires_at
!ll&&!rl&&r
3307
not defined $expires_at or &CORE::GLOBAL::time() < $expires_at
l!l&&r!l&&!r
700
MC/DC33%1/3
$is_loaded and !defined($expires_at) || &CORE::GLOBAL::time() < $expires_at
$is_loaded not defined $expires_at &CORE::GLOBAL::time() < $expires_at
Truth table50%2/4
A and not(B) or C
A= $is_loadedB= not defined $expires_atC= &CORE::GLOBAL::time() < $expires_at
ABCresult
0XX0
1000
11X1
1011
16  
17 # Already loaded, nothing to do
18 7 $self->logger->debug("Config for $config_name is already loaded");
19 7 return $self->config_info->{$config_name};
20 }
21 else {
22 33 $self->logger->debug("Reloading config for $config_name");
23 33 my $config_result = $self->load_config($config_name);
24 33 ▶ if ($config_result) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config_result) 33 0 33
25 33 $self->config_is_loaded->{$config_name} = 1;
26 33 my $ttl = $config_result->{ttl};
27 33 ▶ if ( defined $ttl ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ttl) 0 33 33
28 0 my $will_expire_at = time + $ttl;
29 0 $self->config_expires_at->{$config_name} = $will_expire_at;
30 0 $self->logger->debug(
31 "Config for $config_name will be valid until $will_expire_at"
32 );
33 }
34 33 my $info = $config_result->{info};
35 33 ▶ $self->config_info->{$config_name} = $info if $info;
Branch: 1 branch
BranchTrueFalseTotal
if $info 33 0 33
36 33 return $info;
37 }
38 0 return;
39 }
40 }
41 24 1;
« blib/lib/Lemonldap/NG/Portal/Plugins/AutoSignin.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Main/Auth.pm »