ukrainian_id_number 1.0.0 → 1.1.1

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: 8cc7932981f1a2a971ef20a023db69de6c25c3584253763232a8627251439ca8
4
- data.tar.gz: 4c263fcf013f3cc00b3e3eb5c5f2f843d30595afd6e214971fc490e2f89fd7b4
3
+ metadata.gz: 600972250689ccf3f394583c5ef67f56a2a6e5957d40479e22d77c1f7d607be5
4
+ data.tar.gz: da53096cbcae8cc07622447d0423afef3e484cc84f670f70a791d6736a2c98b8
5
5
  SHA512:
6
- metadata.gz: f29f0bb77ea069d3d4bb3f980c3a1392d1c91e09ca2e8517634f6ab2bd3ff31aa33730bb6b4951368e25e6e064ce921b302474deda3a507165da21181ebcbd4f
7
- data.tar.gz: e32183587398595dbdd5f1b789ed8da91589125f3d017a6403a1741b56b58ced8d8782abb7911fee04b505e5cc1ad03858ba15544dee9c19a4bbfa03de73116a
6
+ metadata.gz: c87f277ef22b07e54c0e4299fc78a2aee584cc69efff85e05a64c25dfe2cb59dd11796fb6f5d50cccc812d91e2d074fa36295dc209e26d8419d9783703dbb4c3
7
+ data.tar.gz: 9c001ba3c2146f92620bd78ce248a15c9e5864601407e795e5b6a0fad4eccd5824fb1e53ca4eec60ffa2e2e694e767b0e95f4f5cd1e7a1aec8915495a980a248
@@ -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
@@ -1,5 +1,12 @@
1
- ## [Unreleased]
2
-
3
- ## [0.1.0] - 2024-01-09
1
+ ## [1.0.0] - 2024-01-09
4
2
 
5
3
  - Initial release
4
+
5
+ ## [1.1.0] - 2024-01-12
6
+
7
+ - Added method `valid?` to check if provided ID number is valid
8
+
9
+ ## [1.1.1] - 2024-01-12
10
+
11
+ - Corrected description and summary
12
+ - Fixed incorrect link to CHANGELOG.md
data/README.md CHANGED
@@ -1,24 +1,23 @@
1
- # UkrainianIdNumber
1
+ # Ukrainian ID Number
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
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 UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
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 UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
13
+ $ gem install ukrainian_id_number
18
14
 
19
15
  ## Usage
20
-
21
- TODO: Write usage instructions here
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/[USERNAME]/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/[USERNAME]/ukrainian_id_number/blob/main/CODE_OF_CONDUCT.md).
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/[USERNAME]/ukrainian_id_number/blob/main/CODE_OF_CONDUCT.md).
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).
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UkrainianIdNumber
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.1"
5
5
  end
@@ -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 = (start_date + birthday_token.to_i) - 1
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
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Yaroslav Nychka"]
9
9
  spec.email = ["Yaroslav Nychka"]
10
10
 
11
- spec.summary = "Get useful information from ukrainian id number"
12
- spec.description = "Ukrainian ID number or taxpayer 10-digit number"
11
+ spec.summary = "Get birthday of Ukrainian taxpayer by 10-digit tax number"
12
+ spec.description = "Get birthday of Ukrainian taxpayer by 10-digit tax number"
13
13
  spec.homepage = "https://github.com/ynychka/ukrainian_id_number"
14
14
  spec.license = "MIT"
15
15
  spec.required_ruby_version = ">= 2.6.0"
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.metadata["homepage_uri"] = spec.homepage
20
20
  spec.metadata["source_code_uri"] = "https://github.com/ynychka/ukrainian_id_number"
21
- spec.metadata["changelog_uri"] = "https://github.com/ynychka/ukrainian_id_number/CHANGELOG.md"
21
+ spec.metadata["changelog_uri"] = "https://github.com/ynychka/ukrainian_id_number/blob/main/CHANGELOG.md"
22
22
 
23
23
  # Specify which files should be added to the gem when it is released.
24
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ukrainian_id_number
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
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-09 00:00:00.000000000 Z
11
+ date: 2024-01-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Ukrainian ID number or taxpayer 10-digit number
13
+ description: Get birthday of Ukrainian taxpayer by 10-digit tax number
14
14
  email:
15
15
  - Yaroslav Nychka
16
16
  executables: []
@@ -41,7 +41,7 @@ metadata:
41
41
  allowed_push_host: https://rubygems.org
42
42
  homepage_uri: https://github.com/ynychka/ukrainian_id_number
43
43
  source_code_uri: https://github.com/ynychka/ukrainian_id_number
44
- changelog_uri: https://github.com/ynychka/ukrainian_id_number/CHANGELOG.md
44
+ changelog_uri: https://github.com/ynychka/ukrainian_id_number/blob/main/CHANGELOG.md
45
45
  post_install_message:
46
46
  rdoc_options: []
47
47
  require_paths:
@@ -60,5 +60,5 @@ requirements: []
60
60
  rubygems_version: 3.4.19
61
61
  signing_key:
62
62
  specification_version: 4
63
- summary: Get useful information from ukrainian id number
63
+ summary: Get birthday of Ukrainian taxpayer by 10-digit tax number
64
64
  test_files: []