diff options
Diffstat (limited to 'lib/mauve/configuration_builders')
-rw-r--r-- | lib/mauve/configuration_builders/alert_group.rb | 18 | ||||
-rw-r--r-- | lib/mauve/configuration_builders/people_list.rb | 41 | ||||
-rw-r--r-- | lib/mauve/configuration_builders/person.rb | 2 |
3 files changed, 51 insertions, 10 deletions
diff --git a/lib/mauve/configuration_builders/alert_group.rb b/lib/mauve/configuration_builders/alert_group.rb index 56c446d..40e5d9d 100644 --- a/lib/mauve/configuration_builders/alert_group.rb +++ b/lib/mauve/configuration_builders/alert_group.rb @@ -14,22 +14,20 @@ module Mauve # Sets up the notification # - # @param [Array] who List of usernames or people_lists to notify + # @param [String] who Username or people_list to notify # @raise [ArgumentError] if a username doesn't exist. # # @return [Mauve::Notification] New notification instance. - def builder_setup(*who) - who = who.map do |username| - if @context.people[username] - @context.people[username] + def builder_setup(who) + who = if @context.people[who] + @context.people[who] - elsif @context.people_lists[username] - @context.people_lists[username] + elsif @context.people_lists[who] + @context.people_lists[who] - else - raise ArgumentError.new("You have not declared who #{username} is") + else + raise ArgumentError.new("You have not declared who #{who} is") - end end @result = Mauve::Notification.new(who, @context.last_alert_group.level) end diff --git a/lib/mauve/configuration_builders/people_list.rb b/lib/mauve/configuration_builders/people_list.rb new file mode 100644 index 0000000..e5f6715 --- /dev/null +++ b/lib/mauve/configuration_builders/people_list.rb @@ -0,0 +1,41 @@ +# encoding: UTF-8 +require 'object_builder' +require 'mauve/people_list' +require 'mauve/configuration_builder' + +module Mauve + module ConfigurationBuilders + + class PeopleList < ObjectBuilder + + def builder_setup(label, list) + @result = Mauve::PeopleList.new(label) + @result += list + end + + is_block_attribute "during" + is_attribute "every" + + end + end + + class ConfigurationBuilder < ObjectBuilder + + is_builder "people_list", ConfigurationBuilders::PeopleList + + # Method called once a people_list has been created to check for duplicate labels + # + # @param [Mauve::PeopleList] people_list + # + def created_people_list(people_list) + label = people_list.label + if @result.people_lists.has_key?(label) + _logger.warn("Duplicate people_list '#{label}'") + @result.people_lists[label] += people_list.list + else + @result.people_lists[label] = people_list + end + end + + end +end diff --git a/lib/mauve/configuration_builders/person.rb b/lib/mauve/configuration_builders/person.rb index c5314c5..7881d01 100644 --- a/lib/mauve/configuration_builders/person.rb +++ b/lib/mauve/configuration_builders/person.rb @@ -15,6 +15,8 @@ module Mauve is_block_attribute "urgent" is_block_attribute "normal" is_block_attribute "low" + is_block_attribute "during" + is_attribute "every" is_attribute "password" is_attribute "sms" is_attribute "holiday_url" |