e-id 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/TODO.md +8 -0
- data/lib/e-id.rb +1 -0
- data/lib/eid/core.rb +2 -0
- data/lib/eid/latvia.rb +56 -0
- data/lib/eid/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f6d6da8667f2637e77c105d3a311bc4742a84250fc67c3d8add1ee20e4f45a6
|
4
|
+
data.tar.gz: e380f4ca4b67c6402d45e600f70b9daaea1cf9f13092683b8fd7ed42a9672a2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8976fee6f2850417ff7c987283202d3de7e03ca67867be2ced0f92d58702b4f7bbb3f1d3e079453b32285e7d6bfd2274ec11f431df151c47e334c18a4cdbc78a
|
7
|
+
data.tar.gz: 5b62029106040fbbe886a2ffe259091e3f5f6cfe2dd09310ab59db4d8cee40669d64ce03cf422dc8756fdbaff54bac70550b198e384ff65dc3a3612a62824649
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -8,7 +8,7 @@ Electronic identity in Estonia and in other countries
|
|
8
8
|
- [x] Finland
|
9
9
|
- [ ] Sweden
|
10
10
|
- [x] Lithuania
|
11
|
-
- [
|
11
|
+
- [x] Latvia
|
12
12
|
- [ ] Denmark
|
13
13
|
|
14
14
|
## Installation
|
@@ -16,7 +16,7 @@ Electronic identity in Estonia and in other countries
|
|
16
16
|
Add this line to your application's Gemfile:
|
17
17
|
|
18
18
|
```ruby
|
19
|
-
gem 'e-id', '~> 0.
|
19
|
+
gem 'e-id', '~> 0.3.0'
|
20
20
|
```
|
21
21
|
|
22
22
|
And then execute:
|
data/TODO.md
ADDED
data/lib/e-id.rb
CHANGED
data/lib/eid/core.rb
CHANGED
data/lib/eid/latvia.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Eid
|
4
|
+
class Latvia < Core
|
5
|
+
# NOTE: identity DDMMYY-XNNNZ
|
6
|
+
# DDMYY - date of birth
|
7
|
+
# X - century
|
8
|
+
# NNN - birth serial number
|
9
|
+
# Z - checksum digit
|
10
|
+
#
|
11
|
+
# 32XXXX-XXXXC (updated format since 01.07.2017)
|
12
|
+
# 32 - updated format indicator
|
13
|
+
# XXXX-XXXX - random numbers
|
14
|
+
# C - checksum
|
15
|
+
|
16
|
+
def legacy?
|
17
|
+
!identity.start_with?('32')
|
18
|
+
end
|
19
|
+
|
20
|
+
def valid?
|
21
|
+
legacy? ? (valid_format? && birth_date.is_a?(Date)) : valid_format?
|
22
|
+
end
|
23
|
+
|
24
|
+
def female?
|
25
|
+
raise 'Not supported'
|
26
|
+
end
|
27
|
+
|
28
|
+
def male?
|
29
|
+
raise 'Not supported'
|
30
|
+
end
|
31
|
+
|
32
|
+
def gender
|
33
|
+
raise 'Not supported'
|
34
|
+
end
|
35
|
+
|
36
|
+
def birth_date
|
37
|
+
Date.new(century + identity[4..5].to_i, identity[2..3].to_i, identity[0..1].to_i) if legacy?
|
38
|
+
rescue StandardError
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def valid_format?
|
45
|
+
identity.match?(/\d{6}-\d{5}/) && identity.size == 12
|
46
|
+
end
|
47
|
+
|
48
|
+
def century
|
49
|
+
case identity[7].to_i
|
50
|
+
when 1 then 1900
|
51
|
+
when 2 then 2000
|
52
|
+
else 2100
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/eid/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: e-id
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tab
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- LICENSE.txt
|
63
63
|
- README.md
|
64
64
|
- Rakefile
|
65
|
+
- TODO.md
|
65
66
|
- bin/console
|
66
67
|
- bin/setup
|
67
68
|
- docker-compose.yaml
|
@@ -70,6 +71,7 @@ files:
|
|
70
71
|
- lib/eid/core.rb
|
71
72
|
- lib/eid/estonia.rb
|
72
73
|
- lib/eid/finland.rb
|
74
|
+
- lib/eid/latvia.rb
|
73
75
|
- lib/eid/lithuania.rb
|
74
76
|
- lib/eid/version.rb
|
75
77
|
homepage: https://github.com/tab/e-id
|