summaryrefslogtreecommitdiff
path: root/lib/rbot/registry/dbm.rb
blob: 9c0304a97f411ab457bec7d664b6ea48d8eaede6 (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
#-- 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 dbexists?
      not Dir.glob(@filename + '.*').empty?
    end

  end

end # Registry
end # Bot
end # Irc