name-tamer 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/Gemfile.lock +1 -1
- data/lib/name-tamer.rb +11 -6
- data/lib/name-tamer/version.rb +1 -1
- data/spec/name_tamer_spec.rb +4 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5238d58c1fd96ae9b61193c2b4e6b64deb1a7866
|
4
|
+
data.tar.gz: c881c108d88814dcf2cb76dc610a3581cdfb5204
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad2db97d850d80e73281f707b4d0a9ad27e1b23dd6d13ca5a389934a1c0cc1c73dfd5b20368c4b2306460216941ad55ac76d5a1f2e14f596c23a1dd0f46eeaba
|
7
|
+
data.tar.gz: e8817a9dcab4a62e7846b151b7bf9b45c5726ee409c1d01d54aa065ecce29a2ad7220e215a10d3ea4e32ad630a398fa5f50fb856b313830d48402e2eb303d2ac
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/lib/name-tamer.rb
CHANGED
@@ -26,7 +26,7 @@ class NameTamer
|
|
26
26
|
@nice_name = name.dup # Start with the name we've received
|
27
27
|
|
28
28
|
tidy_spacing # " John Smith " -> "John Smith"
|
29
|
-
fix_encoding_errors # "Ren
|
29
|
+
fix_encoding_errors # "Ren\u00c3\u00a9 Descartes" -> "Ren\u00e9 Descartes"
|
30
30
|
consolidate_initials # "I. B. M." -> "I.B.M."
|
31
31
|
remove_adfixes # prefixes and suffixes: "Smith, John, Jr." -> "Smith, John"
|
32
32
|
fixup_last_name_first # "Smith, John" -> "John Smith"
|
@@ -177,15 +177,20 @@ class NameTamer
|
|
177
177
|
if @last_name.nil?
|
178
178
|
lowercase = @nice_name.downcase
|
179
179
|
uppercase = @nice_name.upcase
|
180
|
+
fix_case = false
|
180
181
|
|
181
|
-
|
182
|
-
|
183
|
-
|
182
|
+
if @contact_type == :organization
|
183
|
+
fix_case = true if @nice_name == uppercase && @nice_name.length > 4
|
184
|
+
else
|
185
|
+
fix_case = true if [uppercase, lowercase].include?(@nice_name)
|
186
|
+
end
|
187
|
+
|
188
|
+
@nice_name = name_case(lowercase) if fix_case
|
184
189
|
else
|
190
|
+
# It's a person if we've split the name, so no organization logic here
|
185
191
|
lowercase = @last_name.downcase
|
186
192
|
uppercase = @last_name.upcase
|
187
|
-
@last_name = name_case(lowercase) if
|
188
|
-
|
193
|
+
@last_name = name_case(lowercase) if [uppercase, lowercase].include?(@last_name)
|
189
194
|
@nice_name = "#{@remainder} #{@last_name}"
|
190
195
|
end
|
191
196
|
end
|
data/lib/name-tamer/version.rb
CHANGED
data/spec/name_tamer_spec.rb
CHANGED
@@ -88,7 +88,7 @@ describe NameTamer do
|
|
88
88
|
{ n: 'MACKENZIE, Doug', t: :person, nn: 'Doug Mackenzie', sn: 'Doug Mackenzie', s: 'doug-mackenzie' },
|
89
89
|
{ n: 'Up + Down', t: :organization, nn: 'Up + Down', sn: 'Up plus Down', s: 'up-plus-down' },
|
90
90
|
{ n: 'San Francisco Ltd', t: :organization, nn: 'San Francisco', sn: 'San Francisco', s: 'san-francisco' },
|
91
|
-
{ n: 'AT&T', t: :organization, nn: '
|
91
|
+
{ n: 'AT&T', t: :organization, nn: 'AT&T', sn: 'AT and T', s: 'at-and-t' },
|
92
92
|
{ n: 'SMITH, John, Jr.', t: :person, nn: 'John Smith', sn: 'John Smith', s: 'john-smith' },
|
93
93
|
{ n: 'I Heart Movies', t: :organization, nn: 'I Heart Movies', sn: 'I Heart Movies', s: 'i-heart-movies' },
|
94
94
|
{ n: 'Y Combinator', t: :organization, nn: 'Y Combinator', sn: 'Y Combinator', s: 'y-combinator' },
|
@@ -167,7 +167,8 @@ describe NameTamer do
|
|
167
167
|
{ n: 'Jose “Pepe” García', t: :organization, nn: 'Jose “Pepe” García', sn: 'Jose Pepe García',
|
168
168
|
s: 'jose-pepe-garcia' },
|
169
169
|
{ n: 'John Smith M.A. (Oxon)', t: :person, nn: 'John Smith', sn: 'John Smith', s: 'john-smith' },
|
170
|
-
{ n: '
|
170
|
+
{ n: 'IBM', t: :organization, nn: 'IBM', sn: 'IBM', s: 'ibm' },
|
171
|
+
{ n: 'I B M', t: :organization, nn: 'IBM', sn: 'IBM', s: 'ibm' },
|
171
172
|
{ n: 'I-B-M', t: :organization, nn: 'I-B-M', sn: 'I-B-M', s: 'i-b-m' },
|
172
173
|
{ n: 'I.B.M.', t: :organization, nn: 'I.B.M.', sn: 'IBM', s: 'ibm' },
|
173
174
|
{ n: 'Unusuals — the ad industry network', t: :organization,
|
@@ -186,7 +187,7 @@ describe NameTamer do
|
|
186
187
|
t: :person,
|
187
188
|
nn: 'René Descartes',
|
188
189
|
sn: 'René Descartes',
|
189
|
-
s:'rene-descartes'
|
190
|
+
s: 'rene-descartes'
|
190
191
|
}
|
191
192
|
]
|
192
193
|
end
|