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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cc7932981f1a2a971ef20a023db69de6c25c3584253763232a8627251439ca8
4
- data.tar.gz: 4c263fcf013f3cc00b3e3eb5c5f2f843d30595afd6e214971fc490e2f89fd7b4
3
+ metadata.gz: 691d2701aef796184f1aad5249d461eb436a3176d08527d82999d26d545a8e88
4
+ data.tar.gz: ce92ee2eb4aa7e616821e32b8398769a6bb6444e776d65d5bb41461768c875ce
5
5
  SHA512:
6
- metadata.gz: f29f0bb77ea069d3d4bb3f980c3a1392d1c91e09ca2e8517634f6ab2bd3ff31aa33730bb6b4951368e25e6e064ce921b302474deda3a507165da21181ebcbd4f
7
- data.tar.gz: e32183587398595dbdd5f1b789ed8da91589125f3d017a6403a1741b56b58ced8d8782abb7911fee04b505e5cc1ad03858ba15544dee9c19a4bbfa03de73116a
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
@@ -1,5 +1,7 @@
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
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.0"
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
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.0.0
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-09 00:00:00.000000000 Z
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: