Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed a few format bugs

  • Loading branch information...
commit 192cfa1b6caca50907fe6cdbacad9fcbb576af49 1 parent 430e638
@chorn authored
View
5 Changelog
@@ -1,5 +0,0 @@
-0.4.0:
-
-Fixed bug for these patterns:
-HORN, CHRIS K
-HORN, CHRIS K.
View
11 History.txt
@@ -0,0 +1,11 @@
+0.4.2:
+Allow for multiple commas/spaces for the last name, first name format.
+
+0.4.1:
+A period after Jr. or Sr. as a generational title is no longer necessary.
+
+0.4.0:
+
+Fixed a bug for these patterns:
+HORN, CHRIS K
+HORN, CHRIS K.
View
8 lib/nameable.rb
@@ -26,9 +26,9 @@ module Patterns
}
SUFFIX = {
- "Sr." => /^\(*(sr\.|senior)\)*$/i,
- "Jr." => /^\(*(jr\.|junior)\)*$/i,
- "Esq." => /^\(*(esq\.|esquire)\)*$/i,
+ "Sr." => /^\(*(sr\.?|senior)\)*$/i,
+ "Jr." => /^\(*(jr\.?|junior)\)*$/i,
+ "Esq." => /^\(*(esq\.?|esquire)\)*$/i,
"Ph.D." => /^\(*(phd\.?)\)*$/i
}
@@ -146,7 +146,7 @@ def parse(name)
raise InvalidNameError unless name
if name.class == String
if name.index(',')
- name = "#{$2} #{$1}" if name =~ /^([a-z]+),(.*)/i
+ name = "#{$2} #{$1}" if name =~ /^([a-z]+)\s*,\s*,*(.*)/i
end
name = name.strip.split(/\s+/)
View
4 nameable.gemspec
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = "nameable"
- s.version = "0.4.0"
- s.date = "2012-01-18"
+ s.version = "0.4.2"
+ s.date = "2012-01-23"
s.summary = "Provides parsing and output of person names."
s.email = "chorn@chorn.com"
s.homepage = "http://github.com/chorn/nameable"
View
7 test.rb
@@ -5,7 +5,7 @@
DATA.each do |testcase|
n = Nameable::Latin.new.parse(testcase)
- puts "``#{testcase.chomp}'' -> #{n.to_fullname}"
+ puts "``#{testcase.chomp}'' -> #{n.first} #{n.last} // #{n.to_fullname}"
end
__END__
@@ -21,6 +21,7 @@
Chris O' Horn
Chris K Horn
Chris K. Horn
+Chris K Horn Sr
Chris Horn - Horn
Chris Ole Biscuit Barrel Horn
CHRIS HORN
@@ -30,4 +31,8 @@
Horn, Chris K
Horn, Chris K.
Horn, Chris K. DDS
+Horn,,Chris
+Horn,, Chris
+Horn , , Chris
+Horn ,, Chris
Chris Horn, Ph.D. DB CCNE
Please sign in to comment.
Something went wrong with that request. Please try again.