ssn_validator 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/VERSION.yml +1 -1
- data/lib/ssn_validator/models/death_master_file_loader.rb +41 -33
- data/lib/ssn_validator/models/ssn_high_group_code_loader.rb +17 -15
- data/rdoc/classes/DeathMasterFileLoader.html +15 -7
- data/rdoc/classes/SsnHighGroupCodeLoader.html +20 -17
- data/rdoc/created.rid +1 -1
- data/rdoc/files/lib/ssn_validator/models/death_master_file_loader_rb.html +1 -1
- data/rdoc/files/lib/ssn_validator/models/ssn_high_group_code_loader_rb.html +1 -1
- data/rdoc/files/lib/ssn_validator_rb.html +1 -1
- data/rdoc/index.html +2 -2
- data/ssn_validator.gemspec +2 -2
- metadata +77 -86
data/History.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 1.0.7 2010-09-09
|
2
|
+
|
3
|
+
* 2 enhancements:
|
4
|
+
* Modified to death master file load to stream the data from the website to be more jruby friendly.
|
5
|
+
* Made a small change to the ssn high group loader to handle ssa.gov url naming inconsistencies.
|
6
|
+
|
1
7
|
== 1.0.6 2010-09-03
|
2
8
|
* correct gemspec
|
3
9
|
|
data/VERSION.yml
CHANGED
@@ -23,7 +23,7 @@ class DeathMasterFileLoader
|
|
23
23
|
if File.exists?(@file_path_or_url)
|
24
24
|
@download_file = File.open(@file_path_or_url)
|
25
25
|
elsif URI.parse(@file_path_or_url).kind_of?(URI::HTTP)
|
26
|
-
@download_file = get_file_from_web
|
26
|
+
@download_file = File.open(get_file_from_web)
|
27
27
|
else
|
28
28
|
raise(Errno::ENOENT, @file_path_or_url)
|
29
29
|
end
|
@@ -31,7 +31,7 @@ class DeathMasterFileLoader
|
|
31
31
|
|
32
32
|
def load_file
|
33
33
|
|
34
|
-
if DeathMasterFile.connection.kind_of?(ActiveRecord::ConnectionAdapters::MysqlAdapter)
|
34
|
+
if DeathMasterFile.connection.kind_of?(ActiveRecord::ConnectionAdapters::MysqlAdapter) || DeathMasterFile.connection.kind_of?(ActiveRecord::ConnectionAdapters::JdbcAdapter)
|
35
35
|
puts "Converting file to csv format for Mysql import. This could take several minutes."
|
36
36
|
|
37
37
|
csv_file = convert_file_to_csv
|
@@ -53,12 +53,20 @@ class DeathMasterFileLoader
|
|
53
53
|
http.use_ssl = (uri.port == 443)
|
54
54
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
55
55
|
|
56
|
-
|
56
|
+
csv_file = Tempfile.new(@file_path_or_url.split('/').last) # create temp file for the raw file.
|
57
|
+
http.request(request) do |res|
|
58
|
+
raise(ArgumentError, "Invalid URL: #{@file_path_or_url}") if res.kind_of?(Net::HTTPNotFound)
|
59
|
+
raise(ArgumentError, "Authorization Required: Invalid username or password. Set the variables SsnValidator::Ntis.user_name and SsnValidator::Ntis.password in your environment.rb file.") if res.kind_of?(Net::HTTPUnauthorized)
|
60
|
+
size, total = 0, res.header['Content-Length'].to_i
|
61
|
+
res.read_body do |chunk|
|
62
|
+
size += chunk.size
|
63
|
+
csv_file.write chunk
|
64
|
+
puts "%d%% done (%d of %d)" % [(size * 100) / total, size, total]
|
65
|
+
end
|
57
66
|
|
58
|
-
|
59
|
-
raise(ArgumentError, "Authorization Required: Invalid username or password. Set the variables SsnValidator::Ntis.user_name and SsnValidator::Ntis.password in your environment.rb file.") if response.kind_of?(Net::HTTPUnauthorized)
|
67
|
+
end
|
60
68
|
|
61
|
-
return
|
69
|
+
return csv_file.path
|
62
70
|
end
|
63
71
|
|
64
72
|
#Loads all the update files from dmf.ntis.gov.
|
@@ -89,7 +97,7 @@ class DeathMasterFileLoader
|
|
89
97
|
timenow = start.to_s(:db)
|
90
98
|
|
91
99
|
@delete_ssns = []
|
92
|
-
|
100
|
+
puts "********** @download_file = " + @download_file.inspect
|
93
101
|
@download_file.each_with_index do |line,i|
|
94
102
|
action = record_action(line)
|
95
103
|
attributes_hash = text_to_hash(line)
|
@@ -150,21 +158,21 @@ class DeathMasterFileLoader
|
|
150
158
|
else
|
151
159
|
|
152
160
|
# empty field for id to be generated by mysql.
|
153
|
-
# record_hash = {
|
154
|
-
# :as_of => @file_as_of.to_date.to_s(:db),
|
155
|
-
# :social_security_number => parse_record(line,:social_security_number),
|
156
|
-
# :last_name => parse_record(line,:last_name),
|
157
|
-
# :name_suffix => parse_record(line,:name_suffix),
|
158
|
-
# :first_name => parse_record(line,:first_name),
|
159
|
-
# :middle_name => parse_record(line,:middle_name),
|
160
|
-
# :verify_proof_code => parse_record(line,:verify_proof_code),
|
161
|
-
# :date_of_death => parse_record(line,:date_of_death),
|
162
|
-
# :date_of_birth => parse_record(line,:date_of_birth),
|
163
|
-
# # - must be code between 01 and 65 or else nil.
|
164
|
-
# :state_of_residence=> parse_record(line,:state_of_residence=),
|
165
|
-
# :last_known_zip_residence => parse_record(line,:last_known_zip_residence),
|
166
|
-
# :last_known_zip_payment => parse_record(line,:last_known_zip_payment)
|
167
|
-
# }
|
161
|
+
# record_hash = {
|
162
|
+
# :as_of => @file_as_of.to_date.to_s(:db),
|
163
|
+
# :social_security_number => parse_record(line,:social_security_number),
|
164
|
+
# :last_name => parse_record(line,:last_name),
|
165
|
+
# :name_suffix => parse_record(line,:name_suffix),
|
166
|
+
# :first_name => parse_record(line,:first_name),
|
167
|
+
# :middle_name => parse_record(line,:middle_name),
|
168
|
+
# :verify_proof_code => parse_record(line,:verify_proof_code),
|
169
|
+
# :date_of_death => parse_record(line,:date_of_death),
|
170
|
+
# :date_of_birth => parse_record(line,:date_of_birth),
|
171
|
+
# # - must be code between 01 and 65 or else nil.
|
172
|
+
# :state_of_residence=> parse_record(line,:state_of_residence=),
|
173
|
+
# :last_known_zip_residence => parse_record(line,:last_known_zip_residence),
|
174
|
+
# :last_known_zip_payment => parse_record(line,:last_known_zip_payment)
|
175
|
+
# }
|
168
176
|
|
169
177
|
case action
|
170
178
|
when '',nil,' '
|
@@ -217,18 +225,18 @@ class DeathMasterFileLoader
|
|
217
225
|
def text_to_hash(line)
|
218
226
|
|
219
227
|
{:as_of => @file_as_of.to_date.to_s(:db),
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
+
:social_security_number => line[1,9].to_s.strip,
|
229
|
+
:last_name => line[10,20].to_s.strip,
|
230
|
+
:name_suffix => line[30,4].to_s.strip,
|
231
|
+
:first_name => line[34,15].to_s.strip,
|
232
|
+
:middle_name => line[49,15].to_s.strip,
|
233
|
+
:verify_proof_code => line[64,1].to_s.strip,
|
234
|
+
:date_of_death => (Date.strptime(line[65,8].to_s.strip,'%m%d%Y') rescue nil),
|
235
|
+
:date_of_birth => (Date.strptime(line[73,8].to_s.strip,'%m%d%Y') rescue nil),
|
228
236
|
# - must be code between 01 and 65 or else nil.
|
229
|
-
|
230
|
-
|
231
|
-
|
237
|
+
:state_of_residence => (line[81,2].to_s.strip.between?('01', '65') ? line[81,2].to_s.strip : nil),
|
238
|
+
:last_known_zip_residence => line[83,5].to_s.strip,
|
239
|
+
:last_known_zip_payment => line[88,5].to_s.strip}
|
232
240
|
rescue Exception => e
|
233
241
|
puts '@@@@@@@@@ Error = ' + e.message + ': ' + line.inspect
|
234
242
|
end
|
@@ -2,29 +2,31 @@
|
|
2
2
|
require 'net/http'
|
3
3
|
class SsnHighGroupCodeLoader
|
4
4
|
def self.load_all_high_group_codes_files
|
5
|
-
months = ['Jan','Feb','Mar','Apr','May','June','July','Aug','Sept','Oct','Nov','Dec']
|
5
|
+
months = ['Jan','Feb','Mar','Apr','May','June','July','Aug',['Sept','Sep'],'Oct','Nov','Dec']
|
6
6
|
run_file_date = SsnHighGroupCode.maximum(:as_of)
|
7
7
|
run_file_date = run_file_date ? run_file_date.next_month.beginning_of_month.to_date : Date.new(2003,11,01)
|
8
8
|
last_file_date = Date.today.beginning_of_month
|
9
9
|
while run_file_date <= last_file_date
|
10
10
|
file_processed = false
|
11
|
-
|
11
|
+
run_file_month_variants = Array(months[run_file_date.month - 1])
|
12
12
|
run_file_year = run_file_date.year
|
13
|
-
|
13
|
+
run_file_month_variants.each do |run_file_month|
|
14
14
|
break if file_processed
|
15
|
-
['
|
15
|
+
['','corrected'].each do |mod|
|
16
16
|
break if file_processed
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
17
|
+
['ssns','ssnvs'].each do |url_mod|
|
18
|
+
break if file_processed
|
19
|
+
(1..Date.today.day).each do |day|
|
20
|
+
string_day = day.to_s
|
21
|
+
string_day.insert(0,'0') if day < 10
|
22
|
+
string_year = run_file_year.to_s.last(2)
|
23
|
+
file_name = "HG#{run_file_month}#{string_day}#{string_year}#{mod}.txt"
|
24
|
+
text = Net::HTTP.get(URI.parse("http://www.socialsecurity.gov/employer/#{url_mod}/#{file_name}"))
|
25
|
+
unless text.include? 'File Not Found'
|
26
|
+
create_records(parse_text(text),extract_as_of_date(text))
|
27
|
+
file_processed = true
|
28
|
+
break
|
29
|
+
end
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
@@ -130,7 +130,7 @@ loaded, and loads each missing file in sequence up to the current file.
|
|
130
130
|
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
131
131
|
<div class="method-source-code" id="M000007-source">
|
132
132
|
<pre>
|
133
|
-
<span class="ruby-comment cmt"># File lib/ssn_validator/models/death_master_file_loader.rb, line
|
133
|
+
<span class="ruby-comment cmt"># File lib/ssn_validator/models/death_master_file_loader.rb, line 75</span>
|
134
134
|
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">load_update_files_from_web</span>
|
135
135
|
<span class="ruby-identifier">max_as_of</span> = <span class="ruby-constant">DeathMasterFile</span>.<span class="ruby-identifier">maximum</span>(<span class="ruby-identifier">:as_of</span>)
|
136
136
|
<span class="ruby-identifier">run_file_date</span> = <span class="ruby-identifier">max_as_of</span>.<span class="ruby-identifier">beginning_of_month</span>.<span class="ruby-identifier">next_month</span>
|
@@ -204,12 +204,20 @@ data is accurate.
|
|
204
204
|
<span class="ruby-identifier">http</span>.<span class="ruby-identifier">use_ssl</span> = (<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">port</span> <span class="ruby-operator">==</span> <span class="ruby-value">443</span>)
|
205
205
|
<span class="ruby-identifier">http</span>.<span class="ruby-identifier">verify_mode</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">VERIFY_NONE</span>
|
206
206
|
|
207
|
-
<span class="ruby-identifier">
|
207
|
+
<span class="ruby-identifier">csv_file</span> = <span class="ruby-constant">Tempfile</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@file_path_or_url</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">'/'</span>).<span class="ruby-identifier">last</span>) <span class="ruby-comment cmt"># create temp file for the raw file.</span>
|
208
|
+
<span class="ruby-identifier">http</span>.<span class="ruby-identifier">request</span>(<span class="ruby-identifier">request</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">res</span><span class="ruby-operator">|</span>
|
209
|
+
<span class="ruby-identifier">raise</span>(<span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"Invalid URL: #{@file_path_or_url}"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPNotFound</span>)
|
210
|
+
<span class="ruby-identifier">raise</span>(<span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"Authorization Required: Invalid username or password. Set the variables SsnValidator::Ntis.user_name and SsnValidator::Ntis.password in your environment.rb file."</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPUnauthorized</span>)
|
211
|
+
<span class="ruby-identifier">size</span>, <span class="ruby-identifier">total</span> = <span class="ruby-value">0</span>, <span class="ruby-identifier">res</span>.<span class="ruby-identifier">header</span>[<span class="ruby-value str">'Content-Length'</span>].<span class="ruby-identifier">to_i</span>
|
212
|
+
<span class="ruby-identifier">res</span>.<span class="ruby-identifier">read_body</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">chunk</span><span class="ruby-operator">|</span>
|
213
|
+
<span class="ruby-identifier">size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">chunk</span>.<span class="ruby-identifier">size</span>
|
214
|
+
<span class="ruby-identifier">csv_file</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">chunk</span>
|
215
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"%d%% done (%d of %d)"</span> <span class="ruby-operator">%</span> [(<span class="ruby-identifier">size</span> <span class="ruby-operator">*</span> <span class="ruby-value">100</span>) <span class="ruby-operator">/</span> <span class="ruby-identifier">total</span>, <span class="ruby-identifier">size</span>, <span class="ruby-identifier">total</span>]
|
216
|
+
<span class="ruby-keyword kw">end</span>
|
208
217
|
|
209
|
-
<span class="ruby-
|
210
|
-
<span class="ruby-identifier">raise</span>(<span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"Authorization Required: Invalid username or password. Set the variables SsnValidator::Ntis.user_name and SsnValidator::Ntis.password in your environment.rb file."</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPUnauthorized</span>)
|
218
|
+
<span class="ruby-keyword kw">end</span>
|
211
219
|
|
212
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">
|
220
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">csv_file</span>.<span class="ruby-identifier">path</span>
|
213
221
|
<span class="ruby-keyword kw">end</span>
|
214
222
|
</pre>
|
215
223
|
</div>
|
@@ -233,7 +241,7 @@ data is accurate.
|
|
233
241
|
<span class="ruby-comment cmt"># File lib/ssn_validator/models/death_master_file_loader.rb, line 32</span>
|
234
242
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">load_file</span>
|
235
243
|
|
236
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">DeathMasterFile</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>)
|
244
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">DeathMasterFile</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>) <span class="ruby-operator">||</span> <span class="ruby-constant">DeathMasterFile</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">JdbcAdapter</span>)
|
237
245
|
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Converting file to csv format for Mysql import. This could take several minutes."</span>
|
238
246
|
|
239
247
|
<span class="ruby-identifier">csv_file</span> = <span class="ruby-identifier">convert_file_to_csv</span>
|
@@ -273,7 +281,7 @@ data is accurate.
|
|
273
281
|
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-ivar">@file_path_or_url</span>)
|
274
282
|
<span class="ruby-ivar">@download_file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-ivar">@file_path_or_url</span>)
|
275
283
|
<span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-ivar">@file_path_or_url</span>).<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>)
|
276
|
-
<span class="ruby-ivar">@download_file</span> = <span class="ruby-identifier">get_file_from_web</span>
|
284
|
+
<span class="ruby-ivar">@download_file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">get_file_from_web</span>)
|
277
285
|
<span class="ruby-keyword kw">else</span>
|
278
286
|
<span class="ruby-identifier">raise</span>(<span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>, <span class="ruby-ivar">@file_path_or_url</span>)
|
279
287
|
<span class="ruby-keyword kw">end</span>
|
@@ -125,33 +125,36 @@
|
|
125
125
|
<pre>
|
126
126
|
<span class="ruby-comment cmt"># File lib/ssn_validator/models/ssn_high_group_code_loader.rb, line 4</span>
|
127
127
|
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">load_all_high_group_codes_files</span>
|
128
|
-
<span class="ruby-identifier">months</span> = [<span class="ruby-value str">'Jan'</span>,<span class="ruby-value str">'Feb'</span>,<span class="ruby-value str">'Mar'</span>,<span class="ruby-value str">'Apr'</span>,<span class="ruby-value str">'May'</span>,<span class="ruby-value str">'June'</span>,<span class="ruby-value str">'July'</span>,<span class="ruby-value str">'Aug'</span
|
128
|
+
<span class="ruby-identifier">months</span> = [<span class="ruby-value str">'Jan'</span>,<span class="ruby-value str">'Feb'</span>,<span class="ruby-value str">'Mar'</span>,<span class="ruby-value str">'Apr'</span>,<span class="ruby-value str">'May'</span>,<span class="ruby-value str">'June'</span>,<span class="ruby-value str">'July'</span>,<span class="ruby-value str">'Aug'</span>,[<span class="ruby-value str">'Sept'</span>,<span class="ruby-value str">'Sep'</span>],<span class="ruby-value str">'Oct'</span>,<span class="ruby-value str">'Nov'</span>,<span class="ruby-value str">'Dec'</span>]
|
129
129
|
<span class="ruby-identifier">run_file_date</span> = <span class="ruby-constant">SsnHighGroupCode</span>.<span class="ruby-identifier">maximum</span>(<span class="ruby-identifier">:as_of</span>)
|
130
|
-
<span class="ruby-identifier">run_file_date</span> = <span class="ruby-identifier">run_file_date</span> <span class="ruby-value">? </span><span class="ruby-identifier">run_file_date</span>.<span class="ruby-identifier">next_month</span>.<span class="ruby-identifier">beginning_of_month</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Date</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2003</span>,<span class="ruby-value">11</span>,<span class="ruby-value">01</span>)
|
130
|
+
<span class="ruby-identifier">run_file_date</span> = <span class="ruby-identifier">run_file_date</span> <span class="ruby-value">? </span><span class="ruby-identifier">run_file_date</span>.<span class="ruby-identifier">next_month</span>.<span class="ruby-identifier">beginning_of_month</span>.<span class="ruby-identifier">to_date</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Date</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2003</span>,<span class="ruby-value">11</span>,<span class="ruby-value">01</span>)
|
131
131
|
<span class="ruby-identifier">last_file_date</span> = <span class="ruby-constant">Date</span>.<span class="ruby-identifier">today</span>.<span class="ruby-identifier">beginning_of_month</span>
|
132
132
|
<span class="ruby-keyword kw">while</span> <span class="ruby-identifier">run_file_date</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">last_file_date</span>
|
133
133
|
<span class="ruby-identifier">file_processed</span> = <span class="ruby-keyword kw">false</span>
|
134
|
-
<span class="ruby-identifier">
|
134
|
+
<span class="ruby-identifier">run_file_month_variants</span> = <span class="ruby-constant">Array</span>(<span class="ruby-identifier">months</span>[<span class="ruby-identifier">run_file_date</span>.<span class="ruby-identifier">month</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>])
|
135
135
|
<span class="ruby-identifier">run_file_year</span> = <span class="ruby-identifier">run_file_date</span>.<span class="ruby-identifier">year</span>
|
136
|
-
|
136
|
+
<span class="ruby-identifier">run_file_month_variants</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">run_file_month</span><span class="ruby-operator">|</span>
|
137
137
|
<span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">file_processed</span>
|
138
|
-
[<span class="ruby-value str">'
|
138
|
+
[<span class="ruby-value str">''</span>,<span class="ruby-value str">'corrected'</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">mod</span><span class="ruby-operator">|</span>
|
139
139
|
<span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">file_processed</span>
|
140
|
-
|
141
|
-
<span class="ruby-
|
142
|
-
<span class="ruby-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
<span class="ruby-identifier">
|
148
|
-
<span class="ruby-
|
149
|
-
|
150
|
-
|
140
|
+
[<span class="ruby-value str">'ssns'</span>,<span class="ruby-value str">'ssnvs'</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">url_mod</span><span class="ruby-operator">|</span>
|
141
|
+
<span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">file_processed</span>
|
142
|
+
(<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-constant">Date</span>.<span class="ruby-identifier">today</span>.<span class="ruby-identifier">day</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">day</span><span class="ruby-operator">|</span>
|
143
|
+
<span class="ruby-identifier">string_day</span> = <span class="ruby-identifier">day</span>.<span class="ruby-identifier">to_s</span>
|
144
|
+
<span class="ruby-identifier">string_day</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>,<span class="ruby-value str">'0'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">day</span> <span class="ruby-operator"><</span> <span class="ruby-value">10</span>
|
145
|
+
<span class="ruby-identifier">string_year</span> = <span class="ruby-identifier">run_file_year</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">last</span>(<span class="ruby-value">2</span>)
|
146
|
+
<span class="ruby-identifier">file_name</span> = <span class="ruby-node">"HG#{run_file_month}#{string_day}#{string_year}#{mod}.txt"</span>
|
147
|
+
<span class="ruby-identifier">text</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-node">"http://www.socialsecurity.gov/employer/#{url_mod}/#{file_name}"</span>))
|
148
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">text</span>.<span class="ruby-identifier">include?</span> <span class="ruby-value str">'File Not Found'</span>
|
149
|
+
<span class="ruby-identifier">create_records</span>(<span class="ruby-identifier">parse_text</span>(<span class="ruby-identifier">text</span>),<span class="ruby-identifier">extract_as_of_date</span>(<span class="ruby-identifier">text</span>))
|
150
|
+
<span class="ruby-identifier">file_processed</span> = <span class="ruby-keyword kw">true</span>
|
151
|
+
<span class="ruby-keyword kw">break</span>
|
152
|
+
<span class="ruby-keyword kw">end</span>
|
151
153
|
<span class="ruby-keyword kw">end</span>
|
152
154
|
<span class="ruby-keyword kw">end</span>
|
153
155
|
<span class="ruby-keyword kw">end</span>
|
154
156
|
<span class="ruby-keyword kw">end</span>
|
157
|
+
<span class="ruby-identifier">run_file_date</span> = <span class="ruby-identifier">run_file_date</span>.<span class="ruby-identifier">next_month</span>
|
155
158
|
<span class="ruby-keyword kw">end</span>
|
156
159
|
<span class="ruby-keyword kw">end</span>
|
157
160
|
</pre>
|
@@ -177,7 +180,7 @@ href="http://www.socialsecurity.gov/employer/ssns/highgroup.txt">www.socialsecur
|
|
177
180
|
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
178
181
|
<div class="method-source-code" id="M000002-source">
|
179
182
|
<pre>
|
180
|
-
<span class="ruby-comment cmt"># File lib/ssn_validator/models/ssn_high_group_code_loader.rb, line
|
183
|
+
<span class="ruby-comment cmt"># File lib/ssn_validator/models/ssn_high_group_code_loader.rb, line 39</span>
|
181
184
|
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">load_current_high_group_codes_file</span>
|
182
185
|
<span class="ruby-identifier">text</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.socialsecurity.gov/employer/ssns/highgroup.txt'</span>))
|
183
186
|
<span class="ruby-identifier">create_records</span>(<span class="ruby-identifier">parse_text</span>(<span class="ruby-identifier">text</span>),<span class="ruby-identifier">extract_as_of_date</span>(<span class="ruby-identifier">text</span>))
|
data/rdoc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Thu, 09 Sep 2010 14:42:03 -0400
|
data/rdoc/index.html
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
<!--
|
7
7
|
|
8
|
-
ssn_validator 1.0.
|
8
|
+
ssn_validator 1.0.7
|
9
9
|
|
10
10
|
-->
|
11
11
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
12
12
|
<head>
|
13
|
-
<title>ssn_validator 1.0.
|
13
|
+
<title>ssn_validator 1.0.7</title>
|
14
14
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
15
15
|
</head>
|
16
16
|
<frameset rows="20%, 80%">
|
data/ssn_validator.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ssn_validator}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kevin Tyll"]
|
12
|
-
s.date = %q{2010-09-
|
12
|
+
s.date = %q{2010-09-09}
|
13
13
|
s.description = %q{Validates whether an SSN has likely been issued or not.}
|
14
14
|
s.email = %q{kevintyll@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,20 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ssn_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 1
|
7
|
-
- 0
|
8
|
-
- 6
|
9
|
-
version: 1.0.6
|
4
|
+
version: 1.0.7
|
10
5
|
platform: ruby
|
11
6
|
authors:
|
12
|
-
|
7
|
+
- Kevin Tyll
|
13
8
|
autorequire:
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
11
|
|
17
|
-
date: 2010-09-
|
12
|
+
date: 2010-09-09 00:00:00 -04:00
|
18
13
|
default_executable:
|
19
14
|
dependencies: []
|
20
15
|
|
@@ -25,65 +20,65 @@ executables: []
|
|
25
20
|
extensions: []
|
26
21
|
|
27
22
|
extra_rdoc_files:
|
28
|
-
|
29
|
-
|
23
|
+
- LICENSE
|
24
|
+
- README.rdoc
|
30
25
|
files:
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
26
|
+
- .gitignore
|
27
|
+
- History.txt
|
28
|
+
- LICENSE
|
29
|
+
- PostInstall.txt
|
30
|
+
- README.rdoc
|
31
|
+
- Rakefile
|
32
|
+
- VERSION.yml
|
33
|
+
- generators/death_master_file_migration/death_master_file_migration_generator.rb
|
34
|
+
- generators/death_master_file_migration/templates/migration.rb
|
35
|
+
- generators/ssn_validator_migration/.DS_Store
|
36
|
+
- generators/ssn_validator_migration/ssn_validator_migration_generator.rb
|
37
|
+
- generators/ssn_validator_migration/templates/.DS_Store
|
38
|
+
- generators/ssn_validator_migration/templates/migration.rb
|
39
|
+
- lib/ssn_validator.rb
|
40
|
+
- lib/ssn_validator/models/death_master_file.rb
|
41
|
+
- lib/ssn_validator/models/death_master_file_loader.rb
|
42
|
+
- lib/ssn_validator/models/ssn_high_group_code.rb
|
43
|
+
- lib/ssn_validator/models/ssn_high_group_code_loader.rb
|
44
|
+
- lib/ssn_validator/models/ssn_validator.rb
|
45
|
+
- lib/ssn_validator/ntis.rb
|
46
|
+
- lib/tasks/ssn_validator.rake
|
47
|
+
- rdoc/classes/DeathMasterFile.html
|
48
|
+
- rdoc/classes/DeathMasterFileLoader.html
|
49
|
+
- rdoc/classes/SsnHighGroupCode.html
|
50
|
+
- rdoc/classes/SsnHighGroupCodeLoader.html
|
51
|
+
- rdoc/classes/SsnValidator.html
|
52
|
+
- rdoc/classes/SsnValidator/Ntis.html
|
53
|
+
- rdoc/classes/SsnValidator/Ssn.html
|
54
|
+
- rdoc/created.rid
|
55
|
+
- rdoc/files/LICENSE.html
|
56
|
+
- rdoc/files/README_rdoc.html
|
57
|
+
- rdoc/files/lib/ssn_validator/models/death_master_file_loader_rb.html
|
58
|
+
- rdoc/files/lib/ssn_validator/models/death_master_file_rb.html
|
59
|
+
- rdoc/files/lib/ssn_validator/models/ssn_high_group_code_loader_rb.html
|
60
|
+
- rdoc/files/lib/ssn_validator/models/ssn_high_group_code_rb.html
|
61
|
+
- rdoc/files/lib/ssn_validator/models/ssn_validator_rb.html
|
62
|
+
- rdoc/files/lib/ssn_validator/ntis_rb.html
|
63
|
+
- rdoc/files/lib/ssn_validator_rb.html
|
64
|
+
- rdoc/fr_class_index.html
|
65
|
+
- rdoc/fr_file_index.html
|
66
|
+
- rdoc/fr_method_index.html
|
67
|
+
- rdoc/index.html
|
68
|
+
- rdoc/rdoc-style.css
|
69
|
+
- script/console
|
70
|
+
- script/destroy
|
71
|
+
- script/generate
|
72
|
+
- ssn_validator.gemspec
|
73
|
+
- test/files/test_dmf_funky_data_load.txt
|
74
|
+
- test/files/test_dmf_initial_load.txt
|
75
|
+
- test/files/test_dmf_update_load.txt
|
76
|
+
- test/files/valid_csv_from_funky_data_file.txt
|
77
|
+
- test/mocks/test/death_master_file_loader.rb
|
78
|
+
- test/test_death_master_file_loader.rb
|
79
|
+
- test/test_helper.rb
|
80
|
+
- test/test_ssn_high_group_code_loader.rb
|
81
|
+
- test/test_ssn_validator.rb
|
87
82
|
has_rdoc: true
|
88
83
|
homepage: http://kevintyll.git.com/ssn_validator
|
89
84
|
licenses: []
|
@@ -120,35 +115,31 @@ post_install_message: |
|
|
120
115
|
* The death master file data is updated monthly, so you'll want to run this rake task monthly to keep your validations accurate.
|
121
116
|
|
122
117
|
rdoc_options:
|
123
|
-
|
118
|
+
- --charset=UTF-8
|
124
119
|
require_paths:
|
125
|
-
|
120
|
+
- lib
|
126
121
|
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
-
none: false
|
128
122
|
requirements:
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
version: "0"
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: "0"
|
126
|
+
version:
|
134
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
-
none: false
|
136
128
|
requirements:
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
version: "0"
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: "0"
|
132
|
+
version:
|
142
133
|
requirements: []
|
143
134
|
|
144
135
|
rubyforge_project:
|
145
|
-
rubygems_version: 1.3.
|
136
|
+
rubygems_version: 1.3.5
|
146
137
|
signing_key:
|
147
138
|
specification_version: 3
|
148
139
|
summary: Validates whether an SSN has likely been issued or not.
|
149
140
|
test_files:
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
141
|
+
- test/mocks/test/death_master_file_loader.rb
|
142
|
+
- test/test_death_master_file_loader.rb
|
143
|
+
- test/test_helper.rb
|
144
|
+
- test/test_ssn_high_group_code_loader.rb
|
145
|
+
- test/test_ssn_validator.rb
|