lib/Rex/Interface/Cache/Base.pm

filter: Statementstmt 72.9% 27 / 37 Branchbran 75.0% 3 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 9 / 12 Podpod 0.0% 0 / 8 totaltotal 60.6% 40 / 66 CC 4 SCAR 5.5
CC
4
Cov
70%
gen_key_name
3.0
new
2.1
set
2.0
CRAP 1.7
« blib/lib/Rex/Interface/Cache.pm ↑ Summary lib/Rex/Transaction.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Interface::Cache::Base;
6  
7 70 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 70 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 70 our $VERSION = '1.16.1'; # VERSION
11  
12 70 ▶use Rex::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 70 ▶use Rex;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 115 ▶sub new {
Subroutine new: called CC=2 SCAR=7.2
Pod undocumented
16 115 my $that = shift;
17 115 ▶ my $proto = ref($that) || $that;
Condition33%1/3
ref $that || $that
l!l&&r!l&&!r
01150
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table33%1/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
18 115 my $self = {@_};
19  
20 115 bless( $self, $proto );
21  
22 115 return $self;
23 }
24  
25 660 ▶sub gen_key_name {
Subroutine gen_key_name: called CC=2 SCAR=10.9
Pod undocumented
26 660 my ( $self, $key_name ) = @_;
27 660 ▶ return $key_name if $key_name;
Branch: 1 branch
BranchTrueFalseTotal
if $key_name 660 0 660
28  
29 0 my ( $package, $filename, $line, $subroutine ) = caller(1);
30  
31 0 $package =~ s/::/_/g;
32  
33 0 my $gen_key_name = "\L${package}_\L${subroutine}";
34  
35 0 return $gen_key_name;
36 }
37  
38 1296 ▶sub set {
Subroutine set: called CC=2 SCAR=6.9
Pod undocumented
39 1296 my ( $self, $key, $val, $timeout ) = @_;
40  
41 1296 ▶ if ( Rex::Config->get_use_cache ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("Rex::Config"->get_use_cache) 6 1290 1296
42 6 $self->{__data__}->{$key} = $val;
43 }
44 }
45  
46 1028 ▶sub valid {
Subroutine valid: called CC=1 SCAR=0.0
Pod undocumented
47 1028 my ( $self, $key ) = @_;
48 1028 return exists $self->{__data__}->{$key};
49 }
50  
51 1003 ▶sub get {
Subroutine get: called CC=1 SCAR=0.0
Pod undocumented
52 1003 my ( $self, $key ) = @_;
53 1003 return $self->{__data__}->{$key};
54 }
55  
56 0 ▶sub reset {
Subroutine reset: not called CC=1 SCAR=6.9
Pod undocumented
57 0 my ($self) = @_;
58 0 $self->{__data__} = {};
59 }
60  
61 # have to be overwritten by subclass
62 0 ▶sub save {
Subroutine save: not called CC=1 SCAR=6.9
Pod undocumented
63 0 my ($self) = @_;
64 0 return 1;
65 }
66  
67 # have to be overwritten by subclass
68 0 ▶sub load {
Subroutine load: not called CC=1 SCAR=6.9
Pod undocumented
69 0 my ($self) = @_;
70 0 return 0;
71 }
72  
73 70 1;
« blib/lib/Rex/Interface/Cache.pm ↑ Summary lib/Rex/Transaction.pm »