diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2012-04-27 11:12:27 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2012-04-27 11:12:27 +0100 |
commit | dada535a41cba45be0eff77381d6c7e19ab49f51 (patch) | |
tree | f33ab8706c38f278fbdec539e69874d72a9e1b74 /lib | |
parent | ffb9ad5713f0f7b895ec142028abae16d824e3b9 (diff) |
Added better time-based people list polling, and added a "calendar" method to
the config to easily generate Procs to call for people_lists.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mauve/configuration.rb | 4 | ||||
-rw-r--r-- | lib/mauve/notification.rb | 3 | ||||
-rw-r--r-- | lib/mauve/people_list.rb | 4 |
3 files changed, 8 insertions, 3 deletions
diff --git a/lib/mauve/configuration.rb b/lib/mauve/configuration.rb index 3a8f9cc..8a0b982 100644 --- a/lib/mauve/configuration.rb +++ b/lib/mauve/configuration.rb @@ -165,5 +165,9 @@ module Mauve @max_acknowledgement_time = arg end + def calendar=(x) + lambda{|at| CalendarInterface.get_attendees(x,at)} + end + end end diff --git a/lib/mauve/notification.rb b/lib/mauve/notification.rb index 8a5d241..899972b 100644 --- a/lib/mauve/notification.rb +++ b/lib/mauve/notification.rb @@ -122,8 +122,9 @@ module Mauve # def no_one_in(people_list) return true unless Configuration.current.people_lists.has_key?(people_list) + @test_time = @time if @test_time.nil? - return Configuration.current.people_lists[people_list].people.empty? + return Configuration.current.people_lists[people_list].people(@test_time).empty? end # Returns true if the current hour is in the list of hours given. diff --git a/lib/mauve/people_list.rb b/lib/mauve/people_list.rb index 0433034..f632f78 100644 --- a/lib/mauve/people_list.rb +++ b/lib/mauve/people_list.rb @@ -63,9 +63,9 @@ module Mauve # Return the array of people # # @return [Array] - def people + def people(at = Time.now) l = list.collect do |name| - name.is_a?(Proc) ? name.call : name + name.is_a?(Proc) ? name.call(at) : name end.flatten.compact.uniq.collect do |name| Configuration.current.people[name] end.compact |