whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: Option to return hash with ids
Date Mon, 07 Oct 2019 16:21:33 GMT
This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new ec79928  Option to return hash with ids
ec79928 is described below

commit ec799282be58db408cd92de9b877e96b68c8ba08
Author: Sebb <sebb@apache.org>
AuthorDate: Mon Oct 7 17:21:24 2019 +0100

    Option to return hash with ids
---
 lib/whimsy/asf/board.rb | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/lib/whimsy/asf/board.rb b/lib/whimsy/asf/board.rb
index 4268d8e..1fda596 100644
--- a/lib/whimsy/asf/board.rb
+++ b/lib/whimsy/asf/board.rb
@@ -6,10 +6,20 @@ module ASF
     TIMEZONE = TZInfo::Timezone.get('US/Pacific')
 
     # sorted list of Directors
-    def self.directors
-      ASF::Service['board'].members.
-        map {|person| person.public_name}.
-        sort_by {|name| name.split(' ').rotate}
+    # default to names only
+    # if withId == true, then return hash: { id: {name: public_name}}
+    # This allows for returning additional data such as start of tenure
+    # sort is by last name
+    def self.directors(withId=false)
+      if withId
+        ASF::Service['board'].members.
+        map {|person| [person.id, {name: person.public_name}]}.
+          sort_by {|id,hash| hash[:name].split(' ').rotate}.t_h
+      else
+        ASF::Service['board'].members.
+          map {|person| person.public_name}.
+            sort_by {|name| name.split(' ').rotate}
+      end
     end
 
     # list of board meeting times as listed in 


Mime
View raw message