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: Name might contain both Dr. and Ph.D.
Date Tue, 31 Jul 2018 11:33:53 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 5964add  Name might contain both Dr. and Ph.D.
5964add is described below

commit 5964addac819d1d41481cdd449bc6e9e16556e6f
Author: Sebb <sebb@apache.org>
AuthorDate: Tue Jul 31 12:33:51 2018 +0100

    Name might contain both Dr. and Ph.D.
---
 lib/whimsy/asf/person.rb | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/whimsy/asf/person.rb b/lib/whimsy/asf/person.rb
index 2e81c7c..016e69d 100644
--- a/lib/whimsy/asf/person.rb
+++ b/lib/whimsy/asf/person.rb
@@ -83,8 +83,11 @@ module ASF
     def self.ldap_name(name)
       words = name.gsub(',', '').split(' ')
       result = {'cn' => name}
-      result['title'] = words.shift if words.first == 'Dr.'
-      result['title'] ||= words.pop if words.last =~ /^Ph\.D\.?/
+      result['title'] = words.shift if words.first == 'Dr.' or words.first == 'Dr'
+      if words.last =~ /^Ph\.D\.?/
+        title = words.pop # Always pop (||= short-circuits the pop)
+        result['title'] ||= title
+      end 
       result['generationQualifier'] = words.pop if words.last =~ SUFFIXES
       result['givenName'] = words.first
       result['sn'] = words.last


Mime
View raw message