From 58f5a950200f5957307a8552b92ce9e92f948b73 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Thu, 3 May 2012 19:42:20 +0100 Subject: * Person and people lists have now become interchangeable, with notifications only recording the username, rather than the Person/PeopleList. This means that notifications in alert groups can use default #during clauses and #every values from people lists and persons. * Notify clauses can now take an array of persons/people_lists, and people_lists can refer to other people lists. * PeopleList names are now in the same namespace as usernames. * Tests to go with. --- lib/mauve/configuration_builders/alert_group.rb | 38 ++----------------------- lib/mauve/configuration_builders/people_list.rb | 15 ++++------ lib/mauve/configuration_builders/person.rb | 1 + 3 files changed, 9 insertions(+), 45 deletions(-) (limited to 'lib/mauve/configuration_builders') diff --git a/lib/mauve/configuration_builders/alert_group.rb b/lib/mauve/configuration_builders/alert_group.rb index 851ab7f..a813ee9 100644 --- a/lib/mauve/configuration_builders/alert_group.rb +++ b/lib/mauve/configuration_builders/alert_group.rb @@ -18,22 +18,8 @@ module Mauve # @raise [ArgumentError] if a username doesn't exist. # # @return [Mauve::Notification] New notification instance. - def builder_setup(who) - who = if who.is_a?(Mauve::Person) or who.is_a?(Mauve::PeopleList) - who - - elsif @context.people[who] - @context.people[who] - - elsif @context.people_lists[who] - @context.people_lists[who] - - else - raise ArgumentError.new("You have not declared who #{who} is") - - end - - @result = Mauve::Notification.new(who) + def builder_setup(*who) + @result = Mauve::Notification.new(*who) end is_attribute "every" @@ -65,25 +51,7 @@ module Mauve # def created_notify(notification) @result.notifications ||= [] - - if notification.during.nil? and notification.every.nil? - @result.notifications += notification.person.notifications.collect do |n| - # - # Set up a new notification for each one defined for this person. - # - new_notification = Mauve::Notification.new(notification.person) - new_notification.level = @result.level - new_notification.every = n.every - new_notification.during = n.during - new_notification - end - else - # - # Set the level for this notification - # - notification.level = @result.level - @result.notifications << notification - end + @result.notifications << notification end end diff --git a/lib/mauve/configuration_builders/people_list.rb b/lib/mauve/configuration_builders/people_list.rb index fffa15c..7a5f3ab 100644 --- a/lib/mauve/configuration_builders/people_list.rb +++ b/lib/mauve/configuration_builders/people_list.rb @@ -9,9 +9,9 @@ module Mauve class PeopleList < ObjectBuilder - is_builder "notification", Notification + is_builder "notification", ConfigurationBuilders::Notification - def builder_setup(label, list) + def builder_setup(label, *list) @result = Mauve::PeopleList.new(label) @result += list @result @@ -41,14 +41,9 @@ module Mauve # @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 + name = people_list.username + raise ArgumentError.new("Duplicate person '#{name}'") if @result.people[name] + @result.people[name] = people_list end - end end diff --git a/lib/mauve/configuration_builders/person.rb b/lib/mauve/configuration_builders/person.rb index 5c79474..bb4fe8d 100644 --- a/lib/mauve/configuration_builders/person.rb +++ b/lib/mauve/configuration_builders/person.rb @@ -5,6 +5,7 @@ require 'mauve/configuration_builder' require 'mauve/configuration_builders/alert_group' module Mauve + module ConfigurationBuilders class Person < ObjectBuilder -- cgit v1.2.1