You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2018/07/31 11:33:53 UTC
[whimsy] branch master updated: Name might contain both Dr. and
Ph.D.
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 <se...@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