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: Allow for van Gogh etc
Date Tue, 31 Jul 2018 12:41:28 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 d467d8b  Allow for van Gogh etc
d467d8b is described below

commit d467d8b1dccb723e4494c42be97ab0af3a6e5cb9
Author: Sebb <sebb@apache.org>
AuthorDate: Tue Jul 31 13:41:27 2018 +0100

    Allow for van Gogh etc
---
 lib/whimsy/asf/person.rb | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/whimsy/asf/person.rb b/lib/whimsy/asf/person.rb
index 016e69d..b903ae6 100644
--- a/lib/whimsy/asf/person.rb
+++ b/lib/whimsy/asf/person.rb
@@ -89,8 +89,15 @@ module ASF
         result['title'] ||= title
       end 
       result['generationQualifier'] = words.pop if words.last =~ SUFFIXES
-      result['givenName'] = words.first
-      result['sn'] = words.last
+      result['givenName'] = words.first # TODO does gn allow multiple words?
+      # extract surnames like van Gogh etc
+      if words.size >= 4 and words[1..2] == %w(de la) or words[1..2] == %w(van der)
+        result['sn'] = words[-3..-1].join(' ')
+      elsif words.size >= 3 and %w(van Van de De del Del den le Le).include?  words[-2]
+        result['sn'] = words[-2..-1].join(' ')
+      else
+        result['sn'] = words.last
+      end 
       result
     end
 


Mime
View raw message