human_name_parser 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -106,7 +106,12 @@ module HumanNameParser
106
106
  # this is a thing that I cannot recognize
107
107
  @split_name = []
108
108
  elsif @input_string.count(",") == 1
109
- @split_name = split_last_comma_first_middle
109
+ if suffix_follows_comma?(@input_string)
110
+ # remove commas from the split
111
+ @split_name = split_first_middle_last.map {|n| n.gsub(',', '')}
112
+ else
113
+ @split_name = split_last_comma_first_middle
114
+ end
110
115
  else
111
116
  @split_name = split_first_middle_last
112
117
  end
@@ -114,6 +119,11 @@ module HumanNameParser
114
119
  return self
115
120
  end
116
121
 
122
+ # check whether each part is a suffix
123
+ def suffix_follows_comma? name
124
+ name.split(',')[1].split(' ').all? {|part| is_suffix?(part)}
125
+ end
126
+
117
127
  def split_last_comma_first_middle
118
128
  match = @input_string.match(",")
119
129
  normalized = ""
@@ -1,3 +1,3 @@
1
1
  module HumanNameParser
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -45,6 +45,17 @@ describe HumanNameParser::Name do
45
45
  end
46
46
  end
47
47
 
48
+ context "when full name is Marley Mante, esq." do
49
+ let(:full_name) { "Marley Mante, esq." }
50
+ it "should parse the name" do
51
+ @name = HumanNameParser::Name.new full_name
52
+ @name.first.should == 'Marley'
53
+ @name.last.should == 'Mante'
54
+ @name.middle.should == ''
55
+ @name.suffix.should == 'esq.'
56
+ end
57
+ end
58
+
48
59
  context 'when full name is Mary Lou Smith' do
49
60
  let(:full_name) { "Mary Lou Smith" }
50
61
  before do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: human_name_parser
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Adam Bachman