lib/ayadn/databases.rb in ayadn-1.1.0 vs lib/ayadn/databases.rb in ayadn-1.1.1
- old
+ new
@@ -6,15 +6,15 @@
class << self
attr_accessor :users, :index, :pagination, :aliases, :blacklist
end
def self.open_databases
- @users = Daybreak::DB.new "#{Settings.config[:paths][:db]}/users.db"
- @index = Daybreak::DB.new "#{Settings.config[:paths][:pagination]}/index.db"
- @pagination = Daybreak::DB.new "#{Settings.config[:paths][:pagination]}/pagination.db"
- @aliases = Daybreak::DB.new "#{Settings.config[:paths][:db]}/aliases.db"
- @blacklist = Daybreak::DB.new "#{Settings.config[:paths][:db]}/blacklist.db"
+ @users = self.init "#{Settings.config[:paths][:db]}/users.db"
+ @index = self.init "#{Settings.config[:paths][:pagination]}/index.db"
+ @pagination = self.init "#{Settings.config[:paths][:pagination]}/pagination.db"
+ @aliases = self.init "#{Settings.config[:paths][:db]}/aliases.db"
+ @blacklist = self.init "#{Settings.config[:paths][:db]}/blacklist.db"
end
def self.close_all
@pagination.compact if (File.size("#{Settings.config[:paths][:pagination]}/pagination.db") > (250000))
@index.compact if (File.size("#{Settings.config[:paths][:pagination]}/index.db") > (250000))
@@ -22,10 +22,20 @@
db.flush
db.close
end
end
+ def self.init(path)
+ winPlatforms = ['mswin', 'mingw', 'mingw_18', 'mingw_19', 'mingw_20', 'mingw32']
+ case RbConfig::CONFIG['host_os']
+ when *winPlatforms
+ abort("\nSorry, Ayadn doesn't work on Windows.\n\n".color(:red))
+ else
+ Daybreak::DB.new "#{path}"
+ end
+ end
+
def self.add_mention_to_blacklist(target)
@blacklist[target.downcase] = :mention
end
def self.add_client_to_blacklist(target)
@blacklist[target.downcase] = :client
@@ -35,11 +45,11 @@
end
def self.remove_from_blacklist(target)
@blacklist.delete(target.downcase)
end
def self.import_blacklist(blacklist)
- new_list = Daybreak::DB.new blacklist
+ new_list = self.init blacklist
new_list.each {|name,type| @blacklist[name] = type}
new_list.close
end
def self.convert_blacklist
dummy = {}
@@ -66,10 +76,10 @@
def self.get_channel_id(channel_alias)
@aliases[channel_alias]
end
def self.import_aliases(aliases)
- new_aliases = Daybreak::DB.new aliases
+ new_aliases = self.init aliases
new_aliases.each {|al,id| @aliases[al] = id}
new_aliases.close
end
def self.get_alias_from_id(channel_id)