kevintyll-ofac 1.1.4 → 1.1.5
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/History.txt +6 -1
- data/VERSION.yml +1 -1
- data/lib/ofac/models/ofac.rb +11 -9
- data/test/ofac_test.rb +1 -0
- metadata +2 -2
data/History.txt
CHANGED
@@ -28,4 +28,9 @@
|
|
28
28
|
== 1.1.4 2009-06-02
|
29
29
|
|
30
30
|
* 1 minor enhancement:
|
31
|
-
* Improved performance by ignoring initial in names when searching the database for possible hits.
|
31
|
+
* Improved performance by ignoring initial in names when searching the database for possible hits.
|
32
|
+
|
33
|
+
== 1.1.5 2009-06-03
|
34
|
+
|
35
|
+
* 1 bug fix:
|
36
|
+
* fixed a bug that threw an error if only single character initials are passed in for the name.
|
data/VERSION.yml
CHANGED
data/lib/ofac/models/ofac.rb
CHANGED
@@ -103,22 +103,24 @@ class Ofac
|
|
103
103
|
partial_name = @identity[:name].gsub(/\W/,'|')
|
104
104
|
name_array = partial_name.split('|')
|
105
105
|
name_array.delete_if{|n| n.size < 2}
|
106
|
-
|
107
|
-
|
108
|
-
|
106
|
+
unless name_array.empty?
|
107
|
+
sql_name_partial = name_array.collect {|partial_name| "name like '%#{partial_name}%'"}.join(' or ')
|
108
|
+
sql_alt_name_partial = name_array.collect {|partial_name| "alternate_identity_name like '%#{partial_name}%'"}.join(' or ')
|
109
|
+
possible_sdns = OfacSdn.connection.select_all("select name, alternate_identity_name, address, city
|
109
110
|
from ofac_sdns
|
110
111
|
where name is not null
|
111
112
|
and sdn_type = 'individual'
|
112
113
|
and (#{sql_name_partial}
|
113
114
|
or #{sql_alt_name_partial})")
|
114
|
-
|
115
|
+
possible_sdns = possible_sdns.collect {|sdn|{:name => "#{sdn['name']}|#{sdn['alternate_identity_name']}", :city => sdn['city'], :address => sdn['address']}}
|
115
116
|
|
116
|
-
|
117
|
-
|
118
|
-
|
117
|
+
match = OfacMatch.new({:name => {:weight => 60, :token => "#{@identity[:name]}"},
|
118
|
+
:address => {:weight => 10, :token => @identity[:address]},
|
119
|
+
:city => {:weight => 30, :token => @identity[:city]}})
|
119
120
|
|
120
|
-
|
121
|
-
|
121
|
+
score = match.score(possible_sdns)
|
122
|
+
@possible_hits = match.possible_hits
|
123
|
+
end
|
122
124
|
end
|
123
125
|
@score = score || 0
|
124
126
|
return @score
|
data/test/ofac_test.rb
CHANGED
@@ -12,6 +12,7 @@ class OfacTest < Test::Unit::TestCase
|
|
12
12
|
assert_equal 0, Ofac.new({:address => '123 somewhere'}).score
|
13
13
|
assert_equal 0, Ofac.new({:name => ''}).score
|
14
14
|
assert_equal 0, Ofac.new({:name => ' '}).score
|
15
|
+
assert_equal 0, Ofac.new({:name => 'P T'}).score
|
15
16
|
end
|
16
17
|
|
17
18
|
should "give a score of 0 if there is no name match" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kevintyll-ofac
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Tyll
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-03 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|