ofac 2.0.1 → 2.0.2

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.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +24 -49
  3. data/lib/ofac/version.rb +1 -0
  4. data/test/test_helper.rb +5 -1
  5. metadata +118 -94
  6. data/.document +0 -5
  7. data/.ruby-gemset +0 -1
  8. data/.ruby-version +0 -1
  9. data/History.txt +0 -134
  10. data/PostInstall.txt +0 -11
  11. data/VERSION.yml +0 -5
  12. data/generators/ofac_migration/.DS_Store +0 -0
  13. data/generators/ofac_migration/ofac_migration_generator.rb +0 -12
  14. data/generators/ofac_migration/templates/.DS_Store +0 -0
  15. data/generators/ofac_migration/templates/migration.rb +0 -31
  16. data/nbproject/project.properties +0 -7
  17. data/nbproject/project.xml +0 -15
  18. data/ofac.gemspec +0 -129
  19. data/rdoc/CreateOfacSdns.html +0 -249
  20. data/rdoc/Ofac.html +0 -434
  21. data/rdoc/OfacMatch.html +0 -299
  22. data/rdoc/OfacMigration.html +0 -138
  23. data/rdoc/OfacMigration/Generators.html +0 -138
  24. data/rdoc/OfacMigration/Generators/BuildGenerator.html +0 -251
  25. data/rdoc/OfacSdn.html +0 -209
  26. data/rdoc/OfacSdnLoader.html +0 -238
  27. data/rdoc/README_rdoc.html +0 -323
  28. data/rdoc/String.html +0 -262
  29. data/rdoc/classes/Ofac.html +0 -411
  30. data/rdoc/classes/OfacMatch.html +0 -239
  31. data/rdoc/classes/OfacSdn.html +0 -111
  32. data/rdoc/classes/OfacSdnLoader.html +0 -190
  33. data/rdoc/classes/String.html +0 -207
  34. data/rdoc/created.rid +0 -10
  35. data/rdoc/files/README_rdoc.html +0 -317
  36. data/rdoc/files/lib/ofac/models/ofac_rb.html +0 -101
  37. data/rdoc/files/lib/ofac/models/ofac_sdn_loader_rb.html +0 -110
  38. data/rdoc/files/lib/ofac/models/ofac_sdn_rb.html +0 -108
  39. data/rdoc/files/lib/ofac/ofac_match_rb.html +0 -101
  40. data/rdoc/files/lib/ofac/ruby_string_extensions_rb.html +0 -101
  41. data/rdoc/files/lib/ofac_rb.html +0 -113
  42. data/rdoc/fr_class_index.html +0 -31
  43. data/rdoc/fr_file_index.html +0 -33
  44. data/rdoc/fr_method_index.html +0 -35
  45. data/rdoc/images/add.png +0 -0
  46. data/rdoc/images/arrow_up.png +0 -0
  47. data/rdoc/images/brick.png +0 -0
  48. data/rdoc/images/brick_link.png +0 -0
  49. data/rdoc/images/bug.png +0 -0
  50. data/rdoc/images/bullet_black.png +0 -0
  51. data/rdoc/images/bullet_toggle_minus.png +0 -0
  52. data/rdoc/images/bullet_toggle_plus.png +0 -0
  53. data/rdoc/images/date.png +0 -0
  54. data/rdoc/images/delete.png +0 -0
  55. data/rdoc/images/find.png +0 -0
  56. data/rdoc/images/loadingAnimation.gif +0 -0
  57. data/rdoc/images/macFFBgHack.png +0 -0
  58. data/rdoc/images/package.png +0 -0
  59. data/rdoc/images/page_green.png +0 -0
  60. data/rdoc/images/page_white_text.png +0 -0
  61. data/rdoc/images/page_white_width.png +0 -0
  62. data/rdoc/images/plugin.png +0 -0
  63. data/rdoc/images/ruby.png +0 -0
  64. data/rdoc/images/tag_blue.png +0 -0
  65. data/rdoc/images/tag_green.png +0 -0
  66. data/rdoc/images/transparent.png +0 -0
  67. data/rdoc/images/wrench.png +0 -0
  68. data/rdoc/images/wrench_orange.png +0 -0
  69. data/rdoc/images/zoom.png +0 -0
  70. data/rdoc/index.html +0 -96
  71. data/rdoc/js/darkfish.js +0 -155
  72. data/rdoc/js/jquery.js +0 -18
  73. data/rdoc/js/navigation.js +0 -142
  74. data/rdoc/js/search.js +0 -94
  75. data/rdoc/js/search_index.js +0 -1
  76. data/rdoc/js/searcher.js +0 -228
  77. data/rdoc/lib/generators/ofac_migration/build/build_generator_rb.html +0 -97
  78. data/rdoc/lib/generators/ofac_migration/build/templates/create_ofac_sdns_rb.html +0 -97
  79. data/rdoc/lib/ofac/models/ofac_rb.html +0 -97
  80. data/rdoc/lib/ofac/models/ofac_sdn_loader_rb.html +0 -97
  81. data/rdoc/lib/ofac/models/ofac_sdn_rb.html +0 -97
  82. data/rdoc/lib/ofac/ofac_match_rb.html +0 -97
  83. data/rdoc/lib/ofac/ruby_string_extensions_rb.html +0 -97
  84. data/rdoc/lib/ofac_rb.html +0 -97
  85. data/rdoc/rdoc-style.css +0 -208
  86. data/rdoc/rdoc.css +0 -595
  87. data/rdoc/table_of_contents.html +0 -120
