name_splitter 0.1.6 → 0.1.7

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: 971e17c95013fbbc9b9228ed448b6edf91d95d18
4
- data.tar.gz: 67d14c681c08ec9ad153ded0857e4e9c5488d27a
3
+ metadata.gz: 1564e0d6f7a81a05f7c77926c9548115b5f49974
4
+ data.tar.gz: 82c6d53e108581d3e3c071efd83756a4c8924d82
5
5
  SHA512:
6
- metadata.gz: bab12102113da203a1b76fe07121eb61d2615b1436616320e639b180159f7ba2280db42ff10e660ff0f612e15ff5a845a3c95029bb5dc9e9b96072e241f3f0f9
7
- data.tar.gz: d52527c84b3e4d4bc49a8d16d09d2d0fbc79b7a95bc7d16c396456fe9ceb4e2a977ec8090884300b92b4fb832626e537266b39f7b3f385f97ea6cdfe760477ef
6
+ metadata.gz: b2e08535bac76dc5094cff67036b27e4dd58644ee6c4e1011e91f5dad3707a65bd4057654b9c96f61f0c0d11c074a421a1403db1c30d280c174a5cd7c91be6d7
7
+ data.tar.gz: 06028d326a852f8f10f8d0eafa40659d90f9965500a6a762478a8c0068b41e50fc0db6c8e539bf43a7caff2e75d4d77b521dc7d6bc5ac03a18e4906b8545f505
data/lib/name_splitter.rb CHANGED
@@ -45,7 +45,7 @@ module NameSplitter
45
45
  self.last_name = name_arr.shift
46
46
  else
47
47
  self.first_name = name_arr.shift(number_of_first_names(name_arr)).join(" ")
48
- self.middle_name = name_arr.shift if contains_middle_name(name_arr)
48
+ self.middle_name = name_arr.shift(number_of_middle_names(name_arr)).join(" ")
49
49
  self.last_name_check(name_arr)
50
50
  end
51
51
  end
@@ -62,14 +62,23 @@ module NameSplitter
62
62
 
63
63
  private
64
64
 
65
- def contains_middle_name(name_arr)
65
+ def number_of_middle_names(name_arr)
66
+ # if the first and last names have already been assigned, assume the
67
+ # rest of the name is a middle name
68
+ if !first_name.empty? && !last_name.empty?
69
+ return name_arr.length
70
+ end
71
+
66
72
  #checks whether the array of names passed in contains a likely middle name
67
- (name_arr.length == 1 && !last_name.empty? && !first_name.empty?) ||
68
- (name_arr.length == 2 &&
73
+ if (name_arr.length == 2 &&
69
74
  !(contains_suffix(name_arr) || contains_last_name_prefix(name_arr))) ||
70
75
  (name_arr.length == 3 &&
71
76
  !(contains_suffix(name_arr) && contains_last_name_prefix(name_arr))) ||
72
77
  name_arr.length > 3
78
+ return 1
79
+ end
80
+
81
+ return 0
73
82
  end
74
83
 
75
84
  def number_of_salutations(name_arr)
@@ -1,3 +1,3 @@
1
1
  module NameSplitter
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: name_splitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Hoen