aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve/person.rb
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2012-04-23 11:37:38 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2012-04-23 11:37:38 +0100
commitca99b0dff974d2fc841d7132d03b3ad1d1bf9b1e (patch)
tree69f949ec5c8a3396222815eacf9109d516de8c84 /lib/mauve/person.rb
parentc3592bdf6fce6f234de37959c677f75d97b1134d (diff)
People/PeopleLists can now specify individualy notification times/frequencies
* Added PeopleList builder * Added Person#during, PeopleList#during, Person#every, PeopleList#every * Notification now uses #during/#every from the Person/PeopleList if nothing was specified * Added tests
Diffstat (limited to 'lib/mauve/person.rb')
-rw-r--r--lib/mauve/person.rb35
1 files changed, 32 insertions, 3 deletions
diff --git a/lib/mauve/person.rb b/lib/mauve/person.rb
index a10e86a..4b4baf1 100644
--- a/lib/mauve/person.rb
+++ b/lib/mauve/person.rb
@@ -3,9 +3,9 @@ require 'timeout'
require 'log4r'
module Mauve
- class Person < Struct.new(:username, :password, :holiday_url, :urgent, :normal, :low, :email, :xmpp, :sms)
+ class Person < Struct.new(:username, :password, :urgent, :normal, :low, :email, :xmpp, :sms)
- attr_reader :notification_thresholds, :last_pop3_login, :suppressed
+ attr_reader :notification_thresholds, :last_pop3_login, :suppressed, :every, :during
# Set up a new Person
#
@@ -26,6 +26,10 @@ module Mauve
# TODO fix up web login so pop3 can be used as a proxy.
#
@last_pop3_login = {:from => nil, :at => nil}
+
+ @every = nil
+ @during = nil
+
super(*args)
end
@@ -36,6 +40,24 @@ module Mauve
#
# @return [Boolean]
def suppressed? ; @suppressed ; end
+
+ #
+ #
+ #
+ def during=(arg)
+ raise "during must be a block" unless arg.is_a?(Proc)
+ @during = arg
+ end
+
+ #
+ #
+ #
+ def every=(arg)
+ raise ArgumentError, "every must be numeric" unless arg.is_a?(Numeric)
+ @every = arg
+ end
+
+ def holiday_url ; nil ; end
# Works out if a notification should be suppressed. If no parameters are supplied, it will
#
@@ -212,7 +234,14 @@ module Mauve
my_last_update && my_last_update.update_type != "cleared"
end
end
-
+
+ #
+ #
+ #
+ def alert_during
+
+ end
+
# Whether the person is on holiday or not.
#
# @return [Boolean] True if person on holiday, false otherwise.