aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve/configuration_builders/server.rb
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-07-22 16:55:01 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-07-22 16:55:01 +0100
commitfd23821950f0562a8995735105cd31fdc6d55933 (patch)
tree967df2f5647803a6c46f4d52003b2231c1de72cb /lib/mauve/configuration_builders/server.rb
parentd3a3cfef9650b08f62db62bd7e86b673f9d77d0b (diff)
* 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
Diffstat (limited to 'lib/mauve/configuration_builders/server.rb')
-rw-r--r--lib/mauve/configuration_builders/server.rb102
1 files changed, 102 insertions, 0 deletions
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