# = ildus/server/backend - generic server backend library
#
# Copyright (C) 2005 Paul van Tilburg <paul@luon.net>
# Ildus is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
require 'singleton'
module Ildus
class Server
module Backend
BackendClasses = Hash.new
class << self
def load
path = File.dirname(__FILE__)
Dir["#{path}/backends/**/*.rb"].each { |file| require file }
end
def get(type)
BackendClasses[type.to_sym]
alias_method :[], :get
def register(type, backend_class)
if BackendClasses.include? type
raise "type #{type} already registered"
BackendClasses[type] = backend_class
end # self
class Basic
attr_reader :config, :user, :pass
def self.inherited(subclass)
diff = subclass.to_s.split('::') - self.to_s.split('::')
type = diff.to_s.split('::').last.downcase.to_sym
Backend.register(type, subclass)
def initialize(backend_config)
@config = backend_config
@auth = false
@user = user
@pass = pass
#################
# Account methods
def user=(username)
@user = username
def pass=(password)
@pass = password
authenticate
def authenticated?
@auth
# Backend methods
def commit
raise Handler::NotImplementedError
def authenticate
def register_account
def unregister_account
def hosts
def add_host(host)
def remove_host(host)
def update_host(host, addr)
def add_alias(new_alias, host)
def remove_alias(old_alias, host)
end # class Basic
end # module Backend
end # class Server
end # module Ildus