lib/WebService/CIA/Source/DBM.pm

filter: Statementstmt 61.5% 32 / 52 Branchbran 35.7% 5 / 14 Conditioncond 33.3% 3 / 9 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 63.6% 7 / 11 Podpod 100% 5 / 5 totaltotal 54.6% 53 / 97 CC 11 SCAR 20.3
CC
11
Cov
53%
new
12.7
value
12.0
all
6.0
CRAP 7.6
↑ Summary lib/WebService/CIA/Source.pm »
1 package WebService::CIA::Source::DBM;
2  
3 2 require 5.005_62;
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Fcntl;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use MLDBM qw(DB_File Storable);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use WebService::CIA::Source;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 @WebService::CIA::Source::DBM::ISA = ("WebService::CIA::Source");
12  
13 2 our $VERSION = '1.4';
14  
15 2 ▶sub new {
Subroutine new: called CC=8 SCAR=25.4
Pod documented
16  
17 2 my $proto = shift;
18 2 my $opts = shift;
19 2 ▶ my $class = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
20 2 my $self = {};
21  
22 2 ▶ unless (exists $opts->{DBM}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $opts->{"DBM"}) 0 2 2
23 0 croak("WebService::CIA::Source::DBM: No DBM file specified");
24 }
25  
26 2 my $mode;
27 2 ▶ if (exists $opts->{Mode} && $opts->{Mode} eq "readwrite") {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $opts->{'Mode'} and $opts->{'Mode'} eq 'readwrite') { } 1 1 2
elsif (-e $opts->{'DBM'}) { } 0 1 1
Condition66%2/3
exists $opts->{"Mode"} and $opts->{"Mode"} eq "readwrite"
!ll&&!rl&&r
101
MC/DC50%1/2
exists $opts->{"Mode"} and $opts->{"Mode"} eq "readwrite"
exists $opts->{"Mode"} $opts->{"Mode"} eq "readwrite"
Truth table66%2/3
A and B
A= exists $opts->{"Mode"}B= $opts->{"Mode"} eq "readwrite"
ABresult
0X0
100
111
28 1 ▶ tie %{$self->{DBM}}, "MLDBM", $opts->{DBM}, O_CREAT|O_RDWR, 0640 or croak "WebService::CIA::Source::DBM: Can't open DBM: $!"; ## no critic (ProhibitLeadingZeros)
Branch: 1 branch
BranchTrueFalseTotal
tie %{$$self{"DBM"};}, "MLDBM", $opts->{"DBM"}, 66, 416 or croak("WebService::CIA::Source::DBM: Can't open DBM: $!") 0 1 1
29 } elsif (-e $opts->{DBM}) {
30 0 ▶ tie %{$self->{DBM}}, "MLDBM", $opts->{DBM}, O_RDONLY, 0440 or croak "WebService::CIA::Source::DBM: Can't open DBM: $!"; ## no critic (ProhibitLeadingZeros)
Branch: 1 branch
BranchTrueFalseTotal
tie %{$$self{"DBM"};}, "MLDBM", $opts->{"DBM"}, 0, 288 or croak("WebService::CIA::Source::DBM: Can't open DBM: $!") 0 0 0
31 } else {
32 1 croak "WebService::CIA::Source::DBM: $opts->{DBM}: $!";
33 }
34  
35 0 bless ($self, $class);
36 0 return $self;
37  
38 }
39  
40 0 ▶sub value {
Subroutine value: not called CC=3 SCAR=24.8
Pod documented
41  
42 0 my $self = shift;
43 0 my ($country, $field) = @_;
44 0 ▶ if (exists $self->dbm->{$country} and exists $self->dbm->{$country}->{$field}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->dbm->{$country} and exists $self->dbm->{$country}{$field}) { } 0 0 0
Condition0%0/3
exists $self->dbm->{$country} and exists $self->dbm->{$country}{$field}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->dbm->{$country} and exists $self->dbm->{$country}{$field}
exists $self->dbm->{$country} exists $self->dbm->{$country}{$field}
Truth table0%0/3
A and B
A= exists $self->dbm->{$country}B= exists $self->dbm->{$country}{$field}
ABresult
0X0
100
111
45 0 return $self->dbm->{$country}->{$field};
46 } else {
47 0 return;
48 }
49  
50 }
51  
52 0 ▶sub all {
Subroutine all: not called CC=2 SCAR=17.9
Pod documented
53  
54 0 my $self = shift;
55 0 my $cc = shift;
56 0 ▶ if (exists $self->dbm->{$cc}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->dbm->{$cc}) { } 0 0 0
57 0 return $self->dbm->{$cc};
58 } else {
59 0 return {};
60 }
61  
62 }
63  
64 0 ▶sub set {
Subroutine set: not called CC=1 SCAR=6.9
Pod documented
65  
66 0 my $self = shift;
67 0 my ($cc, $data) = @_;
68 0 $self->dbm->{$cc} = $data;
69  
70 }
71  
72 0 ▶sub dbm {
Subroutine dbm: not called CC=1 SCAR=6.9
Pod documented
73  
74 0 my $self = shift;
75 0 return $self->{DBM};
76  
77 }
78  
79  
80 2 1;
81  
82 __END__
↑ Summary lib/WebService/CIA/Source.pm »