aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve/configuration_builders/person.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/person.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/person.rb')
-rw-r--r--lib/mauve/configuration_builders/person.rb60
1 files changed, 60 insertions, 0 deletions
diff --git a/lib/mauve/configuration_builders/person.rb b/lib/mauve/configuration_builders/person.rb
new file mode 100644
index 0000000..1f2af71
--- /dev/null
+++ b/lib/mauve/configuration_builders/person.rb
@@ -0,0 +1,60 @@
+# encoding: UTF-8
+require 'object_builder'
+require 'mauve/person'
+require 'mauve/configuration_builder'
+
+module Mauve
+ module ConfigurationBuilders
+
+ class Person < ObjectBuilder
+
+ def builder_setup(username)
+ @result = Mauve::Person.new(username)
+ end
+
+ is_block_attribute "urgent"
+ is_block_attribute "normal"
+ is_block_attribute "low"
+
+ def all(&block); urgent(&block); normal(&block); low(&block); end
+
+ def password (pwd)
+ @result.password = pwd.to_s
+ end
+
+ def holiday_url (url)
+ @result.holiday_url = url.to_s
+ end
+
+ def email(e)
+ @result.email = e.to_s
+ end
+
+ def xmpp(x)
+ @result.xmpp = x.to_s
+ end
+
+ def sms(x)
+ @result.sms = x.to_s
+ end
+
+ def suppress_notifications_after(h)
+ raise ArgumentError.new("notification_threshold must be specified as e.g. (10 => 1.minute)") unless
+ h.kind_of?(Hash) && h.keys[0].kind_of?(Integer) && h.values[0].kind_of?(Integer)
+ @result.notification_thresholds[h.values[0]] = Array.new(h.keys[0])
+ end
+ end
+ end
+
+ class ConfigurationBuilder < ObjectBuilder
+
+ is_builder "person", ConfigurationBuilders::Person
+
+ def created_person(person)
+ name = person.username
+ raise BuildException.new("Duplicate person '#{name}'") if @result.people[name]
+ @result.people[person.username] = person
+ end
+
+ end
+end