]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
registry: add in-memory implementation for tests
authorMatthias Hecker <mail@apoc.cc>
Mon, 6 Apr 2020 18:19:50 +0000 (20:19 +0200)
committerMatthias Hecker <mail@apoc.cc>
Mon, 6 Apr 2020 18:19:50 +0000 (20:19 +0200)
lib/rbot/registry.rb
lib/rbot/registry/mem.rb [new file with mode: 0644]

index 04892d73d69bd4dd3cfa3aba773df3f7fba55eee..61d4b33e02ef454d8cebcfb52617d53bc1f9eef0 100644 (file)
@@ -110,7 +110,7 @@ class Registry
     attr_accessor :recovery
 
     def initialize(filename)
-      debug 'init registry accessor for: ' + filename
+      debug "init registry accessor of #{self.class} for: #{filename}"
       @filename = filename
       @name = File.basename filename
       @registry = nil
diff --git a/lib/rbot/registry/mem.rb b/lib/rbot/registry/mem.rb
new file mode 100644 (file)
index 0000000..85d52b1
--- /dev/null
@@ -0,0 +1,30 @@
+#-- vim:sw=2:et
+#++
+#
+# :title: Memory registry implementation
+#
+# This is using a in-memory hash, does not persist, used for
+# tests, etc.
+#
+
+module Irc
+class Bot
+class Registry
+
+  class MemAccessor < AbstractAccessor
+
+    def registry
+      super
+      @registry = {}
+    end
+
+    def dbexists?
+      true  # the memory database always exists, this way it won't create any folders on the file system
+    end
+
+  end
+
+end # Registry
+end # Bot
+end # Irc
+