name-tamer 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +14 -12
- data/lib/name-tamer.rb +7 -6
- data/lib/name-tamer/version.rb +1 -1
- data/lib/string_extras.rb +5 -0
- data/spec/name_tamer_spec.rb +3 -1
- data/spec/spec_helper.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ab141545fd0a40633767d4bbec43fd9170a4023
|
4
|
+
data.tar.gz: c2ad25c3863f39082990e4cb1d2c51c2edae8456
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63b3be31c544c28c1de9d9ce0faa243622438db313701273fcf382799bef138d11588841811f16cc7b85df016b3cbdf8e9a79fd69282104ccf8dc907a6dbef2b
|
7
|
+
data.tar.gz: cf0cfeaa251ea8942f43d91ba75abb41575a9476f2907735b0b285ada2c5dfc42326d550b17c125fb463e372b9e31d38705d88a958f61de9a00054b5879511b4
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
name-tamer (0.1.
|
4
|
+
name-tamer (0.1.4)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -13,24 +13,26 @@ GEM
|
|
13
13
|
term-ansicolor
|
14
14
|
thor
|
15
15
|
diff-lcs (1.2.5)
|
16
|
+
docile (1.1.5)
|
16
17
|
gem-release (0.7.3)
|
17
18
|
mime-types (2.3)
|
18
19
|
multi_json (1.10.1)
|
19
20
|
rake (10.3.2)
|
20
21
|
rest-client (1.6.7)
|
21
22
|
mime-types (>= 1.16)
|
22
|
-
rspec (2.
|
23
|
-
rspec-core (~> 2.
|
24
|
-
rspec-expectations (~> 2.
|
25
|
-
rspec-mocks (~> 2.
|
26
|
-
rspec-core (2.
|
27
|
-
rspec-expectations (2.
|
23
|
+
rspec (2.99.0)
|
24
|
+
rspec-core (~> 2.99.0)
|
25
|
+
rspec-expectations (~> 2.99.0)
|
26
|
+
rspec-mocks (~> 2.99.0)
|
27
|
+
rspec-core (2.99.1)
|
28
|
+
rspec-expectations (2.99.1)
|
28
29
|
diff-lcs (>= 1.1.3, < 2.0)
|
29
|
-
rspec-mocks (2.
|
30
|
-
simplecov (0.
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
rspec-mocks (2.99.1)
|
31
|
+
simplecov (0.8.2)
|
32
|
+
docile (~> 1.1.0)
|
33
|
+
multi_json
|
34
|
+
simplecov-html (~> 0.8.0)
|
35
|
+
simplecov-html (0.8.0)
|
34
36
|
term-ansicolor (1.3.0)
|
35
37
|
tins (~> 1.0)
|
36
38
|
thor (0.19.1)
|
data/lib/name-tamer.rb
CHANGED
@@ -42,10 +42,10 @@ class NameTamer
|
|
42
42
|
unless @simple_name
|
43
43
|
@simple_name = nice_name.dup # Start with nice name
|
44
44
|
|
45
|
-
remove_initials
|
46
|
-
remove_middle_names
|
47
|
-
|
48
|
-
standardize_words
|
45
|
+
remove_initials # "John Q. Doe" -> "John Doe"
|
46
|
+
remove_middle_names # "Philip Seymour Hoffman" -> "Philip Hoffman"
|
47
|
+
remove_periods_from_initials # "J.P.R. Williams" -> "JPR Williams"
|
48
|
+
standardize_words # "B&Q Intl" -> "B and Q International"
|
49
49
|
|
50
50
|
@simple_name.whitespace_to!(ASCII_SPACE)
|
51
51
|
end
|
@@ -236,14 +236,15 @@ class NameTamer
|
|
236
236
|
@simple_name = "#{first_name}#{separator}#{last_name}"
|
237
237
|
end
|
238
238
|
|
239
|
-
def
|
240
|
-
@simple_name.
|
239
|
+
def remove_periods_from_initials
|
240
|
+
@simple_name.remove_periods_from_initials!
|
241
241
|
end
|
242
242
|
|
243
243
|
def standardize_words
|
244
244
|
@simple_name.gsub!(/ *& */, ' and ') # replace ampersand characters with ' and '
|
245
245
|
@simple_name.gsub!(/ *\+ */, ' plus ') # replace plus signs with ' plus '
|
246
246
|
@simple_name.gsub!(/\bintl\b/i, 'International') # replace 'intl' with 'International'
|
247
|
+
@simple_name.gsub!(/["“”]/, '') # remove quotes
|
247
248
|
end
|
248
249
|
|
249
250
|
#--------------------------------------------------------
|
data/lib/name-tamer/version.rb
CHANGED
data/lib/string_extras.rb
CHANGED
@@ -129,6 +129,11 @@ class String
|
|
129
129
|
self # Allows chaining
|
130
130
|
end
|
131
131
|
|
132
|
+
def remove_periods_from_initials!
|
133
|
+
self.gsub!(/\b([a-z])\./i) { |_| Regexp.last_match[1] }
|
134
|
+
self # Allows chaining
|
135
|
+
end
|
136
|
+
|
132
137
|
def remove_spaces_from_initials!
|
133
138
|
self.gsub!(/\b([a-z])(\.)* \b(?![a-z0-9']{2,})/i) { |_| "#{Regexp.last_match[1]}#{Regexp.last_match[2]}" }
|
134
139
|
self # Allows chaining
|
data/spec/name_tamer_spec.rb
CHANGED
@@ -139,7 +139,7 @@ describe NameTamer do
|
|
139
139
|
{ n: '* Shorusan *', t: :organization, nn: '* Shorusan *', sn: '* Shorusan *', s: 'shorusan' },
|
140
140
|
{ n: '项目谷', t: :organization, nn: '项目谷', sn: '项目谷', s: '项目谷' },
|
141
141
|
{ n: 'ООО "Инновационные полимерные адгезивы"', t: :organization, nn: 'ООО "Инновационные полимерные адгезивы"',
|
142
|
-
sn: 'ООО
|
142
|
+
sn: 'ООО Инновационные полимерные адгезивы', s: 'ООО-Инновационные-полимерные-адгезивы' },
|
143
143
|
{ n: 'عبدالله ...', t: :organization, nn: 'عبدالله ...', sn: 'عبدالله ...', s: 'عبدالله' },
|
144
144
|
{ n: 'กมลชนก ทิศไธสง', t: :organization, nn: 'กมลชนก ทิศไธสง', sn: 'กมลชนก ทิศไธสง', s: 'กมลชนก-ทิศไธสง' },
|
145
145
|
{ n: 'יוֹ אָב', t: :organization, nn: 'יוֹ אָב', sn: 'יוֹ אָב', s: 'יוֹ-אָב' },
|
@@ -164,6 +164,8 @@ describe NameTamer do
|
|
164
164
|
{ n: '* *', t: :person, nn: '* *', sn: '* *', s: '_' },
|
165
165
|
{ n: '* Olga *', t: :person, nn: '* Olga *', sn: 'Olga', s: 'olga' },
|
166
166
|
{ n: '* Olga Bedia García *', t: :person, nn: '* Olga Bedia García *', sn: 'Olga García', s: 'olga-garcia' },
|
167
|
+
{ n: 'Jose “Pepe” García', t: :organization, nn: 'Jose “Pepe” García', sn: 'Jose Pepe García',
|
168
|
+
s: 'jose-pepe-garcia' },
|
167
169
|
{ n: 'John Smith M.A. (Oxon)', t: :person, nn: 'John Smith', sn: 'John Smith', s: 'john-smith' },
|
168
170
|
{ n: 'I B M', t: :organization, nn: 'Ibm', sn: 'Ibm', s: 'ibm' },
|
169
171
|
{ n: 'I-B-M', t: :organization, nn: 'I-B-M', sn: 'I-B-M', s: 'i-b-m' },
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: name-tamer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xenapto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|