ukrainian_id_number 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/ukrainian_id_number.iml +1 -0
- data/CHANGELOG.md +5 -3
- data/README.md +11 -12
- data/lib/ukrainian_id_number/version.rb +1 -1
- data/lib/ukrainian_id_number.rb +18 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 691d2701aef796184f1aad5249d461eb436a3176d08527d82999d26d545a8e88
|
4
|
+
data.tar.gz: ce92ee2eb4aa7e616821e32b8398769a6bb6444e776d65d5bb41461768c875ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6a1d46ef7dcf7097757920e246b3e06af868301659d2f39554aaa3cc39e0b356fb4adf887844806bc7332c1b6f7bd7981eb18a917bf91a89ee257c755862a65
|
7
|
+
data.tar.gz: f39b940b2ef13472b889e01b5c795d438f46064a999f1c1f6d733d700a5c129b6d821f13af91ff15d3c68973da5597c5dfae73444d459b8de902537436aa0900
|
@@ -11,6 +11,7 @@
|
|
11
11
|
</content>
|
12
12
|
<orderEntry type="inheritedJdk" />
|
13
13
|
<orderEntry type="sourceFolder" forTests="false" />
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.3.1, ruby-2.6.8-p205) [gem]" level="application" />
|
14
15
|
</component>
|
15
16
|
<component name="RakeTasksCache">
|
16
17
|
<option name="myRootTask">
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,24 +1,23 @@
|
|
1
|
-
#
|
1
|
+
# Ukrainian ID Number
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ukrainian_id_number`. To experiment with that code, run `bin/console` for an interactive prompt.
|
3
|
+
Provide 10-digit Ukrainian taxpayer number and get birthday
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
10
|
-
|
11
7
|
Install the gem and add to the application's Gemfile by executing:
|
12
8
|
|
13
|
-
$ bundle add
|
9
|
+
$ bundle add ukrainian_id_number
|
14
10
|
|
15
11
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
12
|
|
17
|
-
$ gem install
|
13
|
+
$ gem install ukrainian_id_number
|
18
14
|
|
19
15
|
## Usage
|
20
|
-
|
21
|
-
|
16
|
+
```
|
17
|
+
id_number = '3401600000' # 10-digit ID number
|
18
|
+
result = UkrainianIdNumber::Processor.new(id_number).call
|
19
|
+
result.birthday.to_s # => 1993-02-17
|
20
|
+
```
|
22
21
|
|
23
22
|
## Development
|
24
23
|
|
@@ -28,7 +27,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
28
27
|
|
29
28
|
## Contributing
|
30
29
|
|
31
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
30
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ynychka/ukrainian_id_number. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/ynychka/ukrainian_id_number/blob/main/CODE_OF_CONDUCT.md).
|
32
31
|
|
33
32
|
## License
|
34
33
|
|
@@ -36,4 +35,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
36
35
|
|
37
36
|
## Code of Conduct
|
38
37
|
|
39
|
-
Everyone interacting in the UkrainianIdNumber project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
38
|
+
Everyone interacting in the UkrainianIdNumber project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ynychka/ukrainian_id_number/blob/main/CODE_OF_CONDUCT.md).
|
data/lib/ukrainian_id_number.rb
CHANGED
@@ -8,19 +8,34 @@ module UkrainianIdNumber
|
|
8
8
|
|
9
9
|
class Processor
|
10
10
|
attr_reader :id_number, :start_date, :birthday
|
11
|
+
|
12
|
+
CORRECTION = 1
|
11
13
|
def initialize(id_number)
|
12
|
-
@id_number = id_number
|
13
|
-
@start_date = Date.parse('1 Jan 1900')
|
14
|
+
@id_number = id_number.to_s
|
14
15
|
end
|
15
16
|
|
16
17
|
def call
|
17
|
-
@birthday =
|
18
|
+
@birthday = process_birthday
|
18
19
|
|
19
20
|
self
|
20
21
|
end
|
21
22
|
|
23
|
+
def valid?
|
24
|
+
return false unless (id_number && !id_number.empty?)
|
25
|
+
|
26
|
+
!!(id_number =~ /^\d{10}$/)
|
27
|
+
end
|
28
|
+
|
22
29
|
private
|
23
30
|
|
31
|
+
def start_date
|
32
|
+
@start_date ||= Date.parse('1 Jan 1900')
|
33
|
+
end
|
34
|
+
|
35
|
+
def process_birthday
|
36
|
+
(start_date + birthday_token.to_i) - CORRECTION
|
37
|
+
end
|
38
|
+
|
24
39
|
def birthday_token
|
25
40
|
@id_number[0..4]
|
26
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ukrainian_id_number
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaroslav Nychka
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ukrainian ID number or taxpayer 10-digit number
|
14
14
|
email:
|