social_security_number 0.1.6 → 0.1.7

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: 3ef6989bf26efcb10701d734422c3dd9c9bc5a21
4
- data.tar.gz: 07fd10da85a51a18fd7bd29caebe2eda7b14fac0
3
+ metadata.gz: 042c2456a881cd2cb0e3cea300bc9fa892397a3a
4
+ data.tar.gz: 68975f6e3b98ef821c4b67551b72d0f6aec7e5dc
5
5
  SHA512:
6
- metadata.gz: 71b5c235966d7fbafbe94605d9cb86df67a01f81081d56cb3ba175ab094265b0520b01bdeda3ade1e503d9f410dc8fdf26bec9a1b7bc2fc34537de6e0ae41c11
7
- data.tar.gz: bb8a3814b5e69ef5246a47578ef5b78fc8dd000344da1f83b4646e32fdd2002f05d59658ebc15827e3ae7332dadf365bd350af4ed0d72c91bac4df52ff50dc3f
6
+ metadata.gz: b2ba939c8082929ed99bae51224ac0586fdaf935704f7fa02a4a3462fae694f1e845ebb270e29d59f39201db7cf31fbece6706689bb749f39a75201105f5433d
7
+ data.tar.gz: 04ae85bdc5c073391f910b65bdd1dcecc9d336df9cbab480f02de5e71b7c487b3b177aeb9c7e2e8f2f38291ca9712d18d5756fc549b049a904cdf4f288167166
data/README.md CHANGED
@@ -8,12 +8,11 @@ Find version information in the CHANGELOG.
8
8
 
9
9
  * Belgium National Register Number (Rijksregisternummer)
10
10
  * Canadian Social Insurance Numbers (SINs)
11
- * Swiss social security numbers
12
11
  * Chinese Resident Identity Card Number
13
12
  * Czech birth numbers
14
13
  * Germany Steuer-IdNr
15
14
  * Denmark Personal Identification Number (Det Centrale Personregister (CPR))
16
- * Spain National Identity Document (Documento Nacional de Identidad (DNI)) number
15
+ * Estonian Personal Identification Code (Isikukood (IK))
17
16
  * Finland Personal Identity Code (Finnish: henkilötunnus (HETU))
18
17
  * France INSEE code
19
18
  * Ireland Personal Public Service Number (PPS No)
@@ -24,7 +23,9 @@ Find version information in the CHANGELOG.
24
23
  * Netherlands Citizen's Service Number (Burgerservicenummer)
25
24
  * Norway birth number (Fødselsnummer)
26
25
  * Pakistan computerised national identity card number (CNIC)
26
+ * Spain National Identity Document (Documento Nacional de Identidad (DNI)) number
27
27
  * Sweden Personal Identity Number (Personnummer)
28
+ * Swiss social security numbers
28
29
  * United Kingdom National Insurance number (NINO)
29
30
  * United Kingdom National Health Service number
30
31
  * United Kingdom CHI (Community Health Index) number
@@ -0,0 +1,54 @@
1
+ module SocialSecurityNumber
2
+ # SocialSecurityNumber::Ee validates Estonian Personal ID numbers (isikukood (IK))
3
+ # https://en.wikipedia.org/wiki/National_identification_number#Estonia
4
+ # https://et.wikipedia.org/wiki/Isikukood
5
+ class Ee < Country
6
+ def validate
7
+ @error = if !check_digits
8
+ 'it is not number'
9
+ elsif !check_length(11)
10
+ 'number should be length of 11'
11
+ elsif @parsed_civil_number[:gnd].to_i > 8
12
+ 'gender number is not recognized'
13
+ elsif !birth_date
14
+ 'number birth date is invalid'
15
+ elsif !check_control_sum
16
+ 'number control sum invalid'
17
+ end
18
+ end
19
+
20
+ def year
21
+ if @parsed_civil_number
22
+ base = case @parsed_civil_number[:gnd].to_i
23
+ when 1..2 then 1800
24
+ when 3..4 then 1900
25
+ when 5..6 then 2000
26
+ when 7..8 then 2100
27
+ else
28
+ 0
29
+ end
30
+ @year = base + @parsed_civil_number[:year].to_i
31
+ else
32
+ 0
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ MODULUS = 11
39
+
40
+ CONTROLCIPHERS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1].freeze
41
+
42
+ REGEXP = /^(?<gnd>\d{1})#{SHORT_DATE_REGEXP}-?(?<indv>\d{3})(?<ctrl>\d{1})$/
43
+
44
+ def check_control_sum
45
+ count_last_number == @control_number.to_i
46
+ end
47
+
48
+ def count_last_number
49
+ sum = calc_sum(@civil_number[0..9], CONTROLCIPHERS)
50
+ last_number = sum % MODULUS
51
+ sum - (last_number * MODULUS)
52
+ end
53
+ end
54
+ end
@@ -1,7 +1,7 @@
1
1
  module SocialSecurityNumber
