kevintyll-ofac 1.1.7 → 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 1
3
- :patch: 7
3
+ :patch: 8
4
4
  :major: 1
@@ -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 '%#{partial_name}%'"}.join(' or ')
124
- sql_alt_name_partial = name_array.collect {|partial_name| "alternate_identity_name like '%#{partial_name}%'"}.join(' or ')
125
- possible_sdns = OfacSdn.connection.select_all("select name, alternate_identity_name, address, city
126
- from ofac_sdns
127
- where name is not null
128
- and sdn_type = 'individual'
129
- and (#{sql_name_partial}
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
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.7
4
+ version: 1.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Tyll