e-id 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.dockerignore +13 -0
- data/.editorconfig +9 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +7 -0
- data/.github/dependabot.yml +19 -0
- data/.github/workflows/checks.yaml +34 -0
- data/.github/workflows/release.yaml +53 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +19 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Dockerfile +13 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +77 -0
- data/LICENSE.txt +21 -0
- data/README.md +83 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/docker-compose.yaml +7 -0
- data/e-id.gemspec +44 -0
- data/lib/e-id.rb +5 -0
- data/lib/eid/core.rb +11 -0
- data/lib/eid/estonia.rb +48 -0
- data/lib/eid/version.rb +5 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 95f1117835526ba0fa98a96f073c540d7cca1bd83016581060ec067f0280b746
|
4
|
+
data.tar.gz: a866ae7a9bcba3feb047929dd983437f08dd3f052367c0b78b88b977884c4666
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5ac32ed7526f059926411f54cfd64f950b554868c704246206157a77776c8a3201a6441921e1e6143b4e2804a5799abc90d2fd3bb49e8ae4de9a0b26acc6568c
|
7
|
+
data.tar.gz: f27d33289cebfc93546ec3d52927cd305884f400886e2d158ad5128c6bb8b83c7e1571f6ffb1fcea2a9362d487652091898cd2b05c02e7c1e660fc14481becb4
|
data/.dockerignore
ADDED
data/.editorconfig
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates
|
2
|
+
|
3
|
+
version: 2
|
4
|
+
updates:
|
5
|
+
- package-ecosystem: github-actions
|
6
|
+
directory: /
|
7
|
+
schedule:
|
8
|
+
interval: daily
|
9
|
+
assignees:
|
10
|
+
- "tab"
|
11
|
+
open-pull-requests-limit: 10
|
12
|
+
|
13
|
+
- package-ecosystem: bundler
|
14
|
+
directory: /
|
15
|
+
schedule:
|
16
|
+
interval: daily
|
17
|
+
assignees:
|
18
|
+
- "tab"
|
19
|
+
open-pull-requests-limit: 10
|
@@ -0,0 +1,34 @@
|
|
1
|
+
name: PR checks
|
2
|
+
on:
|
3
|
+
pull_request:
|
4
|
+
types: [opened, reopened, synchronize, ready_for_review]
|
5
|
+
concurrency:
|
6
|
+
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
|
7
|
+
cancel-in-progress: true
|
8
|
+
jobs:
|
9
|
+
rspec:
|
10
|
+
name: RSpec with ruby ${{matrix.ruby}}
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
fail-fast: false
|
14
|
+
matrix:
|
15
|
+
ruby: ['2.6', '2.7', '3.0', '3.1', head]
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v3
|
18
|
+
- uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: ${{matrix.ruby}}
|
21
|
+
bundler-cache: true
|
22
|
+
- name: Test with RSpec
|
23
|
+
run: bundle exec rspec
|
24
|
+
rubocop:
|
25
|
+
name: RuboCop
|
26
|
+
runs-on: ubuntu-latest
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v3
|
29
|
+
- uses: ruby/setup-ruby@v1
|
30
|
+
with:
|
31
|
+
ruby-version: 3.1.3
|
32
|
+
bundler-cache: true
|
33
|
+
- name: Check with RuboCop
|
34
|
+
run: bundle exec rubocop
|
@@ -0,0 +1,53 @@
|
|
1
|
+
name: Release
|
2
|
+
on:
|
3
|
+
release:
|
4
|
+
types: [ released ]
|
5
|
+
jobs:
|
6
|
+
rubocop:
|
7
|
+
name: RuboCop
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
steps:
|
10
|
+
- uses: actions/checkout@v3
|
11
|
+
- uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 3.1.3
|
14
|
+
bundler-cache: true
|
15
|
+
- name: Check with RuboCop
|
16
|
+
run: bundle exec rubocop
|
17
|
+
rspec:
|
18
|
+
name: RSpec with ruby ${{matrix.ruby}}
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
needs: rubocop
|
21
|
+
strategy:
|
22
|
+
fail-fast: false
|
23
|
+
matrix:
|
24
|
+
ruby: ['2.6', '2.7', '3.0', '3.1', head]
|
25
|
+
steps:
|
26
|
+
- uses: actions/checkout@v3
|
27
|
+
- uses: ruby/setup-ruby@v1
|
28
|
+
with:
|
29
|
+
ruby-version: ${{matrix.ruby}}
|
30
|
+
bundler-cache: true
|
31
|
+
- name: Test with RSpec
|
32
|
+
run: bundle exec rspec
|
33
|
+
build-and-push:
|
34
|
+
name: Build and push gem
|
35
|
+
runs-on: ubuntu-latest
|
36
|
+
needs: rspec
|
37
|
+
steps:
|
38
|
+
- uses: actions/checkout@v3
|
39
|
+
- uses: ruby/setup-ruby@v1
|
40
|
+
with:
|
41
|
+
ruby-version: 3.1.3
|
42
|
+
bundler-cache: true
|
43
|
+
- name: Setup credentials
|
44
|
+
run: |
|
45
|
+
mkdir -p $HOME/.gem
|
46
|
+
touch $HOME/.gem/credentials
|
47
|
+
chmod 0600 $HOME/.gem/credentials
|
48
|
+
printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials
|
49
|
+
env:
|
50
|
+
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|
51
|
+
- name: Release gem
|
52
|
+
run: |
|
53
|
+
bundle exec rake release
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rspec
|
3
|
+
- rubocop-performance
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
NewCops: enable
|
7
|
+
SuggestExtensions: false
|
8
|
+
TargetRubyVersion: 2.6
|
9
|
+
|
10
|
+
RSpec/NestedGroups:
|
11
|
+
Enabled: true
|
12
|
+
Max: 5
|
13
|
+
|
14
|
+
Style/Documentation:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Naming/FileName:
|
18
|
+
Exclude:
|
19
|
+
- lib/e-id.rb
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Dockerfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
FROM ruby:3.1.3-alpine3.17
|
2
|
+
|
3
|
+
WORKDIR /package
|
4
|
+
|
5
|
+
COPY . .
|
6
|
+
|
7
|
+
RUN apk add --update-cache --no-cache --virtual .build-deps g++ make \
|
8
|
+
&& apk add --update-cache --no-cache gcompat git openssh-client \
|
9
|
+
&& bundle install --jobs $(nproc) --retry 3 \
|
10
|
+
&& rm -rf /usr/local/bundle/cache/*.gem \
|
11
|
+
&& find /usr/local/bundle/gems/ -name "*.c" -delete \
|
12
|
+
&& find /usr/local/bundle/gems/ -name "*.o" -delete \
|
13
|
+
&& apk --purge del .build-deps
|
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
6
|
+
|
7
|
+
gemspec
|
8
|
+
|
9
|
+
group :development, :test do
|
10
|
+
gem 'rspec', '~> 3.12.0'
|
11
|
+
gem 'rubocop', '~> 1.50.2'
|
12
|
+
gem 'rubocop-performance', '~> 1.16.0'
|
13
|
+
gem 'rubocop-rspec', '~> 2.19.0'
|
14
|
+
end
|
15
|
+
|
16
|
+
group :test do
|
17
|
+
gem 'simplecov', '~> 0.22.0'
|
18
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
e-id (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.2)
|
10
|
+
diff-lcs (1.5.0)
|
11
|
+
docile (1.4.0)
|
12
|
+
json (2.6.3)
|
13
|
+
parallel (1.23.0)
|
14
|
+
parser (3.2.2.1)
|
15
|
+
ast (~> 2.4.1)
|
16
|
+
rainbow (3.1.1)
|
17
|
+
rake (13.0.6)
|
18
|
+
regexp_parser (2.8.0)
|
19
|
+
rexml (3.2.5)
|
20
|
+
rspec (3.12.0)
|
21
|
+
rspec-core (~> 3.12.0)
|
22
|
+
rspec-expectations (~> 3.12.0)
|
23
|
+
rspec-mocks (~> 3.12.0)
|
24
|
+
rspec-core (3.12.2)
|
25
|
+
rspec-support (~> 3.12.0)
|
26
|
+
rspec-expectations (3.12.3)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.12.0)
|
29
|
+
rspec-mocks (3.12.5)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.12.0)
|
32
|
+
rspec-support (3.12.0)
|
33
|
+
rubocop (1.50.2)
|
34
|
+
json (~> 2.3)
|
35
|
+
parallel (~> 1.10)
|
36
|
+
parser (>= 3.2.0.0)
|
37
|
+
rainbow (>= 2.2.2, < 4.0)
|
38
|
+
regexp_parser (>= 1.8, < 3.0)
|
39
|
+
rexml (>= 3.2.5, < 4.0)
|
40
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
41
|
+
ruby-progressbar (~> 1.7)
|
42
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
43
|
+
rubocop-ast (1.28.0)
|
44
|
+
parser (>= 3.2.1.0)
|
45
|
+
rubocop-capybara (2.18.0)
|
46
|
+
rubocop (~> 1.41)
|
47
|
+
rubocop-performance (1.16.0)
|
48
|
+
rubocop (>= 1.7.0, < 2.0)
|
49
|
+
rubocop-ast (>= 0.4.0)
|
50
|
+
rubocop-rspec (2.19.0)
|
51
|
+
rubocop (~> 1.33)
|
52
|
+
rubocop-capybara (~> 2.17)
|
53
|
+
ruby-progressbar (1.13.0)
|
54
|
+
simplecov (0.22.0)
|
55
|
+
docile (~> 1.1)
|
56
|
+
simplecov-html (~> 0.11)
|
57
|
+
simplecov_json_formatter (~> 0.1)
|
58
|
+
simplecov-html (0.12.3)
|
59
|
+
simplecov_json_formatter (0.1.4)
|
60
|
+
unicode-display_width (2.4.2)
|
61
|
+
|
62
|
+
PLATFORMS
|
63
|
+
x86_64-linux
|
64
|
+
x86_64-linux-musl
|
65
|
+
|
66
|
+
DEPENDENCIES
|
67
|
+
bundler (~> 2.3.0)
|
68
|
+
e-id!
|
69
|
+
rake (~> 13.0.6)
|
70
|
+
rspec (~> 3.12.0)
|
71
|
+
rubocop (~> 1.50.2)
|
72
|
+
rubocop-performance (~> 1.16.0)
|
73
|
+
rubocop-rspec (~> 2.19.0)
|
74
|
+
simplecov (~> 0.22.0)
|
75
|
+
|
76
|
+
BUNDLED WITH
|
77
|
+
2.3.26
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 tab
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# E-ID
|
2
|
+
|
3
|
+
Electronic identity in Estonia and in other countries
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'e-id', '~> 0.1.0'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install e-id
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Estonia
|
24
|
+
|
25
|
+
Identity code format is `GYYMMDDSSSC`
|
26
|
+
|
27
|
+
* `G` – gender
|
28
|
+
* `YYMMDD` – date of birth
|
29
|
+
* `SSS` – serial number
|
30
|
+
* `C` – checksum
|
31
|
+
|
32
|
+
More info: https://www.id.ee/en/
|
33
|
+
|
34
|
+
```bash
|
35
|
+
irb -I lib
|
36
|
+
require 'e-id'
|
37
|
+
|
38
|
+
Eid::Estonia.new(50001029996).valid?
|
39
|
+
=> true
|
40
|
+
|
41
|
+
Eid::Estonia.new(50001029996).gender
|
42
|
+
=> :female
|
43
|
+
|
44
|
+
Eid::Estonia.new(50001029996).birth_date
|
45
|
+
=> #<Date: 2000-01-02 ((2451546j,0s,0n),+0s,2299161j)>
|
46
|
+
|
47
|
+
Eid::Estonia.new(50001029996).age
|
48
|
+
=> 23
|
49
|
+
```
|
50
|
+
|
51
|
+
## Development
|
52
|
+
|
53
|
+
Build docker container with compose:
|
54
|
+
|
55
|
+
```bash
|
56
|
+
docker-compose build
|
57
|
+
docker-compose up
|
58
|
+
```
|
59
|
+
|
60
|
+
Access to the container:
|
61
|
+
|
62
|
+
```bash
|
63
|
+
docker-compose exec e-id sh
|
64
|
+
```
|
65
|
+
|
66
|
+
Run rspec or rubocop checks:
|
67
|
+
|
68
|
+
```bash
|
69
|
+
/package # bundle exec rubocop
|
70
|
+
/package # bundle exec rspec
|
71
|
+
```
|
72
|
+
|
73
|
+
## Contributing
|
74
|
+
|
75
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tab/e-id. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
76
|
+
|
77
|
+
## License
|
78
|
+
|
79
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
80
|
+
|
81
|
+
## Code of Conduct
|
82
|
+
|
83
|
+
Everyone interacting in the e-id project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/tab/e-id/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'eid'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/docker-compose.yaml
ADDED
data/e-id.gemspec
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'eid/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'e-id'
|
9
|
+
spec.version = Eid::VERSION
|
10
|
+
spec.authors = ['tab']
|
11
|
+
spec.email = ['tab@users.noreply.github.com']
|
12
|
+
|
13
|
+
spec.summary = 'Electronic identity in Estonia and in other countries'
|
14
|
+
spec.description = 'Electronic identity in Estonia and in other countries'
|
15
|
+
spec.homepage = 'https://github.com/tab/e-id'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.required_ruby_version = '>= 2.6'
|
19
|
+
|
20
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
21
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
22
|
+
if spec.respond_to?(:metadata)
|
23
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
24
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
25
|
+
spec.metadata['changelog_uri'] = 'https://github.com/tab/e-id/blob/master/CHANGELOG.md'
|
26
|
+
else
|
27
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
28
|
+
'public gem pushes.'
|
29
|
+
end
|
30
|
+
|
31
|
+
# Specify which files should be added to the gem when it is released.
|
32
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
33
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
34
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|rspec|rubocop|github)/}) }
|
35
|
+
end
|
36
|
+
spec.bindir = 'exe'
|
37
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
38
|
+
spec.require_paths = ['lib']
|
39
|
+
|
40
|
+
spec.add_development_dependency 'bundler', '~> 2.3.0'
|
41
|
+
spec.add_development_dependency 'rake', '~> 13.0.6'
|
42
|
+
|
43
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
44
|
+
end
|
data/lib/e-id.rb
ADDED
data/lib/eid/core.rb
ADDED
data/lib/eid/estonia.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Eid
|
4
|
+
class Estonia < Core
|
5
|
+
# NOTE: identity GYYMMDDSSSC
|
6
|
+
# G – gender
|
7
|
+
# YYMMDD – date of birth
|
8
|
+
# SSS – serial number
|
9
|
+
# C – checksum
|
10
|
+
|
11
|
+
def valid?
|
12
|
+
identity.size == 11 && birth_date.is_a?(Date)
|
13
|
+
end
|
14
|
+
|
15
|
+
def female?
|
16
|
+
identity[0].to_i.even?
|
17
|
+
end
|
18
|
+
|
19
|
+
def male?
|
20
|
+
identity[0].to_i.odd?
|
21
|
+
end
|
22
|
+
|
23
|
+
def gender
|
24
|
+
female? ? :female : :male
|
25
|
+
end
|
26
|
+
|
27
|
+
def birth_date
|
28
|
+
Date.new((century + identity[1..2].to_i), identity[3..4].to_i, identity[5..6].to_i)
|
29
|
+
rescue StandardError
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def age
|
34
|
+
Date.today.year - birth_date&.year.to_i
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def century
|
40
|
+
case identity[0].to_i
|
41
|
+
when 1..2 then 1800
|
42
|
+
when 3..4 then 1900
|
43
|
+
when 5..6 then 2000
|
44
|
+
else 2100
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/eid/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: e-id
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- tab
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-04-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.3.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.3.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 13.0.6
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 13.0.6
|
41
|
+
description: Electronic identity in Estonia and in other countries
|
42
|
+
email:
|
43
|
+
- tab@users.noreply.github.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".dockerignore"
|
49
|
+
- ".editorconfig"
|
50
|
+
- ".github/PULL_REQUEST_TEMPLATE.md"
|
51
|
+
- ".github/dependabot.yml"
|
52
|
+
- ".github/workflows/checks.yaml"
|
53
|
+
- ".github/workflows/release.yaml"
|
54
|
+
- ".gitignore"
|
55
|
+
- ".rspec"
|
56
|
+
- ".rubocop.yml"
|
57
|
+
- CHANGELOG.md
|
58
|
+
- CODE_OF_CONDUCT.md
|
59
|
+
- Dockerfile
|
60
|
+
- Gemfile
|
61
|
+
- Gemfile.lock
|
62
|
+
- LICENSE.txt
|
63
|
+
- README.md
|
64
|
+
- Rakefile
|
65
|
+
- bin/console
|
66
|
+
- bin/setup
|
67
|
+
- docker-compose.yaml
|
68
|
+
- e-id.gemspec
|
69
|
+
- lib/e-id.rb
|
70
|
+
- lib/eid/core.rb
|
71
|
+
- lib/eid/estonia.rb
|
72
|
+
- lib/eid/version.rb
|
73
|
+
homepage: https://github.com/tab/e-id
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata:
|
77
|
+
homepage_uri: https://github.com/tab/e-id
|
78
|
+
source_code_uri: https://github.com/tab/e-id
|
79
|
+
changelog_uri: https://github.com/tab/e-id/blob/master/CHANGELOG.md
|
80
|
+
rubygems_mfa_required: 'true'
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.6'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubygems_version: 3.3.26
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Electronic identity in Estonia and in other countries
|
100
|
+
test_files: []
|