From fd23821950f0562a8995735105cd31fdc6d55933 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Fri, 22 Jul 2011 16:55:01 +0100 Subject: * Rejigged configuration * Added --test and --verbose flags for the server config * Started proper test suite * Config parsing now gives more sensible errors + backtrace * Rejigged people and source lists --- lib/mauve/configuration_builders/server.rb | 102 +++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 lib/mauve/configuration_builders/server.rb (limited to 'lib/mauve/configuration_builders/server.rb') diff --git a/lib/mauve/configuration_builders/server.rb b/lib/mauve/configuration_builders/server.rb new file mode 100644 index 0000000..0fa811b --- /dev/null +++ b/lib/mauve/configuration_builders/server.rb @@ -0,0 +1,102 @@ +# encoding: UTF-8 +require 'mauve/server' +require 'mauve/configuration_builder' + +module Mauve + module ConfigurationBuilders + + class HTTPServer < ObjectBuilder + is_attribute "port" + is_attribute "ip" + is_attribute "document_root" + is_attribute "session_secret" + is_attribute "base_url" + + def builder_setup + @result = Mauve::HTTPServer.instance + end + end + + class UDPServer < ObjectBuilder + is_attribute "port" + is_attribute "ip" + is_attribute "poll_every" + + def builder_setup + @result = Mauve::UDPServer.instance + end + end + + class Processor < ObjectBuilder + is_attribute "poll_every" + is_attribute "transmission_cache_expire_time" + + def builder_setup + @result = Mauve::Processor.instance + end + end + + class Timer < ObjectBuilder + is_attribute "poll_every" + + def builder_setup + @result = Mauve::Timer.instance + end + end + + class Notifier < ObjectBuilder + is_attribute "poll_every" + + def builder_setup + @result = Mauve::Notifier.instance + end + end + + class Heartbeat < ObjectBuilder + is_attribute "destination" + is_attribute "detail" + is_attribute "summary" + is_attribute "raise_after" + is_attribute "send_every" + + def builder_setup + @result = Mauve::Heartbeat.instance + end + end + + class Server < ObjectBuilder + # + # Set up second-level builders + # + is_builder "web_interface", HTTPServer + is_builder "listener", UDPServer + is_builder "processor", Processor + is_builder "timer", Timer + is_builder "notifier", Notifier + is_builder "heartbeat", Heartbeat + + is_attribute "hostname" + is_attribute "database" + is_attribute "initial_sleep" + + def builder_setup + @result = Mauve::Server.instance + end + end + end + + # + # Add server to our top-level config builder + # + class ConfigurationBuilder < ObjectBuilder + + is_builder "server", ConfigurationBuilders::Server + + def created_server(server) + raise BuildError.new("Only one 'server' clause can be specified") if @result.server + @result.server = server + end + + end + +end -- cgit v1.2.1