blob: 014987f62c750caf3ceb6ede8b8252593682a6f6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# 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]
#
# Add a default notification threshold
#
person.notification_thresholds[60] = Array.new(10) if person.notification_thresholds.empty?
@result.people[person.username] = person
end
end
end
|