Permalink
Browse files

Fixed a few odd bugs

  • Loading branch information...
chorn committed Jan 18, 2012
1 parent 8bd0f70 commit 430e6388648bb67818ff81e728698d9023907f00
View
0 .gitignore 100644 → 100755
No changes.
View
@@ -0,0 +1,5 @@
+0.4.0:
+
+Fixed bug for these patterns:
+HORN, CHRIS K
+HORN, CHRIS K.
View
0 LICENSE 100644 → 100755
No changes.
View
0 README.rdoc 100644 → 100755
No changes.
View
0 Rakefile 100644 → 100755
No changes.
View
0 TODO 100644 → 100755
No changes.
View
11 lib/nameable.rb 100644 → 100755
@@ -1,4 +1,4 @@
-# Copyright (c) 2010 Chris Horn http://chorn.com/
+# Copyright (c) 2012 Chris Horn http://chorn.com/
# See MIT-LICENSE.txt
# TODO: Make this less sucky.
@@ -78,7 +78,11 @@ def extract_suffix(name)
suff = pretty if name[n] =~ regex
end
- if name[n] =~ Patterns::SUFFIX_ACADEMIC or name[n] =~ Patterns::SUFFIX_PROFESSIONAL or name[n] =~ Patterns::SUFFIX_GENERATIONAL_ROMAN or name[n] =~ Patterns::SUFFIX_ABBREVIATION
+ if name[n] =~ Patterns::SUFFIX_ACADEMIC or name[n] =~ Patterns::SUFFIX_PROFESSIONAL or name[n] =~ Patterns::SUFFIX_GENERATIONAL_ROMAN
+ suff = name[n].upcase.gsub(/\./,'')
+ end
+
+ if name.join != name.join.upcase and name[n].length > 1 and name[n] =~ Patterns::SUFFIX_ABBREVIATION
suff = name[n].upcase.gsub(/\./,'')
end
@@ -139,11 +143,10 @@ def extract_middle(name)
end
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]+),(.*)/i
end
name = name.strip.split(/\s+/)
View
4 nameable.gemspec 100644 → 100755
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = "nameable"
- s.version = "0.2.0"
- s.date = "2010-07-12"
+ s.version = "0.4.0"
+ s.date = "2012-01-18"
s.summary = "Provides parsing and output of person names."
s.email = "chorn@chorn.com"
s.homepage = "http://github.com/chorn/nameable"
View
0 spec/nameable_spec.rb 100644 → 100755
No changes.
View
0 spec/spec.opts 100644 → 100755
No changes.
View
0 spec/spec_helper.rb 100644 → 100755
No changes.
View
@@ -1,14 +1,16 @@
#!/usr/bin/env ruby
require "rubygems"
-require "lib/nameable"
+require "./lib/nameable"
DATA.each do |testcase|
n = Nameable::Latin.new.parse(testcase)
puts "``#{testcase.chomp}'' -> #{n.to_fullname}"
end
__END__
+HORN, CHRIS K
+HORN, CHRIS K.
Mr. Chris Horn PhD
Chris Horn T.I.T.L.E.
Chris Horn II
@@ -25,6 +27,7 @@
CHRIS-HORN
CHRIS;HORN
Horn, Chris
+Horn, Chris K
Horn, Chris K.
Horn, Chris K. DDS
Chris Horn, Ph.D. DB CCNE

0 comments on commit 430e638

Please sign in to comment.