Project

General

Profile

« Previous | Next » 

Revision 849a61fb

Added by Marc Dequènes over 13 years ago

  • ID 849a61fbc6316122e796c45804ce367dfe50f3dd

[evol] Librarian API work §1, using DI too

View differences:

bin/librarian
# to allow in-place run for test
$: << File.join(File.dirname(__FILE__), "..", "lib")
require 'needle'
require 'cyborghood/cyborg'
module CyborgHood
module LibrarianHome
module LibrarianLand
include I18nTranslation
bindtextdomain("cyborghood_librarian", {:path => Config::L10N_DIR, :charset => "UTF-8"})
......
def setup
super
define_interface "0.1~" do
node "Gruik" do
node ["g1", "g2", "g3"] do
on_request do |request|
request.reply.results = {
:plouf => ">>> #{node_name} <<<"
}
end
end
end
end
define_interface "0.1~"
end
end
end
end # LibrarianLand
end
bot = CyborgHood::LibrarianHome::Librarian.new
reg = Needle::Registry.new
reg.define do |b|
b.require 'cyborghood', CyborgHood
b.require 'cyborghood-librarian/land', CyborgHood::LibrarianLand
b.bot { CyborgHood::LibrarianLand::Librarian.new(b.librarian_land) }
end
ldap_config = reg.config.ldap.marshal_dump
ldap_config[:logger] = reg.logger
begin
ActiveLdap::Base.setup_connection(ldap_config)
# force testing a connection NOW (by default ActiveLdap is doing lazy connections)
# (the loaded schema will be useful soon anyway)
# it also tests search parameters (provided to setup_connection)
ActiveLdap::Base.find(:first)
rescue
reg.logger.fatal "LDAP failure: " + $!
exit 1
end
bot = reg.bot
trap('INT') do
bot.ask_to_stop

Also available in: Unified diff