name-tamer 0.1.8 → 0.1.9
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/.rubocop.yml +1 -1
- data/Gemfile.lock +1 -1
- data/lib/name-tamer.rb +15 -6
- data/lib/name-tamer/version.rb +1 -1
- 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: b556d5a36fcb89c56e435fd67a0f159987b7f8b9
|
4
|
+
data.tar.gz: 7ac8e5b948e6edb607f367d4d8303bb3c97c0d9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 215966db363f5630a1b53671c95792057deb29306a07e1cf93c1772700be4b3fc3e4f9cab40a1ba6d39f58813eddead3226d1faa2583aa21e3d73f41eb2c1403
|
7
|
+
data.tar.gz: 4d2bcd7d0f9b8556c548235c4d12ae0c92643399444a2ce70c5e9b8ef984577d54915827a86f4b243d3434775a1ddb37ccd1d0055b8645c56ab770bdba558613
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/lib/name-tamer.rb
CHANGED
@@ -21,13 +21,22 @@ class NameTamer
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
unless @
|
26
|
-
@
|
24
|
+
def tidy_name
|
25
|
+
unless @tidy_name
|
26
|
+
@tidy_name = name.dup # Start with the name we've received
|
27
27
|
|
28
28
|
tidy_spacing # " John Smith " -> "John Smith"
|
29
29
|
fix_encoding_errors # "Ren\u00c3\u00a9 Descartes" -> "Ren\u00e9 Descartes"
|
30
30
|
consolidate_initials # "I. B. M." -> "I.B.M."
|
31
|
+
end
|
32
|
+
|
33
|
+
@tidy_name
|
34
|
+
end
|
35
|
+
|
36
|
+
def nice_name
|
37
|
+
unless @nice_name
|
38
|
+
@nice_name = tidy_name.dup # Start with the tidied name
|
39
|
+
|
31
40
|
remove_adfixes # prefixes and suffixes: "Smith, John, Jr." -> "Smith, John"
|
32
41
|
fixup_last_name_first # "Smith, John" -> "John Smith"
|
33
42
|
fixup_mismatched_braces # "Ceres (AZ" -> "Ceres (AZ)"
|
@@ -103,19 +112,19 @@ class NameTamer
|
|
103
112
|
#--------------------------------------------------------
|
104
113
|
|
105
114
|
def tidy_spacing
|
106
|
-
@
|
115
|
+
@tidy_name
|
107
116
|
.space_after_comma!
|
108
117
|
.strip_or_self!
|
109
118
|
.whitespace_to!(ASCII_SPACE)
|
110
119
|
end
|
111
120
|
|
112
121
|
def fix_encoding_errors
|
113
|
-
@
|
122
|
+
@tidy_name.fix_encoding_errors!
|
114
123
|
end
|
115
124
|
|
116
125
|
# Remove spaces from groups of initials
|
117
126
|
def consolidate_initials
|
118
|
-
@
|
127
|
+
@tidy_name
|
119
128
|
.remove_spaces_from_initials!
|
120
129
|
.ensure_space_after_initials!
|
121
130
|
end
|
data/lib/name-tamer/version.rb
CHANGED