icu_name 1.2.0 → 1.2.1
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.
- data/lib/icu_name/util.rb +4 -2
- data/lib/icu_name/version.rb +1 -1
- data/spec/util_spec.rb +4 -0
- metadata +2 -2
data/lib/icu_name/util.rb
CHANGED
@@ -55,13 +55,15 @@ module ICU
|
|
55
55
|
|
56
56
|
# For generating SQL queries relating to alternative first or last names.
|
57
57
|
module AlternativeNames
|
58
|
-
def last_name_like(last, first)
|
58
|
+
def last_name_like(last, first=nil)
|
59
|
+
first = "X" if first.nil? || first =~ /\A\s*\z/
|
59
60
|
ICU::Name.new(first, last).alternatives(:last).push(last).map do |nam|
|
60
61
|
"last_name LIKE '%#{quote_str(nam)}%'"
|
61
62
|
end.sort.join(" OR ")
|
62
63
|
end
|
63
64
|
|
64
|
-
def first_name_like(first, last)
|
65
|
+
def first_name_like(first, last=nil)
|
66
|
+
last = "X" if last.nil? || last =~ /\A\s*\z/
|
65
67
|
ICU::Name.new(first, last).alternatives(:first).push(first).map do |nam|
|
66
68
|
"first_name LIKE '%#{quote_str(nam)}%'"
|
67
69
|
end.sort.join(" OR ")
|
data/lib/icu_name/version.rb
CHANGED
data/spec/util_spec.rb
CHANGED
@@ -73,6 +73,8 @@ module ICU
|
|
73
73
|
it "#last_name_like" do
|
74
74
|
expect(Dummy.last_name_like("Murphy", "Oissine")).to eq "last_name LIKE '%Murchadha%' OR last_name LIKE '%Murphy%'"
|
75
75
|
expect(Dummy.last_name_like("O'Connor", "Jonathan")).to eq "last_name LIKE '%O''Connor%' OR last_name LIKE '%O`Connor%'"
|
76
|
+
expect(Dummy.last_name_like("O'Connor", "\n")).to eq "last_name LIKE '%O''Connor%' OR last_name LIKE '%O`Connor%'"
|
77
|
+
expect(Dummy.last_name_like("O'Connor")).to eq "last_name LIKE '%O''Connor%' OR last_name LIKE '%O`Connor%'"
|
76
78
|
expect(Dummy.last_name_like("Orr", "Mark")).to eq "last_name LIKE '%Orr%'"
|
77
79
|
expect(Dummy.last_name_like("", "Mark")).to eq "last_name LIKE '%%'"
|
78
80
|
end
|
@@ -80,6 +82,8 @@ module ICU
|
|
80
82
|
it "#first_name_like" do
|
81
83
|
expect(Dummy.first_name_like("sean", "bradley")).to eq "first_name LIKE '%John%' OR first_name LIKE '%sean%'"
|
82
84
|
expect(Dummy.first_name_like("Jonathan", "O'Connor")).to eq "first_name LIKE '%Jon%' OR first_name LIKE '%Jonathan%'"
|
85
|
+
expect(Dummy.first_name_like("Jonathan", " ")).to eq "first_name LIKE '%Jon%' OR first_name LIKE '%Jonathan%'"
|
86
|
+
expect(Dummy.first_name_like("Jonathan")).to eq "first_name LIKE '%Jon%' OR first_name LIKE '%Jonathan%'"
|
83
87
|
expect(Dummy.first_name_like("", "O'Connor")).to eq "first_name LIKE '%%'"
|
84
88
|
end
|
85
89
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icu_name
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -112,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
segments:
|
114
114
|
- 0
|
115
|
-
hash:
|
115
|
+
hash: 2495623935801790259
|
116
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
117
|
none: false
|
118
118
|
requirements:
|