kevintyll-ofac 1.1.7 → 1.1.8
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 +7 -1
- data/VERSION.yml +1 -1
- data/lib/ofac/models/ofac.rb +7 -8
- data/test/ofac_test.rb +2 -0
- metadata +1 -1
data/History.txt
CHANGED
@@ -43,4 +43,10 @@
|
|
43
43
|
== 1.1.7 2009-06-30
|
44
44
|
|
45
45
|
* 1 bug fix:
|
46
|
-
* fixed error when passing a nil value into the new :first_name or :last_name hash values when initializing the Ofac object.
|
46
|
+
* fixed error when passing a nil value into the new :first_name or :last_name hash values when initializing the Ofac object.
|
47
|
+
|
48
|
+
== 1.1.8 2009-06-30
|
49
|
+
|
50
|
+
* 1 bug fix:
|
51
|
+
* Refactored the select on OfacSdn to use the AR connection instead of building sql and using the raw connection. Fixes a bug
|
52
|
+
introducted in 1.1.6 where quotes in the name raised an error.
|
data/VERSION.yml
CHANGED
data/lib/ofac/models/ofac.rb
CHANGED
@@ -120,14 +120,13 @@ class Ofac
|
|
120
120
|
|
121
121
|
name_array.delete_if{|n| n.strip.size < 2}
|
122
122
|
unless name_array.empty?
|
123
|
-
sql_name_partial = name_array.collect {|partial_name| "name like
|
124
|
-
sql_alt_name_partial = name_array.collect {|partial_name| "alternate_identity_name like
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
or #{sql_alt_name_partial})")
|
123
|
+
sql_name_partial = name_array.collect {|partial_name| ["name like ?", "%#{partial_name}%"]}
|
124
|
+
sql_alt_name_partial = name_array.collect {|partial_name| ["alternate_identity_name like ?", "%#{partial_name}%"]}
|
125
|
+
conditions = sql_name_partial + sql_alt_name_partial
|
126
|
+
conditions = conditions.transpose
|
127
|
+
conditions = [conditions.first.join(' or ')] + conditions.second
|
128
|
+
|
129
|
+
possible_sdns = OfacSdn.find_all_by_sdn_type('individual',:select => 'name, alternate_identity_name, address, city', :conditions => conditions)
|
131
130
|
possible_sdns = possible_sdns.collect {|sdn|{:name => "#{sdn['name']}|#{sdn['alternate_identity_name']}", :city => sdn['city'], :address => sdn['address']}}
|
132
131
|
|
133
132
|
match = OfacMatch.new({:name => {:weight => 60, :token => "#{name_array.join(' ')}"},
|
data/test/ofac_test.rb
CHANGED
@@ -20,6 +20,8 @@ class OfacTest < Test::Unit::TestCase
|
|
20
20
|
|
21
21
|
should "give a score of 0 if there is no name match" do
|
22
22
|
assert_equal 0, Ofac.new({:name => 'Kevin T P'}).score
|
23
|
+
assert_equal 0, Ofac.new({:name => "O'Brian"}).score
|
24
|
+
assert_equal 0, Ofac.new({:name => {:first_name => 'Matthew',:last_name => "O'Brian"}}).score
|
23
25
|
end
|
24
26
|
|
25
27
|
should "give a score of 0 if there is no name match but there is an address and city match" do
|