line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bot::BasicBot::Pluggable::Store::Deep; |
2
|
|
|
|
|
|
|
$Bot::BasicBot::Pluggable::Store::Deep::VERSION = '1.10'; |
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
5
|
1
|
|
|
1
|
|
427
|
use DBM::Deep; |
|
1
|
|
|
|
|
6214
|
|
|
1
|
|
|
|
|
3
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
27
|
use base qw( Bot::BasicBot::Pluggable::Store ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
428
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub init { |
10
|
1
|
|
|
1
|
1
|
1
|
my $self = shift; |
11
|
1
|
|
|
|
|
3
|
delete $self->{type}; |
12
|
1
|
|
50
|
|
|
4
|
$self->{file} ||= 'bot-basicbot.deep'; |
13
|
1
|
|
50
|
|
|
7
|
$self->{_db} = DBM::Deep->new(%$self) |
14
|
|
|
|
|
|
|
|| die "Couldn't connect to DB '$self->{file}'"; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub set { |
18
|
2
|
|
|
2
|
1
|
30
|
my ( $self, $namespace, $key, $value ) = @_; |
19
|
2
|
|
|
|
|
9
|
$self->{_db}->{$namespace}->{$key} = $value; |
20
|
2
|
|
|
|
|
2683
|
return $self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub get { |
24
|
2
|
|
|
2
|
1
|
30
|
my ( $self, $namespace, $key ) = @_; |
25
|
2
|
|
|
|
|
12
|
return $self->{_db}->{$namespace}->{$key}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub unset { |
29
|
1
|
|
|
1
|
1
|
2
|
my ( $self, $namespace, $key ) = @_; |
30
|
1
|
|
|
|
|
5
|
delete $self->{_db}->{$namespace}->{$key}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub keys { |
34
|
4
|
|
|
4
|
1
|
11
|
my ( $self, $namespace, %opts ) = @_; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# no idea why this works |
37
|
3
|
|
|
|
|
16
|
return CORE::keys %{ $self->{_db}->{$namespace} } |
38
|
4
|
100
|
66
|
|
|
17
|
unless exists $opts{res} && @{ $opts{res} }; |
|
1
|
|
|
|
|
6
|
|
39
|
1
|
|
50
|
|
|
5
|
my $mod = $self->{_db}->{$namespace} || {}; |
40
|
1
|
|
|
|
|
567
|
return $self->_keys_aux( $mod, $namespace, %opts ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub namespaces { |
44
|
1
|
|
|
1
|
1
|
26
|
my ($self) = @_; |
45
|
1
|
|
|
|
|
1
|
return CORE::keys %{ $self->{_db} }; |
|
1
|
|
|
|
|
4
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
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.10 |
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. |