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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62068afab4a563ea89d776bc33f52476a2d50d8a
4
- data.tar.gz: 6987068ada1d2c58bee972baf9865bf3e1807089
3
+ metadata.gz: bf8d14df93390d9604627934329e510293182862
4
+ data.tar.gz: 0d16842a9e0bba13d330e91d526cea71bcf2e2c2
5
5
  SHA512:
6
- metadata.gz: 928e5dfe5298146c1963dc695f3593d4aff705ded33ce1114e904c8e9edabff5e063bf9e5f376094d2f4113110b226c8ccaca3dc0e3c8277fea10b1965de2e71
7
- data.tar.gz: 68ee19c6b5c6da4225906ac8abd8e0853b5d16f1935d094fa2c8130dedf892b04fd124e8f4634e891e152fae9c80815b5ae3d76b47d42023e86a0b2d5de367bc
6
+ metadata.gz: 1d5046fdb373f86177fa9e0d54505cded83bd74b2a6eab36c18076298cdb46f3d64d8c43734971780183a6219a5ce9e572ba859c4bb8b08be3f42656ce3b1bb6
7
+ data.tar.gz: 1707dd04393c2c9f25babf3277c0a37ccf140f82d9d3137c5fc639df386635da84792126867335720b2d0b5284311ed1c4271396b365a87dc6f772fc44b9dd7f
checksums.yaml.gz.sig CHANGED
Binary file
data/Rakefile CHANGED
@@ -2,9 +2,9 @@
2
2
  require "rake"
3
3
  require "rake/testtask"
4
4
 
5
+ task :default => [:test]
6
+
5
7
  Rake::TestTask.new(:test) do |t|
6
8
  t.libs.push("lib", "test")
7
9
  t.pattern = "test/**/*.rb"
8
10
  end
9
-
10
- task :default => [:test]
@@ -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
- # Return true iff the person has a first name and its non-blank
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
- respond_to?(:first_name) and first_name and first_name!='' and first_name.strip!=''
39
+ !!(respond_to?(:first_name) && first_name && first_name!='' && first_name.strip!='')
14
40
  end
15
41
 
16
-
17
- # Return true iff the person has a middle name and its non-blank
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
- respond_to?(:middle_name) and middle_name and middle_name!='' and middle_name.strip!=''
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
- # Return true iff the person has a last name and its non-blank
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
- respond_to?(:last_name) and last_name and last_name!='' and last_name.strip!=''
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
- # ==Example
34
- # u.first_name_middle_name => "Martin Luther"
35
-
36
- def first_name_middle_name
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
- (pieces << first_name) if first_name?
39
- (pieces << middle_name) if middle_name?
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
- # Return the person's first name + middle initial
147
+ # Get the person's intials
148
+ #
149
+ # Example:
45
150
  #
46
- # ==Example
47
- # u.first_name_middle_initial => "Martin N"
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
- def first_name_middle_initial
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 << first_name) if first_name?
52
- (pieces << middle_name[0...1]) if 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
- # ==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?
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
- # ==Example
74
- # u.full_name => "Martin Luther King"
207
+ # Example:
75
208
  #
76
- # This method skips any piece of the name that is missing or blank.
77
-
78
- def full_name
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 << first_name) if first_name?
81
- (pieces << middle_name) if 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
- # ==Example
90
- # u.list_name => "King, Martin Luther"
222
+ # Example:
91
223
  #
92
- # This method skips any piece of the name that is missing or blank.
93
-
94
- def list_name
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) 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
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
- # ==Example
109
- # u.initials => "MLK"
237
+ # Example:
110
238
  #
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
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
- before do
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
- it "with first" do
21
- F.first_name_middle_name.must_equal("abc")
10
+ before do
11
+ @p = Person.new
22
12
  end
23
13
 
24
- it "with middle" do
25
- M.first_name_middle_name.must_equal("def")
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
- it "with last" do
29
- L.first_name_middle_name.must_equal("")
30
- end
31
-
32
- it "with first & middle" do
33
- FM.first_name_middle_name.must_equal("abc def")
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
- it "with first & last" do
37
- FL.first_name_middle_name.must_equal("abc")
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
- it "with middle & last" do
41
- ML.first_name_middle_name.must_equal("def")
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
- it "with first & middle & last" do
45
- FML.first_name_middle_name.must_equal("abc def")
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
- describe "#first_name_middle_initial" do
51
-
52
- it "with first" do
53
- F.first_name_middle_initial.must_equal("abc")
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
- it "with middle" do
57
- M.first_name_middle_initial.must_equal("d")
58
- end
74
+ describe "#full_name" do
59
75
 
60
- it "with last" do
61
- L.first_name_middle_initial.must_equal("")
62
- end
76
+ it "with given" do
77
+ GIVEN.full_name.must_equal("Given")
78
+ end
63
79
 
64
- it "with first & middle" do
65
- FM.first_name_middle_initial.must_equal("abc d")
66
- end
80
+ it "with first" do
81
+ FIRST.full_name.must_equal("First")
82
+ end
67
83
 
68
- it "with first & last" do
69
- FL.first_name_middle_initial.must_equal("abc")
70
- end
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
- it "with middle & last" do
73
- ML.first_name_middle_initial.must_equal("d")
74
- end
92
+ it "with last" do
93
+ LAST.full_name.must_equal("Last")
94
+ end
75
95
 
