blib/lib/Bot/BasicBot/Pluggable/Store/Deep.pm

filter: Statementstmt 100% 34 / 34 Branchbran 100% 2 / 2 Conditioncond 55.5% 5 / 9 MC/DCmcdc 20.0% 1 / 5 Subroutinesub 100% 10 / 10 Podpod 100% 6 / 6 totaltotal 87.8% 58 / 66 CC 6 SCAR 8.1
CC
6
Cov
91%
keys
4.1
init
3.1
BEGIN
1.0
CRAP 2.2
« blib/lib/Test/Bot/BasicBot/Pluggable.pm ↑ Summary lib/Bot/BasicBot/Pluggable/Module.pm »
1 package Bot::BasicBot::Pluggable::Store::Deep;
2 1 $Bot::BasicBot::Pluggable::Store::Deep::VERSION = '1.11';
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use DBM::Deep;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use base qw( Bot::BasicBot::Pluggable::Store );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 sub init {
10 1 ▶ my $self = shift;
Subroutine init: called CC=3 SCAR=11.4
Pod documented
11 1 delete $self->{type};
12 1 ▶ $self->{file} ||= 'bot-basicbot.deep';
Condition50%1/2
$self->{"file"} ||= "bot-basicbot.deep"
l!l
10
MC/DC0%0/1
$self->{"file"} ||= "bot-basicbot.deep"
$self->{"file"}
Truth table50%1/2
A
A= $self->{"file"}
Aresult
11
00
13 1 ▶ $self->{_db} = DBM::Deep->new(%$self)
Condition50%1/2
'DBM::Deep'->new(%$self) || die("Couldn't connect to DB '$self->{'file'}'")
l!l
10
MC/DC0%0/1
'DBM::Deep'->new(%$self) || die("Couldn't connect to DB '$self->{'file'}'")
'DBM::Deep'->new(%$self)
Truth table50%1/2
A
A= 'DBM::Deep'->new(%$self)
Aresult
11
00
14 || die "Couldn't connect to DB '$self->{file}'";
15 }
16  
17 sub set {
18 2 ▶ my ( $self, $namespace, $key, $value ) = @_;
Subroutine set: called CC=1 SCAR=0.0
Pod documented
19 2 $self->{_db}->{$namespace}->{$key} = $value;
20 2 return $self;
21 }
22  
23 sub get {
24 2 ▶ my ( $self, $namespace, $key ) = @_;
Subroutine get: called CC=1 SCAR=0.0
Pod documented
25 2 return $self->{_db}->{$namespace}->{$key};
26 }
27  
28 sub unset {
29 1 ▶ my ( $self, $namespace, $key ) = @_;
Subroutine unset: called CC=1 SCAR=0.0
Pod documented
30 1 delete $self->{_db}->{$namespace}->{$key};
31 }
32  
33 sub keys {
34 4 ▶ my ( $self, $namespace, %opts ) = @_;
Subroutine keys: called CC=4 SCAR=14.0
Pod documented
35  
36 # no idea why this works
37 3 return CORE::keys %{ $self->{_db}->{$namespace} }
38 4 ▶ unless exists $opts{res} && @{ $opts{res} };
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts{"res"} and @{$opts{"res"};} 3 1 4
Condition66%2/3
exists $opts{"res"} and @{$opts{"res"};}
!ll&&!rl&&r
301
MC/DC50%1/2
exists $opts{"res"} and @{$opts{"res"};}
exists $opts{"res"} @{$opts{"res"};}
Truth table66%2/3
A and B
A= exists $opts{"res"}B= @{$opts{"res"};}
ABresult
0X0
100
111
39 1 ▶ my $mod = $self->{_db}->{$namespace} || {};
Condition50%1/2
$self->{'_db'}{$namespace} || {}
l!l
10
MC/DC0%0/1
$self->{'_db'}{$namespace} || {}
$self->{'_db'}{$namespace}
Truth table50%1/2
A
A= $self->{'_db'}{$namespace}
Aresult
11
00
40 1 return $self->_keys_aux( $mod, $namespace, %opts );
41 }
42  
43 sub namespaces {
44 1 ▶ my ($self) = @_;
Subroutine namespaces: called CC=1 SCAR=0.0
Pod documented
45 1 return CORE::keys %{ $self->{_db} };
46 }
47  
48 1 1;
49  
50 __END__
51  
52 =head1 NAME
53  
54 Bot::BasicBot::Pluggable::Store::Deep - use DBM::Deep to provide a storage backend
55  
56 =head1 VERSION
57  
58 version 1.11
59  
60 =head1 SYNOPSIS
61  
62 my $store = Bot::BasicBot::Pluggable::Store::Deep->new(
63 file => "filename"
64 );
65  
66 $store->set( "namespace", "key", "value" );
67  
68 =head1 DESCRIPTION
69  
70 This is a C<Bot::BasicBot::Pluggable::Store> that uses C<DBM::Deep> to store
71 the values set by modules.
72  
73 =head1 AUTHOR
74  
75 Simon Wistow <simon@thegestalt.org>
76  
77 =head1 COPYRIGHT
78  
79 Copyright 2005, Simon Wistow
80  
81 This program is free software; you can redistribute it
82 and/or modify it under the same terms as Perl itself.
« blib/lib/Test/Bot/BasicBot/Pluggable.pm ↑ Summary lib/Bot/BasicBot/Pluggable/Module.pm »