2
2
  # SocialSecurityNumber::Validator
3
3
  class Validator
4
- SUPPORTED_COUNTRY_CODES = %w[BE CA CH CN CZ DE DK ES FI FR GB IE
4
+ SUPPORTED_COUNTRY_CODES = %w[BE CA CH CN CZ DE DK EE ES FI FR GB IE
5
5
  IS IT LT MX NL NO PK SE US].freeze
6
6
 
7
7
  attr_accessor :civil_number, :country_code, :error
@@ -1,3 +1,3 @@
1
1
  module SocialSecurityNumber
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'
3
3
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["devops@samesystem.com"]
11
11
 
12
12
  spec.summary = %q{It provides validators for national identification numbers.}
13
- spec.description = %q{It provides validators for national identification numbers. Currently the following countries are supported: Belgium, Canada, China, Czech Republic, Denmark, Germany, Finland, France, Iceland, Ireland, Italy, Lithuania, Mexico, Netherlands, Norway, Pakistan, Spain, Sweden, Switzerland, United Kingdom, United States }
13
+ spec.description = %q{It provides validators for national identification numbers. Currently the following countries are supported: Belgium, Canada, China, Czech Republic, Denmark, Estonia, Germany, Finland, France, Iceland, Ireland, Italy, Lithuania, Mexico, Netherlands, Norway, Pakistan, Spain, Sweden, Switzerland, United Kingdom, United States }
14
14
  spec.homepage = "https://github.com/samesystem/social_security_number"
15
15
  spec.license = "MIT"
16
16
 
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.6
4
+ version: 0.1.7
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-28 00:00:00.000000000 Z
11
+ date: 2017-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '3.0'
55
55
  description: 'It provides validators for national identification numbers. Currently
56
56
  the following countries are supported: Belgium, Canada, China, Czech Republic, Denmark,
57
- Germany, Finland, France, Iceland, Ireland, Italy, Lithuania, Mexico, Netherlands,
57
+ Estonia, Germany, Finland, France, Iceland, Ireland, Italy, Lithuania, Mexico, Netherlands,
58
58
  Norway, Pakistan, Spain, Sweden, Switzerland, United Kingdom, United States '
59
59
  email:
60
60
  - devops@samesystem.com
@@ -81,6 +81,7 @@ files:
81
81
  - lib/social_security_number/country/cz.rb
82
82
  - lib/social_security_number/country/de.rb
83
83
  - lib/social_security_number/country/dk.rb
84
+ - lib/social_security_number/country/ee.rb
84
85
  - lib/social_security_number/country/es.rb
85
86
  - lib/social_security_number/country/fi.rb
86
87
  - lib/social_security_number/country/fr.rb
@@ -119,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
120
  version: '0'
120
121
  requirements: []
121
122
  rubyforge_project:
122
- rubygems_version: 2.6.13
123
+ rubygems_version: 2.6.14
123
124
  signing_key:
124
125
  specification_version: 4
125
126
  summary: It provides validators for national identification numbers.