« blib/lib/Bot/BasicBot/Pluggable/Store/Storable.pm
↑ Summary
blib/lib/Test/Bot/BasicBot/Pluggable.pm »
| 1 | package Bot::BasicBot::Pluggable::Store::Deep; | ||||||||||||||||||||||||||||
| 2 | 1 | $Bot::BasicBot::Pluggable::Store::Deep::VERSION = '1.20'; | |||||||||||||||||||||||||||
| 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"
MC/DC0%0/1
$self->{"file"} ||= "bot-basicbot.deep"
$self->{"file"}
Truth table50%1/2
A
A= $self->{"file"}
| |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | $self->{_db} = DBM::Deep->new(%$self) | ||||||||||||||||||||||||||
|
Condition50%1/2
'DBM::Deep'->new(%$self) || die("Couldn't connect to DB '$self->{'file'}'")
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)
| |||||||||||||||||||||||||||||
| 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
Condition66%2/3
exists $opts{"res"} and @{$opts{"res"};}
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"};}
| |||||||||||||||||||||||||||||
| 39 | 1 | ▶ | my $mod = $self->{_db}->{$namespace} || {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'_db'}{$namespace} || {}
MC/DC0%0/1
$self->{'_db'}{$namespace} || {}
$self->{'_db'}{$namespace}
Truth table50%1/2
A
A= $self->{'_db'}{$namespace}
| |||||||||||||||||||||||||||||
| 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.20 | ||||||||||||||||||||||||||||
| 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. | ||||||||||||||||||||||||||||