From: Matthias Hecker Date: Wed, 5 Mar 2014 12:04:47 +0000 (+0100) Subject: [registry] use tc by-default if available X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;ds=sidebyside;h=269d874e9dfc9e076eb45ca22397ad2f3715aa29;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git [registry] use tc by-default if available --- diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 02414a07..34c82926 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -435,8 +435,8 @@ class Bot }, :desc => "Percentage of IRC penalty to consider when sending messages to prevent being disconnected for excess flood. Set to 0 to disable penalty control.") Config.register Config::StringValue.new('core.db', - :default => "dbm", - :wizard => true, :default => "dbm", + :default => default_db, + :wizard => true, :validate => Proc.new { |v| Registry::formats.include? v }, :requires_restart => true, :desc => "DB adaptor to use for storing the plugin data/registries. Options: " + Registry::formats.join(', ')) @@ -822,6 +822,16 @@ class Bot end end + # Determine if tokyocabinet is installed, if it is use it as a default. + def default_db + begin + require 'tokyocabinet' + return 'tc' + rescue LoadError + return 'dbm' + end + end + def repopulate_botclass_directory template_dir = File.join Config::datadir, 'templates' if FileTest.directory? @botclass