@@ -1,239 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: OfacMatch</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">OfacMatch</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../files/lib/ofac/ofac_match_rb.html">
59
- lib/ofac/ofac_match.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- <tr class="top-aligned-row">
66
- <td><strong>Parent:</strong></td>
67
- <td>
68
- Object
69
- </td>
70
- </tr>
71
- </table>
72
- </div>
73
- <!-- banner header -->
74
-
75
- <div id="bodyContent">
76
-
77
-
78
-
79
- <div id="contextContent">
80
-
81
-
82
-
83
- </div>
84
-
85
- <div id="method-list">
86
- <h3 class="section-bar">Methods</h3>
87
-
88
- <div class="name-list">
89
- <a href="#M000001">new</a>&nbsp;&nbsp;
90
- <a href="#M000002">score</a>&nbsp;&nbsp;
91
- </div>
92
- </div>
93
-
94
- </div>
95
-
96
-
97
- <!-- if includes -->
98
-
99
- <div id="section">
100
-
101
-
102
-
103
-
104
-
105
- <div id="attribute-list">
106
- <h3 class="section-bar">Attributes</h3>
107
-
108
- <div class="name-list">
109
- <table>
110
- <tr class="top-aligned-row context-row">
111
- <td class="context-item-name">possible_hits</td>
112
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
113
- <td class="context-item-desc"></td>
114
- </tr>
115
- </table>
116
- </div>
117
- </div>
118
-
119
-
120
-
121
- <!-- if method_list -->
122
- <div id="methods">
123
- <h3 class="section-bar">Public Class methods</h3>
124
-
125
- <div id="method-M000001" class="method-detail">
126
- <a name="M000001"></a>
127
-
128
- <div class="method-heading">
129
- <a href="#M000001" class="method-signature">
130
- <span class="method-name">new</span><span class="method-args">(stats={})</span>
131
- </a>
132
- </div>
133
-
134
- <div class="method-description">
135
- <p>
136
- Intialize a Match object with a record hash of fields you want to match on.
137
- Each key in the hash, also has a data hash value for the weight, token, and
138
- type.
139
- </p>
140
- <pre>
141
- match = Ofac::Match.new({:name =&gt; {:weight =&gt; 10, :token =&gt; 'Kevin Tyll'},
142
- :city =&gt; {:weight =&gt; 40, :token =&gt; 'Clearwater', },
143
- :address =&gt; {:weight =&gt; 40, :token =&gt; '1234 Park St.', },
144
- :zip =&gt; {:weight =&gt; 10, :token =&gt; '33759', :type =&gt; :number}})
145
-
146
- data hash keys:
147
- * &lt;tt&gt;data[:weight]&lt;/tt&gt; - value to apply to the score if there is a match (Default is 100/number of keys in the record hash)
148
- * &lt;tt&gt;data[:token]&lt;/tt&gt; - string to match
149
- * &lt;tt&gt;data[:match]&lt;/tt&gt; - set from records hash
150
- * &lt;tt&gt;data[:score]&lt;/tt&gt; - output field
151
- * &lt;tt&gt;data[:type]&lt;/tt&gt; - the type of match that should be performed (valid values are +:sound+ | +:number+) (Default is +:sound+)
152
- </pre>
153
- <p><a class="source-toggle" href="#"
154
- onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
155
- <div class="method-source-code" id="M000001-source">
156
- <pre>
157
- <span class="ruby-comment cmt"># File lib/ofac/ofac_match.rb, line 19</span>
158
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">stats</span>={})
159
- <span class="ruby-ivar">@possible_hits</span> = []
160
- <span class="ruby-ivar">@stats</span> = <span class="ruby-identifier">stats</span>.<span class="ruby-identifier">dup</span>
161
- <span class="ruby-identifier">weight</span> = <span class="ruby-value">100</span>
162
- <span class="ruby-identifier">weight</span> = <span class="ruby-value">100</span> <span class="ruby-operator">/</span> <span class="ruby-ivar">@stats</span>.<span class="ruby-identifier">length</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@stats</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
163
- <span class="ruby-ivar">@stats</span>.<span class="ruby-identifier">each_value</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">data</span><span class="ruby-operator">|</span>
164
- <span class="ruby-identifier">data</span>[<span class="ruby-identifier">:weight</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">weight</span>
165
- <span class="ruby-identifier">data</span>[<span class="ruby-identifier">:match</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">''</span>
166
- <span class="ruby-identifier">data</span>[<span class="ruby-identifier">:type</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">:sound</span>
167
- <span class="ruby-identifier">data</span>[<span class="ruby-identifier">:score</span>] <span class="ruby-operator">||=</span> <span class="ruby-value">0</span>
168
- <span class="ruby-identifier">data</span>[<span class="ruby-identifier">:token</span>] = <span class="ruby-identifier">data</span>[<span class="ruby-identifier">:token</span>].<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">upcase</span>
169
- <span class="ruby-keyword kw">end</span>
170
- <span class="ruby-keyword kw">end</span>
171
- </pre>
172
- </div>
173
- </div>
174
- </div>
175
-
176
- <h3 class="section-bar">Public Instance methods</h3>
177
-
178
- <div id="method-M000002" class="method-detail">
179
- <a name="M000002"></a>
180
-
181
- <div class="method-heading">
182
- <a href="#M000002" class="method-signature">
183
- <span class="method-name">score</span><span class="method-args">(match_records)</span>
184
- </a>
185
- </div>
186
-
187
- <div class="method-description">
188
- <p>
189
- match_records is an array of hashes.
190
- </p>
191
- <p>
192
- The hash keys must match the record hash keys set when initialized.
193
- </p>
194
- <p>
195
- <a href="OfacMatch.html#M000002">score</a> will return the highest <a
196
- href="OfacMatch.html#M000002">score</a> of all the records that are sent in
197
- match_records.
198
- </p>
199
- <p><a class="source-toggle" href="#"
200
- onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
201
- <div class="method-source-code" id="M000002-source">
202
- <pre>
203
- <span class="ruby-comment cmt"># File lib/ofac/ofac_match.rb, line 39</span>
204
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">score</span>(<span class="ruby-identifier">match_records</span>)
205
- <span class="ruby-identifier">score_results</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
206
- <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">match_records</span>.<span class="ruby-identifier">empty?</span>
207
- <span class="ruby-comment cmt">#place the match_records information</span>
208
- <span class="ruby-comment cmt">#into our @stats hash</span>
209
- <span class="ruby-identifier">match_records</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">match</span><span class="ruby-operator">|</span>
210
- <span class="ruby-identifier">match</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
211
- <span class="ruby-ivar">@stats</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_sym</span>][<span class="ruby-identifier">:match</span>] = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">upcase</span>
212
- <span class="ruby-keyword kw">end</span>
213
- <span class="ruby-identifier">record_score</span> = <span class="ruby-identifier">calculate_record</span>
214
- <span class="ruby-identifier">score_results</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">record_score</span>)
215
- <span class="ruby-ivar">@possible_hits</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">match</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">:score</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">record_score</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">record_score</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
216
- <span class="ruby-keyword kw">end</span>
217
- <span class="ruby-identifier">score</span> = <span class="ruby-identifier">score_results</span>.<span class="ruby-identifier">max</span> <span class="ruby-comment cmt">#take max score</span>
218
- <span class="ruby-keyword kw">end</span>
219
- <span class="ruby-ivar">@possible_hits</span>.<span class="ruby-identifier">uniq!</span>
220
- <span class="ruby-identifier">score</span> <span class="ruby-operator">||=</span> <span class="ruby-value">0</span>
221
- <span class="ruby-keyword kw">end</span>
222
- </pre>
223
- </div>
224
- </div>
225
- </div>
226
-
227
-
228
- </div>
229
-
230
-
231
- </div>
232
-
233
-
234
- <div id="validator-badges">
235
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
236
- </div>
237
-
238
- </body>
239
- </html>
@@ -1,111 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: OfacSdn</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">OfacSdn</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../files/lib/ofac/models/ofac_sdn_rb.html">
59
- lib/ofac/models/ofac_sdn.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- <tr class="top-aligned-row">
66
- <td><strong>Parent:</strong></td>
67
- <td>
68
- ActiveRecord::Base
69
- </td>
70
- </tr>
71
- </table>
72
- </div>
73
- <!-- banner header -->
74
-
75
- <div id="bodyContent">
76
-
77
-
78
-
79
- <div id="contextContent">
80
-
81
-
82
-
83
- </div>
84
-
85
-
86
- </div>
87
-
88
-
89
- <!-- if includes -->
90
-
91
- <div id="section">
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
- <!-- if method_list -->
101
-
102
-
103
- </div>
104
-
105
-
106
- <div id="validator-badges">
107
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
108
- </div>
109
-
110
- </body>
111
- </html>
@@ -1,190 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: OfacSdnLoader</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">OfacSdnLoader</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../files/lib/ofac/models/ofac_sdn_loader_rb.html">
59
- lib/ofac/models/ofac_sdn_loader.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- <tr class="top-aligned-row">
66
- <td><strong>Parent:</strong></td>
67
- <td>
68
- Object
69
- </td>
70
- </tr>
71
- </table>
72
- </div>
73
- <!-- banner header -->
74
-
75
- <div id="bodyContent">
76
-
77
-
78
-
79
- <div id="contextContent">
80
-
81
-
82
-
83
- </div>
84
-
85
- <div id="method-list">
86
- <h3 class="section-bar">Methods</h3>
87
-
88
- <div class="name-list">
89
- <a href="#M000009">load_current_sdn_file</a>&nbsp;&nbsp;
90
- </div>
91
- </div>
92
-
93
- </div>
94
-
95
-
96
- <!-- if includes -->
97
-
98
- <div id="section">
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
- <!-- if method_list -->
108
- <div id="methods">
109
- <h3 class="section-bar">Public Class methods</h3>
110
-
111
- <div id="method-M000009" class="method-detail">
112
- <a name="M000009"></a>
113
-
114
- <div class="method-heading">
115
- <a href="#M000009" class="method-signature">
116
- <span class="method-name">load_current_sdn_file</span><span class="method-args">() {|&quot;Downloading OFAC data from http://www.treas.gov/offices/enforcement/ofac/sdn&quot; if block_given?| ...}</span>
117
- </a>
118
- </div>
119
-
120
- <div class="method-description">
121
- <p>
122
- Loads the most recent file from <a
123
- href="http://www.treas.gov/offices/enforcement/ofac/sdn/delimit/index.shtml">www.treas.gov/offices/enforcement/ofac/sdn/delimit/index.shtml</a>
124
- </p>
125
- <p><a class="source-toggle" href="#"
126
- onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
127
- <div class="method-source-code" id="M000009-source">
128
- <pre>
129
- <span class="ruby-comment cmt"># File lib/ofac/models/ofac_sdn_loader.rb, line 9</span>
130
- <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">load_current_sdn_file</span>
131
- <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;Reloading OFAC sdn data&quot;</span>
132
- <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;Downloading OFAC data from http://www.treas.gov/offices/enforcement/ofac/sdn&quot;</span>
133
- <span class="ruby-keyword kw">yield</span> <span class="ruby-value str">&quot;Downloading OFAC data from http://www.treas.gov/offices/enforcement/ofac/sdn&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
134
- <span class="ruby-comment cmt">#get the 3 data files</span>
135
- <span class="ruby-identifier">sdn</span> = <span class="ruby-constant">Tempfile</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'sdn'</span>)
136
- <span class="ruby-identifier">bytes</span> = <span class="ruby-identifier">sdn</span>.<span class="ruby-identifier">write</span>(<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">get</span>(<span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-value str">'http://www.treasury.gov/ofac/downloads/sdn.pip'</span>)))
137
- <span class="ruby-identifier">sdn</span>.<span class="ruby-identifier">rewind</span>
138
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">bytes</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">convert_line_to_array</span>(<span class="ruby-identifier">sdn</span>.<span class="ruby-identifier">readline</span>).<span class="ruby-identifier">size</span> <span class="ruby-operator">!=</span> <span class="ruby-value">12</span>
139
- <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;Trouble downloading file. The url may have changed.&quot;</span>
140
- <span class="ruby-keyword kw">yield</span> <span class="ruby-value str">&quot;Trouble downloading file. The url may have changed.&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
141
- <span class="ruby-keyword kw">return</span>
142
- <span class="ruby-keyword kw">else</span>
143
- <span class="ruby-identifier">sdn</span>.<span class="ruby-identifier">rewind</span>
144
- <span class="ruby-keyword kw">end</span>
145
- <span class="ruby-identifier">address</span> = <span class="ruby-constant">Tempfile</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'sdn'</span>)
146
- <span class="ruby-identifier">address</span>.<span class="ruby-identifier">write</span>(<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">get</span>(<span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-value str">'http://www.treasury.gov/ofac/downloads/add.pip'</span>)))
147
- <span class="ruby-identifier">address</span>.<span class="ruby-identifier">rewind</span>
148
- <span class="ruby-identifier">alt</span> = <span class="ruby-constant">Tempfile</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'sdn'</span>)
149
- <span class="ruby-identifier">alt</span>.<span class="ruby-identifier">write</span>(<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">get</span>(<span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-value str">'http://www.treasury.gov/ofac/downloads/alt.pip'</span>)))
150
- <span class="ruby-identifier">alt</span>.<span class="ruby-identifier">rewind</span>
151
-
152
- <span class="ruby-keyword kw">if</span> <span class="ruby-constant">OfacSdn</span>.<span class="ruby-identifier">connection</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">ConnectionAdapters</span><span class="ruby-operator">::</span><span class="ruby-constant">MysqlAdapter</span>)
153
- <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;Converting file to csv format for Mysql import. This could take several minutes.&quot;</span>
154
- <span class="ruby-keyword kw">yield</span> <span class="ruby-value str">&quot;Converting file to csv format for Mysql import. This could take several minutes.&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
155
-
156
- <span class="ruby-identifier">csv_file</span> = <span class="ruby-identifier">convert_to_flattened_csv</span>(<span class="ruby-identifier">sdn</span>, <span class="ruby-identifier">address</span>, <span class="ruby-identifier">alt</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">status</span><span class="ruby-operator">|</span>
157
- <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">status</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
158
- <span class="ruby-keyword kw">end</span>
159
-
160
- <span class="ruby-identifier">bulk_mysql_update</span>(<span class="ruby-identifier">csv_file</span>)<span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">status</span><span class="ruby-operator">|</span>
161
- <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">status</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
162
- <span class="ruby-keyword kw">end</span>
163
- <span class="ruby-keyword kw">else</span>
164
- <span class="ruby-identifier">active_record_file_load</span>(<span class="ruby-identifier">sdn</span>, <span class="ruby-identifier">address</span>, <span class="ruby-identifier">alt</span>)<span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">status</span><span class="ruby-operator">|</span>
165
- <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">status</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
166
- <span class="ruby-keyword kw">end</span>
167
- <span class="ruby-keyword kw">end</span>
168
-
169
- <span class="ruby-identifier">sdn</span>.<span class="ruby-identifier">close</span>
170
- <span class="ruby-ivar">@address</span>.<span class="ruby-identifier">close</span>
171
- <span class="ruby-ivar">@alt</span>.<span class="ruby-identifier">close</span>
172
- <span class="ruby-keyword kw">end</span>
173
- </pre>
174
- </div>
175
- </div>
176
- </div>
177
-
178
-
179
- </div>
180
-
181
-
182
- </div>
183
-
184
-
185
- <div id="validator-badges">
186
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
187
- </div>
188
-
189
- </body>
190
- </html>