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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8e5bd6a935818948438315fc5f7a1a2ff90e173
4
- data.tar.gz: c6b2f73fa732939faa8e0eef6c680d852374b7c2
3
+ metadata.gz: 5238d58c1fd96ae9b61193c2b4e6b64deb1a7866
4
+ data.tar.gz: c881c108d88814dcf2cb76dc610a3581cdfb5204
5
5
  SHA512:
6
- metadata.gz: dca80914cdbb4d1e6d254e51c2c9104ea18410424cd75663800564ac9c597cfe19c16651467cebc20883f4359b9e394ee23fbc0291cd6dad293c801db862ec84
7
- data.tar.gz: 4cfadfe895919caf36468c5dc2c243054db0be686f8a6bb8500c69f4f7b39aeb00e9c32e6d358eb088e6e39c36ce1f9eb2d3d2ebce5806f5618aa8ee41832b75
6
+ metadata.gz: ad2db97d850d80e73281f707b4d0a9ad27e1b23dd6d13ca5a389934a1c0cc1c73dfd5b20368c4b2306460216941ad55ac76d5a1f2e14f596c23a1dd0f46eeaba
7
+ data.tar.gz: e8817a9dcab4a62e7846b151b7bf9b45c5726ee409c1d01d54aa065ecce29a2ad7220e215a10d3ea4e32ad630a398fa5f50fb856b313830d48402e2eb303d2ac
@@ -7,4 +7,4 @@ CyclomaticComplexity:
7
7
  ClassLength:
8
8
  Description: 'Avoid classes longer than 100 lines of code.'
9
9
  CountComments: false # count full line comments?
10
- Max: 301
10
+ Max: 305
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- name-tamer (0.1.6)
4
+ name-tamer (0.1.7)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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é Descartes" -> "René Descartes"
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
- # Some companies like to be all lowercase so don't mess with them
182
- @nice_name = name_case(lowercase) if @nice_name == uppercase ||
183
- ( @nice_name == lowercase && @contact_type != :organization)
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 @last_name == uppercase || @last_name == lowercase
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
@@ -1,3 +1,3 @@
1
1
  class NameTamer
2
- VERSION = '0.1.7'
2
+ VERSION = '0.1.8'
3
3
  end
@@ -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: 'At&T', sn: 'At and T', s: 'at-and-t' },
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: 'I B M', t: :organization, nn: 'Ibm', sn: 'Ibm', s: 'ibm' },
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: name-tamer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xenapto