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

filter: Statementstmt 86.6% 26 / 30 Branchbran 75.0% 6 / 8 Conditioncond 50.0% 3 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 77.3% 41 / 53 CC 7 SCAR 17.0
CC
7
Cov
80%
lazy_load_config
8.0
BEGIN
1.0
__ANON__
1.0
CRAP 5.5
« blib/lib/Lemonldap/NG/Portal/Password/Combination.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Auth/Choice.pm »
1 package Lemonldap::NG::Portal::Lib::LazyLoadedConfiguration;
2 29 ▶use Mouse::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 29 requires qw(load_config);
5  
6 60 ▶has config_expires_at => ( is => 'rw', default => sub { {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
7 60 ▶has config_is_loaded => ( is => 'rw', default => sub { {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
8 60 ▶has config_info => ( is => 'rw', default => sub { {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
9  
10 119 ▶sub lazy_load_config {
Subroutine lazy_load_config: called CC=7 SCAR=20.8
Pod undocumented
11 119 my ( $self, $config_name ) = @_;
12  
13 119 my $expires_at = $self->config_expires_at->{$config_name};
14 119 my $is_loaded = $self->config_is_loaded->{$config_name};
15 119 ▶ 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) { } 54 65 119
Condition50%3/6
$is_loaded and !defined($expires_at) || &CORE::GLOBAL::time() < $expires_at
!ll&&!rl&&r
65054
not defined $expires_at or &CORE::GLOBAL::time() < $expires_at
l!l&&r!l&&!r
5400
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 54 $self->logger->debug("Config for $config_name is already loaded");
19 54 return $self->config_info->{$config_name};
20 }
21 else {
22 65 $self->logger->debug("Reloading config for $config_name");
23 65 my $config_result = $self->load_config($config_name);
24 65 ▶ if ($config_result) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config_result) 65 0 65
25 65 $self->config_is_loaded->{$config_name} = 1;
26 65 my $ttl = $config_result->{ttl};
27 65 ▶ if ( defined $ttl ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ttl) 0 65 65
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 65 my $info = $config_result->{info};
35 65 ▶ $self->config_info->{$config_name} = $info if $info;
Branch: 1 branch
BranchTrueFalseTotal
if $info 64 1 65
36 65 return $info;
37 }
38 0 return;
39 }
40 }
41 29 1;
« blib/lib/Lemonldap/NG/Portal/Password/Combination.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Auth/Choice.pm »