social_security_number 0.1.3 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ef6989bf26efcb10701d734422c3dd9c9bc5a21
|
4
|
+
data.tar.gz: 07fd10da85a51a18fd7bd29caebe2eda7b14fac0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71b5c235966d7fbafbe94605d9cb86df67a01f81081d56cb3ba175ab094265b0520b01bdeda3ade1e503d9f410dc8fdf26bec9a1b7bc2fc34537de6e0ae41c11
|
7
|
+
data.tar.gz: bb8a3814b5e69ef5246a47578ef5b78fc8dd000344da1f83b4646e32fdd2002f05d59658ebc15827e3ae7332dadf365bd350af4ed0d72c91bac4df52ff50dc3f
|
@@ -32,18 +32,22 @@ module SocialSecurityNumber
|
|
32
32
|
|
33
33
|
CONTROLCIPHERS = [2, 1, 2, 1, 2, 1, 2, 1, 2].freeze
|
34
34
|
|
35
|
-
|
35
|
+
YEAR_REGEXP = /(?<year>(\d{2}){0,1}(\d{2}))/
|
36
|
+
DATE_REGEXP = /#{YEAR_REGEXP}(?<month>\d{2})(?<day>\d{2})/
|
37
|
+
REGEXP = /^#{DATE_REGEXP}[- +]?(?<indv>\d{2})(?<gnd>\d{1})(?<ctrl>\d{0,1})$/
|
36
38
|
|
37
39
|
def check_control_digit
|
38
40
|
sum = checksum(:even)
|
39
41
|
control_number = (sum % 10 != 0) ? 10 - (sum % 10) : 0
|
42
|
+
return true if @control_number.to_s.empty?
|
40
43
|
control_number.to_i == @control_number.to_i
|
41
44
|
end
|
42
45
|
|
43
46
|
def checksum(operation)
|
44
47
|
i = 0
|
45
48
|
compare_method = operation == :even ? :== : :>
|
46
|
-
|
49
|
+
numer = @civil_number.gsub(/\-|\+/, '').to_s.length == 10 ? digit_number[0..8] : digit_number[2..10]
|
50
|
+
numer.reverse.split('').reduce(0) do |sum, c|
|
47
51
|
n = c.to_i
|
48
52
|
weight = (i % 2).send(compare_method, 0) ? n * 2 : n
|
49
53
|
i += 1
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social_security_number
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SameSystem
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|