blib/lib/Cache/FastMmap/Tie.pm

filter: Statementstmt 95.6% 44 / 46 Branchbran 60.0% 6 / 10 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 84.6% 11 / 13 Podpod n/a totaltotal 85.1% 63 / 74 CC 8 SCAR 10.9
CC
8
Cov
88%
TIEHASH
6.2
EXISTS
3.0
DELETE
2.0
CRAP 3.0
↑ Summary
1 package Cache::FastMmap::Tie;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use v5.8.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 our $VERSION = '0.03';
6  
7 5 ▶use base 'Cache::FastMmap';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use Class::Inspector;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use Best [ [ qw/YAML::XS YAML::Syck YAML/ ], qw/LoadFile/ ];
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 ▶sub TIEHASH{
Subroutine TIEHASH: called CC=6 SCAR=18.2
12 4 my $class = shift;
13 4 my ($params_hash) = @_;
14 4 my $self;
15 4 ▶ if (ref $params_hash eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $params_hash eq "HASH") 1 3 4
16 1 $params_hash = shift @_;
17 1 ▶ if (my $yaml_file = delete $params_hash->{yaml_file}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $yaml_file = delete $params_hash->{"yaml_file"}) 1 0 1
18 1 ▶ $params_hash = LoadFile("$yaml_file") or
Branch: 1 branch
BranchTrueFalseTotal
$params_hash = LoadFile("$yaml_file") or die "Can't open `${yaml_file}':$@ ", __LINE__ 1 0 1
19 die "Can't open `$yaml_file':$@ ",__LINE__;
20 }
21 1 ▶ $self = $class->new(%{$params_hash}) unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 1 0 1
22 }
23 4 ▶ $self ||= $class->new(@_);
Condition66%2/3
$self ||= $class->new(@_)
l!l&&r!l&&!r
130
MC/DC0%0/2
$self ||= $class->new(@_)
$self $class->new(@_)
Truth table66%2/3
A ||= B
A= $selfB= $class->new(@_)
ABresult
1X1
011
000
24 4 $self->{_tie_var} = {};
25 4 return $self;
26 }
27  
28 8 ▶sub STORE { shift->set(@_) } # ( Key => Value )
Subroutine STORE: called CC=1 SCAR=0.0
29  
30 14 ▶sub FETCH { shift->get(@_) } # ( Key )
Subroutine FETCH: called CC=1 SCAR=0.0
31  
32 0 ▶sub DELETE{ shift->remove(@_) } # ( Key )
Subroutine DELETE: not called CC=1 SCAR=6.9
33  
34 0 ▶sub CLEAR { shift->clear }
Subroutine CLEAR: not called CC=1 SCAR=6.9
35  
36 9 ▶sub EXISTS { # ( Key )
Subroutine EXISTS: called CC=3 SCAR=11.1
37 9 my $self = shift;
38 9 $self->purge;
39 9 for ($self->get_keys(0)){
40 5 ▶ $_ eq $_[0] and return 1;
Branch: 1 branch
BranchTrueFalseTotal
$_ eq $_[0] and return 1 5 0 5
41 }
42 4 return ;
43 }
44  
45 12 ▶sub FIRSTKEY {
Subroutine FIRSTKEY: called CC=1 SCAR=0.0
46 12 my $self = shift;
47 12 $self->purge;
48 12 @{$self->{_tie_var}->{get_keys_0}} = $self->get_keys(0);
49 12 shift @{$self->{_tie_var}->{get_keys_0}};
50 }
51  
52 16 ▶sub NEXTKEY { # ( prevKey )
Subroutine NEXTKEY: called CC=1 SCAR=0.0
53 16 my $self = shift;
54 16 shift @{$self->{_tie_var}->{get_keys_0}};
55 }
56  
57 #sub DESTROY {}
58  
59 5 1;
60 __END__
↑ Summary