sixarm_ruby_person_name 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/Rakefile +2 -2
- data/lib/sixarm_ruby_person_name/person_name.rb +214 -69
- data/lib/sixarm_ruby_person_name.rb +1 -117
- data/test/sixarm_ruby_person_name_test/person_name_test.rb +375 -145
- data.tar.gz.sig +0 -0
- metadata +29 -9
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf8d14df93390d9604627934329e510293182862
|
4
|
+
data.tar.gz: 0d16842a9e0bba13d330e91d526cea71bcf2e2c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d5046fdb373f86177fa9e0d54505cded83bd74b2a6eab36c18076298cdb46f3d64d8c43734971780183a6219a5ce9e572ba859c4bb8b08be3f42656ce3b1bb6
|
7
|
+
data.tar.gz: 1707dd04393c2c9f25babf3277c0a37ccf140f82d9d3137c5fc639df386635da84792126867335720b2d0b5284311ed1c4271396b365a87dc6f772fc44b9dd7f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/Rakefile
CHANGED
@@ -3,120 +3,265 @@
|
|
3
3
|
Please see README
|
4
4
|
=end
|
5
5
|
|
6
|
-
|
7
6
|
module PersonName
|
8
7
|
|
8
|
+
###
|
9
|
+
#
|
10
|
+
# Boolean methods
|
11
|
+
#
|
12
|
+
###
|
9
13
|
|
10
|
-
#
|
14
|
+
# Does the person have a given name?
|
15
|
+
#
|
16
|
+
# Example:
|
17
|
+
#
|
18
|
+
# user.given_name = "Martin"
|
19
|
+
# user.given_name?
|
20
|
+
# => true
|
21
|
+
#
|
22
|
+
# @return true iff the person has a given name and its non-blank.
|
23
|
+
#
|
24
|
+
def given_name?
|
25
|
+
!!(respond_to?(:given_name) && given_name && given_name!='' && given_name.strip!='')
|
26
|
+
end
|
11
27
|
|
28
|
+
# Does the person have a first name?
|
29
|
+
#
|
30
|
+
# Example:
|
31
|
+
#
|
32
|
+
# user.first_name = "Martin"
|
33
|
+
# user.first_name?
|
34
|
+
# => true
|
35
|
+
#
|
36
|
+
# @return true iff the person has a first name and its non-blank.
|
37
|
+
#
|
12
38
|
def first_name?
|
13
|
-
|
39
|
+
!!(respond_to?(:first_name) && first_name && first_name!='' && first_name.strip!='')
|
14
40
|
end
|
15
41
|
|
16
|
-
|
17
|
-
#
|
18
|
-
|
42
|
+
# Does the person have a middle name?
|
43
|
+
#
|
44
|
+
# Example:
|
45
|
+
#
|
46
|
+
# user.middle_name = "Luther"
|
47
|
+
# user.middle_name?
|
48
|
+
# => true
|
49
|
+
#
|
50
|
+
# @return true iff the person has a middle name and its non-blank.
|
51
|
+
#
|
19
52
|
def middle_name?
|
20
|
-
|
53
|
+
!!(respond_to?(:middle_name) && middle_name && middle_name!='' && middle_name.strip!='')
|
21
54
|
end
|
22
55
|
|
56
|
+
# Does the person have a family name?
|
57
|
+
#
|
58
|
+
# Example:
|
59
|
+
#
|
60
|
+
# user.family_name = "King"
|
61
|
+
# user.family_name?
|
62
|
+
# => true
|
63
|
+
#
|
64
|
+
# @return true iff the person has a family name and its non-blank.
|
65
|
+
#
|
66
|
+
def family_name?
|
67
|
+
!!(respond_to?(:family_name) && family_name && family_name!='' && family_name.strip!='')
|
68
|
+
end
|
23
69
|
|
24
|
-
#
|
25
|
-
|
70
|
+
# Does the person have a last name?
|
71
|
+
#
|
72
|
+
# Example:
|
73
|
+
#
|
74
|
+
# user.last_name = "King"
|
75
|
+
# user.last_name?
|
76
|
+
# => true
|
77
|
+
#
|
78
|
+
# Return true iff the person has a last name and its non-blank.
|
79
|
+
#
|
26
80
|
def last_name?
|
27
|
-
|
81
|
+
!!(respond_to?(:last_name) && last_name && last_name!='' && last_name.strip!='')
|
28
82
|
end
|
29
83
|
|
30
|
-
|
31
|
-
# Return the person's first name + middle name
|
84
|
+
###
|
32
85
|
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
|
36
|
-
|
86
|
+
# Concatenation methods
|
87
|
+
#
|
88
|
+
###
|
89
|
+
|
90
|
+
# Get the person's full name.
|
91
|
+
#
|
92
|
+
# Example:
|
93
|
+
#
|
94
|
+
# user.full_name => "Martin Luther King"
|
95
|
+
#
|
96
|
+
# This method skips any piece of the name that is missing or blank.
|
97
|
+
#
|
98
|
+
# @return the person's full name
|
99
|
+
#
|
100
|
+
def full_name
|
37
101
|
pieces = []
|
38
|
-
|
39
|
-
|
102
|
+
if given_name?
|
103
|
+
pieces << given_name
|
104
|
+
elsif first_name?
|
105
|
+
pieces << first_name
|
106
|
+
end
|
107
|
+
if middle_name?
|
108
|
+
pieces << middle_name
|
109
|
+
end
|
110
|
+
if family_name?
|
111
|
+
pieces << family_name
|
112
|
+
elsif last_name?
|
113
|
+
pieces << last_name
|
114
|
+
end
|
40
115
|
return pieces.join(' ')
|
41
116
|
end
|
42
117
|
|
118
|
+
# Get the person's list name.
|
119
|
+
#
|
120
|
+
# Example:
|
121
|
+
#
|
122
|
+
# user.list_name => "King, Martin Luther"
|
123
|
+
#
|
124
|
+
# This method skips any piece of the name that is missing or blank.
|
125
|
+
#
|
126
|
+
# @teturn the person's list name
|
127
|
+
#
|
128
|
+
def list_name
|
129
|
+
left_pieces = []
|
130
|
+
right_pieces = []
|
131
|
+
if family_name?
|
132
|
+
left_pieces << family_name
|
133
|
+
elsif last_name?
|
134
|
+
left_pieces << last_name
|
135
|
+
end
|
136
|
+
if given_name?
|
137
|
+
right_pieces << given_name
|
138
|
+
elsif first_name?
|
139
|
+
right_pieces << first_name
|
140
|
+
end
|
141
|
+
if middle_name?
|
142
|
+
right_pieces << middle_name
|
143
|
+
end
|
144
|
+
return left_pieces.join(' ') + (!left_pieces.empty? && !right_pieces.empty? ? ", " : '') + right_pieces.join(' ')
|
145
|
+
end
|
43
146
|
|
44
|
-
#
|
147
|
+
# Get the person's intials
|
148
|
+
#
|
149
|
+
# Example:
|
45
150
|
#
|
46
|
-
#
|
47
|
-
#
|
151
|
+
# user.initials => "MLK"
|
152
|
+
#
|
153
|
+
# This method skips any piece of the name that is missing or blank.
|
154
|
+
#
|
155
|
+
# @return the person's intials
|
156
|
+
#
|
157
|
+
def initials
|
158
|
+
s = ""
|
159
|
+
if given_name?
|
160
|
+
s << given_name[0]
|
161
|
+
elsif first_name?
|
162
|
+
s << first_name[0]
|
163
|
+
end
|
164
|
+
if middle_name?
|
165
|
+
s << middle_name[0]
|
166
|
+
end
|
167
|
+
if family_name?
|
168
|
+
s << family_name[0]
|
169
|
+
elsif last_name?
|
170
|
+
s << last_name[0]
|
171
|
+
end
|
172
|
+
return s
|
173
|
+
end
|
48
174
|
|
49
|
-
|
175
|
+
# Get the person's given name + middle name
|
176
|
+
#
|
177
|
+
# Example:
|
178
|
+
#
|
179
|
+
# user.given_name_middle_name => "Martin Luther"
|
180
|
+
#
|
181
|
+
# @return the person's given name + middle name
|
182
|
+
#
|
183
|
+
def given_name_middle_name
|
50
184
|
pieces = []
|
51
|
-
(pieces <<
|
52
|
-
(pieces << middle_name
|
185
|
+
(pieces << given_name) if given_name?
|
186
|
+
(pieces << middle_name) if middle_name?
|
53
187
|
return pieces.join(' ')
|
54
188
|
end
|
55
189
|
|
56
|
-
|
57
|
-
# Return the person's first name + middle initial + last name
|
190
|
+
# Get the person's first name + middle name
|
58
191
|
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
192
|
+
# Example:
|
193
|
+
#
|
194
|
+
# user.first_name_middle_name => "Martin Luther"
|
195
|
+
#
|
196
|
+
# @return the person's first name + middle name
|
197
|
+
#
|
198
|
+
def first_name_middle_name
|
199
|
+
pieces = []
|
200
|
+
(pieces << first_name) if first_name?
|
201
|
+
(pieces << middle_name) if middle_name?
|
67
202
|
return pieces.join(' ')
|
68
203
|
end
|
69
204
|
|
70
|
-
|
71
|
-
# Return the person's full name: first_name middle_name last_name
|
205
|
+
# Get the person's given name + middle initial
|
72
206
|
#
|
73
|
-
#
|
74
|
-
# u.full_name => "Martin Luther King"
|
207
|
+
# Example:
|
75
208
|
#
|
76
|
-
#
|
77
|
-
|
78
|
-
|
209
|
+
# user.first_name_middle_initial => "Martin L"
|
210
|
+
#
|
211
|
+
# @return the person's given name + middle initial
|
212
|
+
#
|
213
|
+
def given_name_middle_initial
|
79
214
|
pieces = []
|
80
|
-
(pieces <<
|
81
|
-
(pieces << middle_name)
|
82
|
-
(pieces << last_name) if last_name?
|
215
|
+
(pieces << given_name) if given_name?
|
216
|
+
(pieces << middle_name[0...1]) if middle_name?
|
83
217
|
return pieces.join(' ')
|
84
218
|
end
|
85
219
|
|
86
|
-
|
87
|
-
# Return the person's list name: last_name, first_name middle_name
|
220
|
+
# Get the person's first name + middle initial
|
88
221
|
#
|
89
|
-
#
|
90
|
-
# u.list_name => "King, Martin Luther"
|
222
|
+
# Example:
|
91
223
|
#
|
92
|
-
#
|
93
|
-
|
94
|
-
|
224
|
+
# user.first_name_middle_initial => "Martin L"
|
225
|
+
#
|
226
|
+
# @return the person's first name + middle initial
|
227
|
+
#
|
228
|
+
def first_name_middle_initial
|
95
229
|
pieces = []
|
96
|
-
(pieces << first_name)
|
97
|
-
(pieces << middle_name)
|
98
|
-
if last_name?
|
99
|
-
comma = pieces.size>0 ? ',' : ''
|
100
|
-
pieces.unshift(last_name+comma)
|
101
|
-
end
|
230
|
+
(pieces << first_name) if first_name?
|
231
|
+
(pieces << middle_name[0...1]) if middle_name?
|
102
232
|
return pieces.join(' ')
|
103
233
|
end
|
104
234
|
|
105
|
-
|
106
|
-
# Return the person's intials
|
235
|
+
# Get the person's given name + middle initial + family name
|
107
236
|
#
|
108
|
-
#
|
109
|
-
# u.initials => "MLK"
|
237
|
+
# Example:
|
110
238
|
#
|
111
|
-
#
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
(
|
118
|
-
|
239
|
+
# user.given_name_middle_initial_family_name => "Martin L King"
|
240
|
+
#
|
241
|
+
# @return the person's given name + middle initial + family name
|
242
|
+
#
|
243
|
+
def given_name_middle_initial_family_name
|
244
|
+
pieces = []
|
245
|
+
(pieces << given_name) if given_name?
|
246
|
+
(pieces << middle_name[0...1]) if middle_name?
|
247
|
+
(pieces << family_name) if family_name?
|
248
|
+
return pieces.join(' ')
|
119
249
|
end
|
120
250
|
|
251
|
+
# Get the person's first name + middle initial + last name
|
252
|
+
#
|
253
|
+
# Example:
|
254
|
+
#
|
255
|
+
# u.first_name_middle_initial_family_name => "Martin N King"
|
256
|
+
#
|
257
|
+
# @return the person's first name + middle initial + last name
|
258
|
+
#
|
259
|
+
def first_name_middle_initial_last_name
|
260
|
+
pieces = []
|
261
|
+
(pieces << first_name) if first_name?
|
262
|
+
(pieces << middle_name[0...1]) if middle_name?
|
263
|
+
(pieces << last_name) if last_name?
|
264
|
+
return pieces.join(' ')
|
265
|
+
end
|
121
266
|
|
122
267
|
end
|
@@ -3,120 +3,4 @@
|
|
3
3
|
Please see README
|
4
4
|
=end
|
5
5
|
|
6
|
-
|
7
|
-
module PersonName
|
8
|
-
|
9
|
-
|
10
|
-
# Return true iff the person has a first name and its non-blank
|
11
|
-
|
12
|
-
def first_name?
|
13
|
-
respond_to?(:first_name) and first_name and first_name!='' and first_name.strip!=''
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
# Return true iff the person has a middle name and its non-blank
|
18
|
-
|
19
|
-
def middle_name?
|
20
|
-
respond_to?(:middle_name) and middle_name and middle_name!='' and middle_name.strip!=''
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
# Return true iff the person has a last name and its non-blank
|
25
|
-
|
26
|
-
def last_name?
|
27
|
-
respond_to?(:last_name) and last_name and last_name!='' and last_name.strip!=''
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
# Return the person's first name + middle name
|
32
|
-
#
|
33
|
-
# ==Example
|
34
|
-
# u.first_name_middle_name => "Martin Luther"
|
35
|
-
|
36
|
-
def first_name_middle_name
|
37
|
-
pieces = []
|
38
|
-
(pieces << first_name) if first_name?
|
39
|
-
(pieces << middle_name) if middle_name?
|
40
|
-
return pieces.join(' ')
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
# Return the person's first name + middle initial
|
45
|
-
#
|
46
|
-
# ==Example
|
47
|
-
# u.first_name_middle_initial => "Martin N"
|
48
|
-
|
49
|
-
def first_name_middle_initial
|
50
|
-
pieces = []
|
51
|
-
(pieces << first_name) if first_name?
|
52
|
-
(pieces << middle_name[0...1]) if middle_name?
|
53
|
-
return pieces.join(' ')
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
# Return the person's first name + middle initial + last name
|
58
|
-
#
|
59
|
-
# ==Example
|
60
|
-
# u.first_name_middle_initial_last_name => "Martin N King"
|
61
|
-
|
62
|
-
def first_name_middle_initial_last_name
|
63
|
-
pieces = []
|
64
|
-
(pieces << first_name) if first_name?
|
65
|
-
(pieces << middle_name[0...1]) if middle_name?
|
66
|
-
(pieces << last_name) if last_name?
|
67
|
-
return pieces.join(' ')
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
# Return the person's full name: first_name middle_name last_name
|
72
|
-
#
|
73
|
-
# ==Example
|
74
|
-
# u.full_name => "Martin Luther King"
|
75
|
-
#
|
76
|
-
# This method skips any piece of the name that is missing or blank.
|
77
|
-
|
78
|
-
def full_name
|
79
|
-
pieces = []
|
80
|
-
(pieces << first_name) if first_name?
|
81
|
-
(pieces << middle_name) if middle_name?
|
82
|
-
(pieces << last_name) if last_name?
|
83
|
-
return pieces.join(' ')
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
# Return the person's list name: last_name, first_name middle_name
|
88
|
-
#
|
89
|
-
# ==Example
|
90
|
-
# u.list_name => "King, Martin Luther"
|
91
|
-
#
|
92
|
-
# This method skips any piece of the name that is missing or blank.
|
93
|
-
|
94
|
-
def list_name
|
95
|
-
pieces = []
|
96
|
-
(pieces << first_name) if first_name?
|
97
|
-
(pieces << middle_name) if middle_name?
|
98
|
-
if last_name?
|
99
|
-
comma = pieces.size>0 ? ',' : ''
|
100
|
-
pieces.unshift(last_name+comma)
|
101
|
-
end
|
102
|
-
return pieces.join(' ')
|
103
|
-
end
|
104
|
-
|
105
|
-
|
106
|
-
# Return the person's intials
|
107
|
-
#
|
108
|
-
# ==Example
|
109
|
-
# u.initials => "MLK"
|
110
|
-
#
|
111
|
-
# This method skips any piece of the name that is missing or blank.
|
112
|
-
|
113
|
-
def initials
|
114
|
-
s = ""
|
115
|
-
(s << first_name[0]) if first_name?
|
116
|
-
(s << middle_name[0]) if middle_name?
|
117
|
-
(s << last_name[0]) if last_name?
|
118
|
-
return s
|
119
|
-
end
|
120
|
-
|
121
|
-
|
122
|
-
end
|
6
|
+
require "sixarm_ruby_person_name/person_name"
|
@@ -5,204 +5,430 @@ describe PersonName do
|
|
5
5
|
|
6
6
|
include PersonName
|
7
7
|
|
8
|
-
|
9
|
-
F ||= Person.new("abc", nil, nil) # First name
|
10
|
-
M ||= Person.new( nil, "def", nil) # Middle name
|
11
|
-
L ||= Person.new( nil, nil, "ghi") # Last name
|
12
|
-
FM ||= Person.new("abc", "def", nil) # First name & Middle name
|
13
|
-
FL ||= Person.new("abc", nil, "ghi") # First name & Last name
|
14
|
-
ML ||= Person.new( nil, "def", "ghi") # Middle name & Last name
|
15
|
-
FML ||= Person.new("abc", "def", "ghi") # First name & Middle name & Last name
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "#first_name_middle_name" do
|
8
|
+
describe "boolean methods" do
|
19
9
|
|
20
|
-
|
21
|
-
|
10
|
+
before do
|
11
|
+
@p = Person.new
|
22
12
|
end
|
23
13
|
|
24
|
-
|
25
|
-
|
14
|
+
describe "#given_name?" do
|
15
|
+
it "works" do
|
16
|
+
expect(@p.given_name?).must_be_same_as false
|
17
|
+
@p.given_name = "x"
|
18
|
+
expect(@p.given_name?).must_be_same_as true
|
19
|
+
end
|
26
20
|
end
|
27
21
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
22
|
+
describe "#first_name?" do
|
23
|
+
it "works" do
|
24
|
+
expect(@p.first_name?).must_be_same_as false
|
25
|
+
@p.first_name = "x"
|
26
|
+
expect(@p.first_name?).must_be_same_as true
|
27
|
+
end
|
34
28
|
end
|
35
29
|
|
36
|
-
|
37
|
-
|
30
|
+
describe "#middle_name?" do
|
31
|
+
it "works" do
|
32
|
+
expect(@p.middle_name?).must_be_same_as false
|
33
|
+
@p.middle_name = "x"
|
34
|
+
expect(@p.middle_name?).must_be_same_as true
|
35
|
+
end
|
38
36
|
end
|
39
37
|
|
40
|
-
|
41
|
-
|
38
|
+
describe "#family_name?" do
|
39
|
+
it "works" do
|
40
|
+
expect(@p.family_name?).must_be_same_as false
|
41
|
+
@p.family_name = "x"
|
42
|
+
expect(@p.family_name?).must_be_same_as true
|
43
|
+
end
|
42
44
|
end
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
+
describe "#last_name?" do
|
47
|
+
it "works" do
|
48
|
+
expect(@p.last_name?).must_be_same_as false
|
49
|
+
@p.last_name = "x"
|
50
|
+
expect(@p.last_name?).must_be_same_as true
|
51
|
+
end
|
46
52
|
end
|
47
53
|
|
48
54
|
end
|
55
|
+
|
56
|
+
describe "concatenation methods" do
|
49
57
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
58
|
+
before do
|
59
|
+
GIVEN ||= Person.new(given_name: "Given")
|
60
|
+
FIRST ||= Person.new(first_name: "First")
|
61
|
+
MIDDLE ||= Person.new(middle_name: "Middle")
|
62
|
+
FAMILY ||= Person.new(family_name: "Family")
|
63
|
+
LAST ||= Person.new(last_name: "Last")
|
64
|
+
GIVEN_MIDDLE ||= Person.new(given_name: "Given", middle_name: "Middle")
|
65
|
+
FIRST_MIDDLE ||= Person.new(first_name: "First", middle_name: "Middle")
|
66
|
+
GIVEN_FAMILY ||= Person.new(given_name: "Given", family_name: "Family")
|
67
|
+
FIRST_LAST ||= Person.new(first_name: "First", last_name: "Last")
|
68
|
+
MIDDLE_FAMILY ||= Person.new(middle_name: "Middle", family_name: "Family")
|
69
|
+
MIDDLE_LAST ||= Person.new(middle_name: "Middle", last_name: "Last")
|
70
|
+
GIVEN_MIDDLE_FAMILY ||= Person.new(given_name: "Given", middle_name: "Middle", family_name: "Family")
|
71
|
+
FIRST_MIDDLE_LAST ||= Person.new(first_name: "First", middle_name: "Middle", last_name: "Last")
|
54
72
|
end
|
55
73
|
|
56
|
-
|
57
|
-
M.first_name_middle_initial.must_equal("d")
|
58
|
-
end
|
74
|
+
describe "#full_name" do
|
59
75
|
|
60
|
-
|
61
|
-
|
62
|
-
|
76
|
+
it "with given" do
|
77
|
+
GIVEN.full_name.must_equal("Given")
|
78
|
+
end
|
63
79
|
|
64
|
-
|
65
|
-
|
66
|
-
|
80
|
+
it "with first" do
|
81
|
+
FIRST.full_name.must_equal("First")
|
82
|
+
end
|
67
83
|
|
68
|
-
|
69
|
-
|
70
|
-
|
84
|
+
it "with middle" do
|
85
|
+
MIDDLE.full_name.must_equal("Middle")
|
86
|
+
end
|
87
|
+
|
88
|
+
it "with family" do
|
89
|
+
FAMILY.full_name.must_equal("Family")
|
90
|
+
end
|
71
91
|
|
72
|
-
|
73
|
-
|
74
|
-
|
92
|
+
it "with last" do
|
93
|
+
LAST.full_name.must_equal("Last")
|
94
|
+
end
|
75
95
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
|
-
describe "#first_name_middle_initial_last_name" do
|
96
|
+
it "with given & middle" do
|
97
|
+
GIVEN_MIDDLE.full_name.must_equal("Given Middle")
|
98
|
+
end
|
83
99
|
|
84
|
-
|
85
|
-
|
86
|
-
|
100
|
+
it "with first & middle" do
|
101
|
+
FIRST_MIDDLE.full_name.must_equal("First Middle")
|
102
|
+
end
|
87
103
|
|
88
|
-
|
89
|
-
|
90
|
-
|
104
|
+
it "with given & family" do
|
105
|
+
GIVEN_FAMILY.full_name.must_equal("Given Family")
|
106
|
+
end
|
91
107
|
|
92
|
-
|
93
|
-
|
94
|
-
|
108
|
+
it "with first & last" do
|
109
|
+
FIRST_LAST.full_name.must_equal("First Last")
|
110
|
+
end
|
95
111
|
|
96
|
-
|
97
|
-
|
98
|
-
|
112
|
+
it "with middle & family" do
|
113
|
+
MIDDLE_FAMILY.full_name.must_equal("Middle Family")
|
114
|
+
end
|
99
115
|
|
100
|
-
|
101
|
-
|
102
|
-
|
116
|
+
it "with middle & last" do
|
117
|
+
MIDDLE_LAST.full_name.must_equal("Middle Last")
|
118
|
+
end
|
103
119
|
|
104
|
-
|
105
|
-
|
106
|
-
|
120
|
+
it "with given & middle & family" do
|
121
|
+
GIVEN_MIDDLE_FAMILY.full_name.must_equal("Given Middle Family")
|
122
|
+
end
|
123
|
+
|
124
|
+
it "with first & middle & last" do
|
125
|
+
FIRST_MIDDLE_LAST.full_name.must_equal("First Middle Last")
|
126
|
+
end
|
107
127
|
|
108
|
-
it "with first & middle &_last" do
|
109
|
-
FML.first_name_middle_initial_last_name.must_equal("abc d ghi")
|
110
128
|
end
|
111
129
|
|
112
|
-
|
130
|
+
describe "#list_name" do
|
113
131
|
|
114
|
-
|
132
|
+
it "with given" do
|
133
|
+
GIVEN.list_name.must_equal("Given")
|
134
|
+
end
|
115
135
|
|
116
|
-
|
117
|
-
|
118
|
-
|
136
|
+
it "with first" do
|
137
|
+
FIRST.list_name.must_equal("First")
|
138
|
+
end
|
119
139
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
it "with last" do
|
125
|
-
L.full_name.must_equal("ghi")
|
126
|
-
end
|
140
|
+
it "with middle" do
|
141
|
+
MIDDLE.list_name.must_equal("Middle")
|
142
|
+
end
|
127
143
|
|
128
|
-
|
129
|
-
|
130
|
-
|
144
|
+
it "with family" do
|
145
|
+
FAMILY.list_name.must_equal("Family")
|
146
|
+
end
|
131
147
|
|
132
|
-
|
133
|
-
|
134
|
-
|
148
|
+
it "with last" do
|
149
|
+
LAST.list_name.must_equal("Last")
|
150
|
+
end
|
135
151
|
|
136
|
-
|
137
|
-
|
138
|
-
|
152
|
+
it "with given & middle" do
|
153
|
+
GIVEN_MIDDLE.list_name.must_equal("Given Middle")
|
154
|
+
end
|
139
155
|
|
140
|
-
|
141
|
-
|
142
|
-
|
156
|
+
it "with first & middle" do
|
157
|
+
FIRST_MIDDLE.list_name.must_equal("First Middle")
|
158
|
+
end
|
143
159
|
|
144
|
-
|
160
|
+
it "with given & family" do
|
161
|
+
GIVEN_FAMILY.list_name.must_equal("Family, Given")
|
162
|
+
end
|
145
163
|
|
146
|
-
|
164
|
+
it "with first & last" do
|
165
|
+
FIRST_LAST.list_name.must_equal("Last, First")
|
166
|
+
end
|
147
167
|
|
148
|
-
|
149
|
-
|
150
|
-
|
168
|
+
it "with middle & family" do
|
169
|
+
MIDDLE_FAMILY.list_name.must_equal("Family, Middle")
|
170
|
+
end
|
151
171
|
|
152
|
-
|
153
|
-
|
154
|
-
|
172
|
+
it "with middle & last" do
|
173
|
+
MIDDLE_LAST.list_name.must_equal("Last, Middle")
|
174
|
+
end
|
155
175
|
|
156
|
-
|
157
|
-
|
158
|
-
|
176
|
+
it "with given & middle & family" do
|
177
|
+
GIVEN_MIDDLE_FAMILY.list_name.must_equal("Family, Given Middle")
|
178
|
+
end
|
159
179
|
|
160
|
-
|
161
|
-
|
162
|
-
|
180
|
+
it "with first & middle & last" do
|
181
|
+
FIRST_MIDDLE_LAST.list_name.must_equal("Last, First Middle")
|
182
|
+
end
|
163
183
|
|
164
|
-
it "with first & last" do
|
165
|
-
FL.list_name.must_equal("ghi, abc")
|
166
184
|
end
|
167
185
|
|
168
|
-
|
169
|
-
ML.list_name.must_equal("ghi, def")
|
170
|
-
end
|
186
|
+
describe "#initials" do
|
171
187
|
|
172
|
-
|
173
|
-
|
174
|
-
|
188
|
+
it "with given" do
|
189
|
+
GIVEN.initials.must_equal("G")
|
190
|
+
end
|
175
191
|
|
176
|
-
|
192
|
+
it "with first" do
|
193
|
+
FIRST.initials.must_equal("F")
|
194
|
+
end
|
195
|
+
|
196
|
+
it "with middle" do
|
197
|
+
MIDDLE.initials.must_equal("M")
|
198
|
+
end
|
199
|
+
|
200
|
+
it "with family" do
|
201
|
+
FAMILY.initials.must_equal("F")
|
202
|
+
end
|
203
|
+
|
204
|
+
it "with last" do
|
205
|
+
LAST.initials.must_equal("L")
|
206
|
+
end
|
207
|
+
|
208
|
+
it "with given & middle" do
|
209
|
+
GIVEN_MIDDLE.initials.must_equal("GM")
|
210
|
+
end
|
211
|
+
|
212
|
+
it "with first & middle" do
|
213
|
+
FIRST_MIDDLE.initials.must_equal("FM")
|
214
|
+
end
|
215
|
+
|
216
|
+
it "with given & family" do
|
217
|
+
GIVEN_FAMILY.initials.must_equal("GF")
|
218
|
+
end
|
219
|
+
|
220
|
+
it "with first & last" do
|
221
|
+
FIRST_LAST.initials.must_equal("FL")
|
222
|
+
end
|
223
|
+
|
224
|
+
it "with middle & family" do
|
225
|
+
MIDDLE_FAMILY.initials.must_equal("MF")
|
226
|
+
end
|
227
|
+
|
228
|
+
it "with middle & last" do
|
229
|
+
MIDDLE_LAST.initials.must_equal("ML")
|
230
|
+
end
|
231
|
+
|
232
|
+
it "with given & middle & family" do
|
233
|
+
GIVEN_MIDDLE_FAMILY.initials.must_equal("GMF")
|
234
|
+
end
|
235
|
+
|
236
|
+
it "with first & middle & last" do
|
237
|
+
FIRST_MIDDLE_LAST.initials.must_equal("FML")
|
238
|
+
end
|
177
239
|
|
178
|
-
describe "#initials" do
|
179
|
-
|
180
|
-
it "with first" do
|
181
|
-
F.initials.must_equal("a")
|
182
240
|
end
|
183
241
|
|
184
|
-
|
185
|
-
|
242
|
+
describe "#given_name_middle_name" do
|
243
|
+
|
244
|
+
it "with given" do
|
245
|
+
GIVEN.given_name_middle_name.must_equal("Given")
|
246
|
+
end
|
247
|
+
|
248
|
+
it "with middle" do
|
249
|
+
MIDDLE.given_name_middle_name.must_equal("Middle")
|
250
|
+
end
|
251
|
+
|
252
|
+
it "with last" do
|
253
|
+
LAST.given_name_middle_name.must_equal("")
|
254
|
+
end
|
255
|
+
|
256
|
+
it "with given & middle" do
|
257
|
+
GIVEN_MIDDLE.given_name_middle_name.must_equal("Given Middle")
|
258
|
+
end
|
259
|
+
|
260
|
+
it "with given & family" do
|
261
|
+
GIVEN_FAMILY.given_name_middle_name.must_equal("Given")
|
262
|
+
end
|
263
|
+
|
264
|
+
it "with middle & family" do
|
265
|
+
MIDDLE_FAMILY.given_name_middle_name.must_equal("Middle")
|
266
|
+
end
|
267
|
+
|
268
|
+
it "with given & middle & family" do
|
269
|
+
GIVEN_MIDDLE_FAMILY.given_name_middle_name.must_equal("Given Middle")
|
270
|
+
end
|
271
|
+
|
186
272
|
end
|
187
273
|
|
188
|
-
|
189
|
-
|
274
|
+
describe "#first_name_middle_name" do
|
275
|
+
|
276
|
+
it "with first" do
|
277
|
+
FIRST.first_name_middle_name.must_equal("First")
|
278
|
+
end
|
279
|
+
|
280
|
+
it "with middle" do
|
281
|
+
MIDDLE.first_name_middle_name.must_equal("Middle")
|
282
|
+
end
|
283
|
+
|
284
|
+
it "with last" do
|
285
|
+
LAST.first_name_middle_name.must_equal("")
|
286
|
+
end
|
287
|
+
|
288
|
+
it "with first & middle" do
|
289
|
+
FIRST_MIDDLE.first_name_middle_name.must_equal("First Middle")
|
290
|
+
end
|
291
|
+
|
292
|
+
it "with first & last" do
|
293
|
+
FIRST_LAST.first_name_middle_name.must_equal("First")
|
294
|
+
end
|
295
|
+
|
296
|
+
it "with middle & last" do
|
297
|
+
MIDDLE_LAST.first_name_middle_name.must_equal("Middle")
|
298
|
+
end
|
299
|
+
|
300
|
+
it "with first & middle & last" do
|
301
|
+
FIRST_MIDDLE_LAST.first_name_middle_name.must_equal("First Middle")
|
302
|
+
end
|
303
|
+
|
190
304
|
end
|
191
305
|
|
192
|
-
|
193
|
-
|
306
|
+
describe "#given_name_middle_initial" do
|
307
|
+
|
308
|
+
it "with given" do
|
309
|
+
GIVEN.given_name_middle_initial.must_equal("Given")
|
310
|
+
end
|
311
|
+
|
312
|
+
it "with middle" do
|
313
|
+
MIDDLE.given_name_middle_initial.must_equal("M")
|
314
|
+
end
|
315
|
+
|
316
|
+
it "with family" do
|
317
|
+
FAMILY.given_name_middle_initial.must_equal("")
|
318
|
+
end
|
319
|
+
|
320
|
+
it "with given & middle" do
|
321
|
+
GIVEN_MIDDLE.given_name_middle_initial.must_equal("Given M")
|
322
|
+
end
|
323
|
+
|
324
|
+
it "with given & family" do
|
325
|
+
GIVEN_FAMILY.given_name_middle_initial.must_equal("Given")
|
326
|
+
end
|
327
|
+
|
328
|
+
it "with middle & family" do
|
329
|
+
MIDDLE_FAMILY.given_name_middle_initial.must_equal("M")
|
330
|
+
end
|
331
|
+
|
332
|
+
it "with given & middle & family" do
|
333
|
+
GIVEN_MIDDLE_FAMILY.given_name_middle_initial.must_equal("Given M")
|
334
|
+
end
|
335
|
+
|
194
336
|
end
|
195
337
|
|
196
|
-
|
197
|
-
|
338
|
+
describe "#first_name_middle_initial" do
|
339
|
+
|
340
|
+
it "with first" do
|
341
|
+
FIRST.first_name_middle_initial.must_equal("First")
|
342
|
+
end
|
343
|
+
|
344
|
+
it "with middle" do
|
345
|
+
MIDDLE.first_name_middle_initial.must_equal("M")
|
346
|
+
end
|
347
|
+
|
348
|
+
it "with last" do
|
349
|
+
LAST.first_name_middle_initial.must_equal("")
|
350
|
+
end
|
351
|
+
|
352
|
+
it "with first & middle" do
|
353
|
+
FIRST_MIDDLE.first_name_middle_initial.must_equal("First M")
|
354
|
+
end
|
355
|
+
|
356
|
+
it "with first & last" do
|
357
|
+
FIRST_LAST.first_name_middle_initial.must_equal("First")
|
358
|
+
end
|
359
|
+
|
360
|
+
it "with middle & last" do
|
361
|
+
MIDDLE_LAST.first_name_middle_initial.must_equal("M")
|
362
|
+
end
|
363
|
+
|
364
|
+
it "with first & middle & last" do
|
365
|
+
FIRST_MIDDLE_LAST.first_name_middle_initial.must_equal("First M")
|
366
|
+
end
|
367
|
+
|
198
368
|
end
|
199
369
|
|
200
|
-
|
201
|
-
|
370
|
+
describe "#given_name_middle_initial_family_name" do
|
371
|
+
|
372
|
+
it "with given" do
|
373
|
+
GIVEN.given_name_middle_initial_family_name.must_equal("Given")
|
374
|
+
end
|
375
|
+
|
376
|
+
it "with middle" do
|
377
|
+
MIDDLE.given_name_middle_initial_family_name.must_equal("M")
|
378
|
+
end
|
379
|
+
|
380
|
+
it "with family" do
|
381
|
+
FAMILY.given_name_middle_initial_family_name.must_equal("Family")
|
382
|
+
end
|
383
|
+
|
384
|
+
it "with given &_middle" do
|
385
|
+
GIVEN_MIDDLE.given_name_middle_initial_family_name.must_equal("Given M")
|
386
|
+
end
|
387
|
+
|
388
|
+
it "with given &_family" do
|
389
|
+
GIVEN_FAMILY.given_name_middle_initial_family_name.must_equal("Given Family")
|
390
|
+
end
|
391
|
+
|
392
|
+
it "with middle &_family" do
|
393
|
+
MIDDLE_FAMILY.given_name_middle_initial_family_name.must_equal("M Family")
|
394
|
+
end
|
395
|
+
|
396
|
+
it "with given & middle &_family" do
|
397
|
+
GIVEN_MIDDLE_FAMILY.given_name_middle_initial_family_name.must_equal("Given M Family")
|
398
|
+
end
|
399
|
+
|
202
400
|
end
|
203
401
|
|
204
|
-
|
205
|
-
|
402
|
+
describe "#first_name_middle_initial_last_name" do
|
403
|
+
|
404
|
+
it "with first" do
|
405
|
+
FIRST.first_name_middle_initial_last_name.must_equal("First")
|
406
|
+
end
|
407
|
+
|
408
|
+
it "with middle" do
|
409
|
+
MIDDLE.first_name_middle_initial_last_name.must_equal("M")
|
410
|
+
end
|
411
|
+
|
412
|
+
it "with last" do
|
413
|
+
LAST.first_name_middle_initial_last_name.must_equal("Last")
|
414
|
+
end
|
415
|
+
|
416
|
+
it "with first &_middle" do
|
417
|
+
FIRST_MIDDLE.first_name_middle_initial_last_name.must_equal("First M")
|
418
|
+
end
|
419
|
+
|
420
|
+
it "with first &_last" do
|
421
|
+
FIRST_LAST.first_name_middle_initial_last_name.must_equal("First Last")
|
422
|
+
end
|
423
|
+
|
424
|
+
it "with middle &_last" do
|
425
|
+
MIDDLE_LAST.first_name_middle_initial_last_name.must_equal("M Last")
|
426
|
+
end
|
427
|
+
|
428
|
+
it "with first & middle &_last" do
|
429
|
+
FIRST_MIDDLE_LAST.first_name_middle_initial_last_name.must_equal("First M Last")
|
430
|
+
end
|
431
|
+
|
206
432
|
end
|
207
433
|
|
208
434
|
end
|
@@ -212,16 +438,20 @@ end
|
|
212
438
|
|
213
439
|
class Person
|
214
440
|
|
215
|
-
|
216
|
-
|
217
|
-
|
441
|
+
attr_accessor :given_name
|
442
|
+
attr_accessor :first_name
|
443
|
+
attr_accessor :middle_name
|
444
|
+
attr_accessor :family_name
|
445
|
+
attr_accessor :last_name
|
218
446
|
|
219
|
-
|
447
|
+
include PersonName
|
220
448
|
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
449
|
+
def initialize(opts = {})
|
450
|
+
@given_name = opts[:given_name]
|
451
|
+
@first_name = opts[:first_name]
|
452
|
+
@middle_name = opts[:middle_name]
|
453
|
+
@family_name = opts[:family_name]
|
454
|
+
@last_name = opts[:last_name]
|
455
|
+
end
|
226
456
|
|
227
457
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sixarm_ruby_person_name
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SixArm
|
@@ -44,7 +44,7 @@ cert_chain:
|
|
44
44
|
2AC9FOGkybW6DJEFSFFMlNk0IILsa/gNp8ufGuTVLWF9FUUdMNK+TMbghnifT8/1
|
45
45
|
n+ES/gQPOnvmVkLDGw==
|
46
46
|
-----END CERTIFICATE-----
|
47
|
-
date:
|
47
|
+
date: 2017-11-29 00:00:00.000000000 Z
|
48
48
|
dependencies:
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: minitest
|
@@ -66,6 +66,26 @@ dependencies:
|
|
66
66
|
- - "<"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sixarm_ruby_minitest_extensions
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.0.8
|
76
|
+
- - "<"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '2'
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.0.8
|
86
|
+
- - "<"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '2'
|
69
89
|
- !ruby/object:Gem::Dependency
|
70
90
|
name: rake
|
71
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,11 +160,12 @@ files:
|
|
140
160
|
- test/sixarm_ruby_person_name_test/person_name_test.rb
|
141
161
|
homepage: http://sixarm.com/
|
142
162
|
licenses:
|
143
|
-
-
|
144
|
-
-
|
163
|
+
- Apache-2.0
|
164
|
+
- Artistic-2.0
|
165
|
+
- BSD-3-Clause
|
166
|
+
- GPL-3.0
|
145
167
|
- MIT
|
146
|
-
-
|
147
|
-
- Various
|
168
|
+
- MPL-2.0
|
148
169
|
metadata: {}
|
149
170
|
post_install_message:
|
150
171
|
rdoc_options: []
|
@@ -162,11 +183,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
183
|
version: '0'
|
163
184
|
requirements: []
|
164
185
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.
|
186
|
+
rubygems_version: 2.6.13
|
166
187
|
signing_key:
|
167
188
|
specification_version: 4
|
168
|
-
summary: SixArm.com
|
189
|
+
summary: SixArm.com → Ruby → PersonName methods
|
169
190
|
test_files:
|
170
191
|
- test/sixarm_ruby_person_name_test.rb
|
171
192
|
- test/sixarm_ruby_person_name_test/person_name_test.rb
|
172
|
-
has_rdoc: true
|
metadata.gz.sig
CHANGED
Binary file
|