resident 0.0.14 → 0.0.15
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10570376ab3b4bace53b841cef776196df2ca868f1b58894245f369ed961ee48
|
4
|
+
data.tar.gz: b0ee9c563dca36dc0ef8eea25022970487d157fb648cd0a1078ed4263a12b27a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc5284eb2da72ef4fdd8cc67eb2d1b220fd948b69c8e1e950a5f8c3bdc4d4d36fd8c79d6697d92dd1460f305ea1bd1fe98bc9b0a47a5ae87ddcc5ccf8b87ba54
|
7
|
+
data.tar.gz: 36c549365b79eeaebbfb20cbc01eac1fb70e788e5b284279e17dc35a0cf927d6ab17ad5c6b0c63e2b3a804436fc82c9143f6fa8d066ca86d71685482cb42ace0
|
@@ -25,8 +25,22 @@ module NationalIdentificationNumber
|
|
25
25
|
|
26
26
|
protected
|
27
27
|
|
28
|
+
def parse_twelve_digits
|
29
|
+
return unless @number.match(/\A(\d{4})(\d{2})(\d{2})(\d{4})\Z/)
|
30
|
+
year = $1
|
31
|
+
month = $2
|
32
|
+
day = $3
|
33
|
+
born = Date.new(year.to_i, month.to_i, day.to_i)
|
34
|
+
sep = born < Date.today.prev_year(100) ? '+' : '-'
|
35
|
+
@number = "#{year[2..]}#{month}#{day}#{sep}#{$4}"
|
36
|
+
rescue Date::Error
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
|
28
40
|
def repair
|
29
41
|
super
|
42
|
+
return if parse_twelve_digits
|
43
|
+
|
30
44
|
if @number.match(/\A(\d{0}|\d{2})(\d{6})(\-{0,1})(\d{4})\Z/)
|
31
45
|
@number = "#{$2}-#{$4}"
|
32
46
|
else
|
@@ -47,7 +61,7 @@ module NationalIdentificationNumber
|
|
47
61
|
year = $1.to_i
|
48
62
|
month = $2.to_i
|
49
63
|
day = $3.to_i
|
50
|
-
divider
|
64
|
+
divider = $4 || '-'
|
51
65
|
serial = $5.to_i
|
52
66
|
|
53
67
|
today = Date.today
|
@@ -59,7 +73,6 @@ module NationalIdentificationNumber
|
|
59
73
|
century = 1800
|
60
74
|
else
|
61
75
|
preliminary_age = age_for_dob(Date.parse("#{1900 + year}-#{month}-#{day}")) rescue 0
|
62
|
-
#raise preliminary_age.inspect
|
63
76
|
if preliminary_age > 99
|
64
77
|
# It's unlikely that the person is older than 99, so assume a child when no divider was provided.
|
65
78
|
century = 2000
|
@@ -62,7 +62,7 @@ describe Swedish, '.generate' do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
context 'valid numbers' do
|
65
|
-
it 'is the sanitize
|
65
|
+
it 'is the sanitize number' do
|
66
66
|
expect(Swedish.new('19180123-2669').sanitize).to eq '180123-2669'
|
67
67
|
expect(Swedish.new('00180123-2669').sanitize).to eq '180123-2669'
|
68
68
|
expect(Swedish.new('000180123-2669').sanitize).to eq '180123-2669'
|
@@ -72,6 +72,11 @@ describe Swedish, '.generate' do
|
|
72
72
|
expect(Swedish.new('450202-6950').sanitize).to eq '450202-6950'
|
73
73
|
expect(Swedish.new('19450202-6950').sanitize).to eq '450202-6950'
|
74
74
|
end
|
75
|
+
|
76
|
+
it 'adds - or + depending on century for twelve digit formats' do
|
77
|
+
expect(Swedish.new('202401275181').sanitize).to eq "240127-5181"
|
78
|
+
expect(Swedish.new('192401275181').sanitize).to eq "240127+5181"
|
79
|
+
end
|
75
80
|
end
|
76
81
|
end
|
77
82
|
|
@@ -125,7 +130,7 @@ describe Swedish, '.generate' do
|
|
125
130
|
expect( Swedish.new('0501261853').to_s ).to eq '050126-1853'
|
126
131
|
expect( Swedish.new('050126-1853').to_s ).to eq '050126-1853'
|
127
132
|
expect( Swedish.new('0asdfghj501261853').to_s).to eq '050126-1853'
|
128
|
-
expect( Swedish.new("190501261853").to_s ).to eq '050126
|
133
|
+
expect( Swedish.new("190501261853").to_s ).to eq '050126+1853'
|
129
134
|
expect( Swedish.new("19050126-1853").to_s ).to eq '050126-1853'
|
130
135
|
expect( Swedish.new("19050126-185d3").to_s ).to eq '050126-1853'
|
131
136
|
expect( Swedish.new("19050126-185d3\n").to_s ).to eq '050126-1853'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resident
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bukowskis
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -38,8 +38,8 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description:
|
42
|
-
email:
|
41
|
+
description:
|
42
|
+
email:
|
43
43
|
executables: []
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
@@ -63,7 +63,7 @@ homepage: http://github.com/bukowskis/national_identification_number/
|
|
63
63
|
licenses:
|
64
64
|
- MIT-LICENSE
|
65
65
|
metadata: {}
|
66
|
-
post_install_message:
|
66
|
+
post_install_message:
|
67
67
|
rdoc_options: []
|
68
68
|
require_paths:
|
69
69
|
- lib
|
@@ -79,8 +79,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
|
-
rubygems_version: 3.
|
83
|
-
signing_key:
|
82
|
+
rubygems_version: 3.4.10
|
83
|
+
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: Validate National Identification Numbers.
|
86
86
|
test_files: []
|