kevintyll-ssn_validator 0.1.1 → 0.1.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.
- data/History.txt +6 -0
- data/PostInstall.txt +1 -0
- data/README.rdoc +28 -12
- data/lib/ssn_validator/models/ssn_high_group_code.rb +26 -41
- data/lib/ssn_validator/models/ssn_validator.rb +4 -0
- data/lib/ssn_validator.rb +1 -1
- metadata +1 -1
data/History.txt
CHANGED
data/PostInstall.txt
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
For more information on ssn_validator, see http://kevintyll.github.com/ssn_validator/
|
3
3
|
|
4
4
|
* To create the necessary db migration, from the command line, run: script/generate ssn_validator_migration
|
5
|
+
* Require the gem in your environment.rb file in the Rails::Initializer block: config.gem 'ssn_validator'
|
5
6
|
* To load your table with the current SSN data, from the command line, run: rake ssn_validator:update_data
|
6
7
|
* The SSN data is updated monthly, so you'll want to run this rake task monthly to keep your validations accurate.
|
7
8
|
|
data/README.rdoc
CHANGED
@@ -1,32 +1,43 @@
|
|
1
1
|
= ssn_validator
|
2
2
|
|
3
|
-
* http://kevintyll.github.com/ssn_validator
|
3
|
+
* http://kevintyll.github.com/ssn_validator
|
4
|
+
* http://www.drexel-labs.com
|
4
5
|
|
5
6
|
== DESCRIPTION:
|
6
7
|
|
7
|
-
|
8
|
+
ssn_validator is a ruby gem that validates whether an SSN has likely been issued or not.
|
9
|
+
What exactly does that mean "likely" been issued? We can't tell for sure if an SSN belongs
|
10
|
+
to a particular person, but knowing the "rules"[http://www.socialsecurity.gov/employer/ssnweb.htm]
|
11
|
+
on how the social security administration assigns numbers, we can determine whether a number
|
12
|
+
has ever been issued or not.
|
13
|
+
|
14
|
+
ssn_validator started as a need for the company I work for, Clarity Services Inc. Incredibly, we
|
15
|
+
couldn't find an existing gem or service that provided what we needed. Since we were going to have
|
16
|
+
to role our own solution, we decided to create a gem out of it and share it with the community. Much
|
17
|
+
thanks goes to the management at Clarity Services Inc. for allowing this code to be open sourced.
|
8
18
|
|
9
19
|
|
10
20
|
== FEATURES/PROBLEMS:
|
11
21
|
|
12
|
-
*
|
22
|
+
* What it can do:
|
23
|
+
Validates the likelyhood that an SSN has been issued to someone.
|
13
24
|
|
14
25
|
* What it cannot do:
|
15
26
|
Validate that an SSN actually belongs to a particular person.
|
16
27
|
|
17
|
-
* What it's planned to do
|
18
|
-
Determine when an SSN was issued. This can be used to further validate an SSN by comparing it to a Date of Birth.
|
19
|
-
Check the Death Master File if the SSN belongs to a dead person.
|
28
|
+
* What it's planned to do:
|
29
|
+
Determine when an SSN was issued...if i can find the historical data. This can be used to further validate an SSN by comparing it to a Date of Birth.
|
30
|
+
Check the Death Master File if the SSN belongs to a dead person. This will require you to purchase the dmf data from https://dmf.ntis.gov
|
20
31
|
|
21
32
|
== SYNOPSIS:
|
22
33
|
|
23
|
-
|
34
|
+
* Just instantiate the object with an SSN.
|
24
35
|
ssn = SsnValidator::Ssn.new('123-45-6789')
|
25
36
|
|
26
|
-
|
37
|
+
* Then check if it's valid
|
27
38
|
ssn.valid?
|
28
39
|
|
29
|
-
|
40
|
+
* You can check the errors array to see why it's not valid.
|
30
41
|
ssn.errors
|
31
42
|
|
32
43
|
== REQUIREMENTS:
|
@@ -35,9 +46,14 @@ A ruby gem that validates whether an SSN has likely been issued or not.
|
|
35
46
|
|
36
47
|
== INSTALL:
|
37
48
|
|
38
|
-
*
|
39
|
-
|
40
|
-
* To
|
49
|
+
* To install the gem:
|
50
|
+
sudo gem install kevintyll-ssn_validator
|
51
|
+
* To create the necessary db migration, from the command line, run:
|
52
|
+
script/generate ssn_validator_migration
|
53
|
+
* Require the gem in your environment.rb file in the Rails::Initializer block:
|
54
|
+
config.gem 'ssn_validator'
|
55
|
+
* To load your table with the current SSN data, from the command line, run:
|
56
|
+
rake ssn_validator:update_data
|
41
57
|
* The SSN data is updated monthly, so you'll want to run this rake task monthly to keep your validations accurate.
|
42
58
|
|
43
59
|
== LICENSE:
|
@@ -2,33 +2,29 @@ require 'activerecord'
|
|
2
2
|
require 'net/http'
|
3
3
|
class SsnHighGroupCode < ActiveRecord::Base
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
5
|
+
# def self.load_historical_high_group_codes_file
|
6
|
+
# ['Jan','Feb','Mar','Apr','May','June','July','Aug','Sept','Oct','Nov','Dec'].each do |month|
|
7
|
+
# (1..10).each do |day|
|
8
|
+
# string_day = day.to_s
|
9
|
+
# string_day.insert(0,'0') if day < 10
|
10
|
+
# current_year = Date.today.year
|
11
|
+
# #(1932..current_year).each do |year|
|
12
|
+
# [2003].each do |year|
|
13
|
+
# string_year = year.to_s.last(2)
|
14
|
+
# ['','corrected'].each do |mod|
|
15
|
+
# ['ssns','ssnvs'].each do |url_mod|
|
16
|
+
# file_name = "HG#{month}#{string_day}#{string_year}#{mod}.txt"
|
17
|
+
# text = Net::HTTP.get(URI.parse("http://www.socialsecurity.gov/employer/#{url_mod}/#{file_name}"))
|
18
|
+
# puts file_name.inspect
|
19
|
+
# puts '@@@@@@@@@ found file_name = ' + file_name.inspect unless text.include? 'File Not Found'
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# end
|
27
|
+
# end
|
32
28
|
|
33
29
|
#Loads the most recent file from http://www.socialsecurity.gov/employer/ssns/highgroup.txt
|
34
30
|
def self.load_current_high_group_codes_file
|
@@ -36,23 +32,12 @@ class SsnHighGroupCode < ActiveRecord::Base
|
|
36
32
|
create_records(parse_text(text),extract_as_of_date(text))
|
37
33
|
end
|
38
34
|
|
35
|
+
|
36
|
+
private
|
37
|
+
|
39
38
|
def self.already_loaded?(file_as_of_date)
|
40
39
|
self.find_by_as_of(file_as_of_date)
|
41
40
|
end
|
42
|
-
###################
|
43
|
-
#end class mehtods#
|
44
|
-
###################
|
45
|
-
|
46
|
-
##################
|
47
|
-
#instance mehtods#
|
48
|
-
##################
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
######################
|
53
|
-
#end instance mehtods#
|
54
|
-
######################
|
55
|
-
private
|
56
41
|
|
57
42
|
def self.create_records(area_groups,file_as_of)
|
58
43
|
if already_loaded?(file_as_of)
|
@@ -5,6 +5,8 @@ module SsnValidator
|
|
5
5
|
attr_reader :errors
|
6
6
|
|
7
7
|
|
8
|
+
#Instantiate the object passing in a social security number.
|
9
|
+
#The ssn can be a string or integer, with or without the '-'s.
|
8
10
|
def initialize(ssn)
|
9
11
|
@errors = []
|
10
12
|
ssn = ssn.to_s
|
@@ -52,6 +54,8 @@ module SsnValidator
|
|
52
54
|
|
53
55
|
end
|
54
56
|
|
57
|
+
#Determines whether or not the passed in
|
58
|
+
#ssn passed all validations.
|
55
59
|
def valid?
|
56
60
|
@errors.empty?
|
57
61
|
end
|
data/lib/ssn_validator.rb
CHANGED