76
- it "with first & middle & last" do
77
- FML.first_name_middle_initial.must_equal("abc d")
78
- end
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
- it "with first" do
85
- F.first_name_middle_initial_last_name.must_equal("abc")
86
- end
100
+ it "with first & middle" do
101
+ FIRST_MIDDLE.full_name.must_equal("First Middle")
102
+ end
87
103
 
88
- it "with middle" do
89
- M.first_name_middle_initial_last_name.must_equal("d")
90
- end
104
+ it "with given & family" do
105
+ GIVEN_FAMILY.full_name.must_equal("Given Family")
106
+ end
91
107
 
92
- it "with last" do
93
- L.first_name_middle_initial_last_name.must_equal("ghi")
94
- end
108
+ it "with first & last" do
109
+ FIRST_LAST.full_name.must_equal("First Last")
110
+ end
95
111
 
96
- it "with first &_middle" do
97
- FM.first_name_middle_initial_last_name.must_equal("abc d")
98
- end
112
+ it "with middle & family" do
113
+ MIDDLE_FAMILY.full_name.must_equal("Middle Family")
114
+ end
99
115
 
100
- it "with first &_last" do
101
- FL.first_name_middle_initial_last_name.must_equal("abc ghi")
102
- end
116
+ it "with middle & last" do
117
+ MIDDLE_LAST.full_name.must_equal("Middle Last")
118
+ end
103
119
 
104
- it "with middle &_last" do
105
- ML.first_name_middle_initial_last_name.must_equal("d ghi")
106
- end
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
- end
130
+ describe "#list_name" do
113
131
 
114
- describe "#full_name" do
132
+ it "with given" do
133
+ GIVEN.list_name.must_equal("Given")
134
+ end
115
135
 
116
- it "with first" do
117
- F.full_name.must_equal("abc")
118
- end
136
+ it "with first" do
137
+ FIRST.list_name.must_equal("First")
138
+ end
119
139
 
120
- it "with middle" do
121
- M.full_name.must_equal("def")
122
- end
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
- it "with first & middle" do
129
- FM.full_name.must_equal("abc def")
130
- end
144
+ it "with family" do
145
+ FAMILY.list_name.must_equal("Family")
146
+ end
131
147
 
132
- it "with first & last" do
133
- FL.full_name.must_equal("abc ghi")
134
- end
148
+ it "with last" do
149
+ LAST.list_name.must_equal("Last")
150
+ end
135
151
 
136
- it "with middle & last" do
137
- ML.full_name.must_equal("def ghi")
138
- end
152
+ it "with given & middle" do
153
+ GIVEN_MIDDLE.list_name.must_equal("Given Middle")
154
+ end
139
155
 
140
- it "with first & middle & last" do
141
- FML.full_name.must_equal("abc def ghi")
142
- end
156
+ it "with first & middle" do
157
+ FIRST_MIDDLE.list_name.must_equal("First Middle")
158
+ end
143
159
 
144
- end
160
+ it "with given & family" do
161
+ GIVEN_FAMILY.list_name.must_equal("Family, Given")
162
+ end
145
163
 
146
- describe "#list_name" do
164
+ it "with first & last" do
165
+ FIRST_LAST.list_name.must_equal("Last, First")
166
+ end
147
167
 
148
- it "with first" do
149
- F.list_name.must_equal("abc")
150
- end
168
+ it "with middle & family" do
169
+ MIDDLE_FAMILY.list_name.must_equal("Family, Middle")
170
+ end
151
171
 
152
- it "with middle" do
153
- M.list_name.must_equal("def")
154
- end
172
+ it "with middle & last" do
173
+ MIDDLE_LAST.list_name.must_equal("Last, Middle")
174
+ end
155
175
 
156
- it "with last" do
157
- L.list_name.must_equal("ghi")
158
- end
176
+ it "with given & middle & family" do
177
+ GIVEN_MIDDLE_FAMILY.list_name.must_equal("Family, Given Middle")
178
+ end
159
179
 
160
- it "with first & middle" do
161
- FM.list_name.must_equal("abc def")
162
- end
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
- it "with middle & last" do
169
- ML.list_name.must_equal("ghi, def")
170
- end
186
+ describe "#initials" do
171
187
 
172
- it "with first & middle & last" do
173
- FML.list_name.must_equal("ghi, abc def")
174
- end
188
+ it "with given" do
189
+ GIVEN.initials.must_equal("G")
190
+ end
175
191
 
176
- end
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
- it "with middle" do
185
- M.initials.must_equal("d")
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
- it "with last" do
189
- L.initials.must_equal("g")
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
- it "with first & middle" do
193
- FM.initials.must_equal("ad")
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
- it "with first & last" do
197
- FL.initials.must_equal("ag")
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
- it "with middle & last" do
201
- ML.initials.must_equal("dg")
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
- it "with first & middle & last" do
205
- FML.initials.must_equal("adg")
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
- attr_accessor :first_name
216
- attr_accessor :middle_name
217
- attr_accessor :last_name
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
- include PersonName
447
+ include PersonName
220
448
 
221
- def initialize(first,middle,last)
222
- @first_name=first
223
- @middle_name=middle
224
- @last_name=last
225
- end
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.1.2
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: 2015-07-19 00:00:00.000000000 Z
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
- - BSD
144
- - GPL
163
+ - Apache-2.0
164
+ - Artistic-2.0
165
+ - BSD-3-Clause
166
+ - GPL-3.0
145
167
  - MIT
146
- - PAL
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.4.8
186
+ rubygems_version: 2.6.13
166
187
  signing_key:
167
188
  specification_version: 4
168
- summary: SixArm.com » Ruby » PersonName methods
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