| 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
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||||
| 20 | 2 | my $self = {}; | |||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | unless (exists $opts->{DBM}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
exists $opts->{"Mode"} and $opts->{"Mode"} eq "readwrite"
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"
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
exists $self->dbm->{$country} and exists $self->dbm->{$country}{$field}
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}
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||