Session/Store/DBM.pm

filter: Statementstmt 87.8% 36 / 41 Branchbran 50.0% 4 / 8 Conditioncond 80.0% 4 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 76.9% 10 / 13 Podpod 71.4% 5 / 7 totaltotal 77.9% 60 / 77 CC 8 SCAR 10.5
CC
8
Cov
81%
new
5.3
dbm
4.2
update
2.0
CRAP 2.9
« Session/Store/CHI.pm ↑ Summary Session/State/Test.pm »
1 package HTTP::Session::Store::DBM;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use base qw/Class::Accessor::Fast/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Fcntl;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Storable;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Module::Runtime ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 __PACKAGE__->mk_ro_accessors(qw/file dbm_class/);
10  
11 4 ▶sub new {
Subroutine new: called CC=5 SCAR=16.7
Pod documented
12 4 my $class = shift;
13 0 ▶ my %args = ref($_[0]) ? %{$_[0]} : @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 4 4
14 # check required parameters
15 4 for (qw/file/) {
16 4 ▶ Carp::croak "missing parameter $_" unless $args{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{$_} 0 4 4
17 }
18 # set default values
19 4 ▶ $args{dbm_class} ||= 'SDBM_File';
Condition100%2/2
$args{"dbm_class"} ||= "SDBM_File"
l!l
22
MC/DC100%1/1
$args{"dbm_class"} ||= "SDBM_File"
$args{"dbm_class"}
Truth table100%2/2
A
A= $args{"dbm_class"}
Aresult
11
00
20 4 bless {%args}, $class;
21 }
22  
23 6 ▶sub dbm {
Subroutine dbm: called CC=4 SCAR=14.3
Pod undocumented
24 6 my $self = shift;
25 6 ▶ $self->{dbm} ||= do {
Condition66%2/3
$self->{"dbm"} ||= do { my %hash; &Module::Runtime::require_module(scalar $self->dbm_class) or die $@; tie %hash, $self->dbm_class, $self->file, 66, 384 or die qq[Cannot open dbm file for session: $self->{"dbm_class"}, $self->{"file"}]; \%hash }
l!l&&r!l&&!r
240
MC/DC0%0/2
$self->{"dbm"} ||= do { my %hash; &Module::Runtime::require_module(scalar $self->dbm_class) or die $@; tie %hash, $self->dbm_class, $self->file, 66, 384 or die qq[Cannot open dbm file for session: $self->{"dbm_class"}, $self->{"file"}]; \%hash }
$self->{"dbm"} do { my %hash; &Module::Runtime::require_module(scalar $self->dbm_class) or die $@; tie %hash, $self->dbm_class, $self->file, 66, 384 or die qq[Cannot open dbm file for session: $self->{"dbm_class"}, $self->{"file"}]; \%hash }
Truth table66%2/3
A ||= B
A= $self->{"dbm"}B= do { my %hash; &Module::Runtime::require_module(scalar $self->dbm_class) or die $@; tie %hash, $self->dbm_class, $self->file, 66, 384 or die qq[Cannot open dbm file for session: $self->{"dbm_class"}, $self->{"file"}]; \%hash }
ABresult
1X1
011
000
26 4 my %hash;
27 4 ▶ Module::Runtime::require_module($self->dbm_class) or die $@;
Branch: 1 branch
BranchTrueFalseTotal
&Module::Runtime::require_module(scalar $self->dbm_class) or die $@ 4 0 4
28 4 ▶ tie %hash, $self->dbm_class, $self->file, O_CREAT | O_RDWR, oct("600") or die "Cannot open dbm file for session: $self->{dbm_class}, $self->{file}";
Branch: 1 branch
BranchTrueFalseTotal
tie %hash, $self->dbm_class, $self->file, 66, 384 or die qq[Cannot open dbm file for session: $self->{"dbm_class"}, $self->{"file"}] 4 0 4
29 4 \%hash;
30 };
31 }
32  
33 4 ▶sub select {
Subroutine select: called CC=1 SCAR=0.0
Pod documented
34 4 my ( $self, $key ) = @_;
35 4 Storable::thaw $self->dbm->{$key};
36 }
37  
38 2 ▶sub insert {
Subroutine insert: called CC=1 SCAR=0.0
Pod documented
39 2 my ( $self, $key, $value ) = @_;
40 2 $self->dbm->{$key} = Storable::freeze $value;
41 }
42 0 ▶sub update { shift->insert(@_) }
Subroutine update: not called CC=1 SCAR=6.9
Pod documented
43  
44 0 ▶sub delete {
Subroutine delete: not called CC=1 SCAR=6.9
Pod documented
45 0 my ( $self, $key ) = @_;
46 0 delete $self->dbm->{$key};
47 }
48  
49 0 ▶sub cleanup { Carp::croak "This storage doesn't support cleanup" }
Subroutine cleanup: not called CC=1 SCAR=6.9
Pod undocumented
50  
51 2 1;
52 __END__
« Session/Store/CHI.pm ↑ Summary Session/State/Test.pm »