kevintyll-ofac 1.1.5 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -1
- data/VERSION.yml +1 -1
- data/lib/ofac/models/ofac.rb +19 -3
- data/test/ofac_test.rb +6 -0
- metadata +2 -2
data/History.txt
CHANGED
@@ -33,4 +33,9 @@
|
|
33
33
|
== 1.1.5 2009-06-03
|
34
34
|
|
35
35
|
* 1 bug fix:
|
36
|
-
* fixed a bug that threw an error if only single character initials are passed in for the name.
|
36
|
+
* fixed a bug that threw an error if only single character initials are passed in for the name.
|
37
|
+
|
38
|
+
== 1.1.6 2009-06-29
|
39
|
+
|
40
|
+
* 1 minor enhancement:
|
41
|
+
* Allow passing of first and last name seperately...to improve performance.
|
data/VERSION.yml
CHANGED
data/lib/ofac/models/ofac.rb
CHANGED
@@ -7,6 +7,15 @@ class Ofac
|
|
7
7
|
#
|
8
8
|
# <tt>:name</tt> is required to get a score. If <tt>:name</tt> is missing, an error will not be thrown, but a score of 0 will be returned.
|
9
9
|
#
|
10
|
+
# You can pass a string in for the full name:
|
11
|
+
# Ofac.new(:name => 'Victor De La Garza')
|
12
|
+
#
|
13
|
+
# Or you can specify the last and first names
|
14
|
+
# Ofac.new(:name => {:first_name => 'Victor', :last_name => 'De La Garza'})
|
15
|
+
#
|
16
|
+
# The first method will build a larger list of names for ruby to parse through and more likely to find similar names.
|
17
|
+
# The second method is quicker.
|
18
|
+
#
|
10
19
|
# The more information provided, the higher the score could be. A score of 100 would mean all fields
|
11
20
|
# were passed in, and all fields were 100% matches. If only the name is passed in without an address,
|
12
21
|
# it will be impossible to get a score of 100, even if the name matches perfectly.
|
@@ -100,8 +109,15 @@ class Ofac
|
|
100
109
|
#first get a list from the database of possible matches by name
|
101
110
|
#this query is pretty liberal, we just want to get a list of possible
|
102
111
|
#matches from the database that we can run through our ruby matching algorithm
|
103
|
-
|
104
|
-
|
112
|
+
|
113
|
+
#you can pass in a full name, or specify the first and last name
|
114
|
+
if @identity[:name].kind_of?(Hash)
|
115
|
+
name_array = [@identity[:name][:first_name],@identity[:name][:last_name]]
|
116
|
+
else
|
117
|
+
partial_name = @identity[:name].gsub(/\W/,'|')
|
118
|
+
name_array = partial_name.split('|')
|
119
|
+
end
|
120
|
+
|
105
121
|
name_array.delete_if{|n| n.size < 2}
|
106
122
|
unless name_array.empty?
|
107
123
|
sql_name_partial = name_array.collect {|partial_name| "name like '%#{partial_name}%'"}.join(' or ')
|
@@ -114,7 +130,7 @@ class Ofac
|
|
114
130
|
or #{sql_alt_name_partial})")
|
115
131
|
possible_sdns = possible_sdns.collect {|sdn|{:name => "#{sdn['name']}|#{sdn['alternate_identity_name']}", :city => sdn['city'], :address => sdn['address']}}
|
116
132
|
|
117
|
-
match = OfacMatch.new({:name => {:weight => 60, :token => "#{
|
133
|
+
match = OfacMatch.new({:name => {:weight => 60, :token => "#{name_array.join(' ')}"},
|
118
134
|
:address => {:weight => 10, :token => @identity[:address]},
|
119
135
|
:city => {:weight => 30, :token => @identity[:city]}})
|
120
136
|
|
data/test/ofac_test.rb
CHANGED
@@ -25,6 +25,12 @@ class OfacTest < Test::Unit::TestCase
|
|
25
25
|
|
26
26
|
should "give a score of 60 if there is a name match and deduct scores for non matches on address and city" do
|
27
27
|
assert_equal 60, Ofac.new({:name => 'Oscar Hernandez'}).score
|
28
|
+
assert_equal 60, Ofac.new({:name => {:first_name => 'Oscar', :last_name => 'Hernandez'}}).score
|
29
|
+
end
|
30
|
+
|
31
|
+
should "give a score of 30 if there is only a partial match" do
|
32
|
+
assert_equal 30, Ofac.new({:name => 'Oscar de la Hernandez'}).score
|
33
|
+
assert_equal 30, Ofac.new({:name => {:first_name => 'Oscar', :last_name => 'de la Hernandez'}}).score
|
28
34
|
end
|
29
35
|
|
30
36
|
should "deduct scores for non matches on address and city if data is in the database" 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.6
|
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-29 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|