icu_name 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
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 ")
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ICU
4
4
  class Name
5
- VERSION = "1.2.0"
5
+ VERSION = "1.2.1"
6
6
  end
7
7
  end
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.0
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: 1642061693049790720
115
+ hash: 2495623935801790259
116
116
  required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements: