blob: a13cb8cef23ddd6a6d9b04a35b52cf9d98bc28f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#-- vim:sw=2:et
#++
#
# :title: DBM registry implementation
#
# DBM is the ruby standard library wrapper module for Unix-style
# dbm libraries. The specific library used depends
# on how ruby was compiled. Its any of the following: ndbm, bdb,
# gdbm or qdbm.
# http://ruby-doc.org/stdlib-2.1.0/libdoc/dbm/rdoc/DBM.html
#
require 'dbm'
module Irc
class Bot
class Registry
class DBMAccessor < AbstractAccessor
def registry
super
@registry ||= DBM.open(@filename, 0666, DBM::WRCREAT)
end
def flush
return if !@registry
# ruby dbm has no flush, so we close/reopen :(
close
registry
end
def dbexists?
not Dir.glob(@filename + '.*').empty?
end
def optimize
# unsupported!
end
end
end # Registry
end # Bot
end # Irc
|