turkish_id 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbb26b22018a74e1d6f96e7a99fb04b67e62763b3470b3fa3b4efebd347dee95
4
- data.tar.gz: 426878d705b49faeb15398622e4746a30f0955cb31fe80c27f8193be72397297
3
+ metadata.gz: f4684fceace032af39d2544af388d2fdf0ab924a222c1a0e270d0e6aa85e017a
4
+ data.tar.gz: f60561764a5b5e51509a1347556ae0ef3783769e298362299506a4407839741b
5
5
  SHA512:
6
- metadata.gz: 662308d80cd939cdeaccb7e121d84b26051f2f29827d54ec617a17786d372d8f985ddd964c33547e7c693226aedc138d98e18e728655ddee67d74ab73f498cf5
7
- data.tar.gz: 2a0e0d9fe6f032e5d7a7766281fbbeae8610b35eaa06758edeaaf959c766a4d19d96e317bdf5bd946fda02f3d3d31bb6cbb2359aca79a05b4b69088316daa4f2
6
+ metadata.gz: 3b0430b78f2e136a35f3a260a5b392aecc73a288fd7aeea4c67030d95723977776abc12fc9ab72a13972598e2aaf320fe6cc5667419ce666b8298c8f560445f5
7
+ data.tar.gz: 8320d6109db78d527919c117be76a9ea52642f467f41ddcc80cd56f182859fbfbaf2aecf512958b7e1c04628aa68ac0770100c6a8573068c2314114dc0ecbde0
data/README.md CHANGED
@@ -22,6 +22,8 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
+ ### Validating ID Numbers
26
+
25
27
  Create a new instance:
26
28
 
27
29
  ```rb
@@ -31,59 +33,38 @@ identity_number = TurkishId.new(10000000146)
31
33
  Use ```is_valid?``` method to check validity:
32
34
 
33
35
  ```rb
34
- identity_number.is_valid?
35
- => true
36
+ identity_number.is_valid? #=> true
36
37
  ```
37
38
 
38
39
  Or use the command line executable:
39
40
 
40
41
  ```sh
41
- $ turkish_id 10000000078
42
- Your identification number is valid.
42
+ $ turkish_id 10000000078 #=> Your identification number is valid.
43
43
  ```
44
44
 
45
- ## Anatomy of the Turkish ID Number
46
-
47
- The Turkish Identification Number consists of ```11``` digits.
48
-
49
- There are three conditions for a valid identification number:
50
-
51
- 1. ```d1 > 0```
52
- 2. ```d10 == ((d1 + d3 + d5 + d7 + d9) * 7 - (d2 + d4 + d6 + d8)) mod 10```
53
- 3. ```d11 == (d1 + d2 + d3 + d4 + d5 + d6 + d8 + d9 + d10) mod 10```
54
-
55
- Where ```dn``` refers to the ```n-th``` digit of the identification number.
56
-
57
- Remember that a valid identification number does not imply the existence of an ID. It could only be used as a preliminary check e.g. before querying a government website. This is very similar to credit card validation.
58
-
59
-
60
- ## Generating Relatives
45
+ ### Generating Relatives
61
46
 
62
47
  You can generate ID numbers for your younger or elder relatives.
63
48
 
64
49
  ```rb
65
50
  me = TurkishId.new(10000000146)
66
- me.elder_relatives.take(5)
67
51
  ```
68
52
 
69
53
  Calling `younger_relative` or `elder_relative` will return an Enumerable class.
70
54
 
71
55
  ```rb
72
- me.elder_relative
73
- #=> #<Enumerator:0x00007f9e629032d0>
56
+ me.elder_relative #=> #<Enumerator:0x00007f9e629032d0>
74
57
  ```
75
58
 
76
59
  You can perform standard Enumerable operations on it.
77
60
 
78
61
  ```rb
79
- me.elder_relative.first
80
-
81
- #=> 10003000082
62
+ me.elder_relative.first #=> 10003000082
82
63
  ```
83
64
 
84
65
  ```rb
85
66
  3.times do
86
- puts me.elder_relative.next()
67
+ puts me.elder_relative.next
87
68
  end
88
69
 
89
70
  #=> 10035998982
@@ -92,13 +73,30 @@ end
92
73
  ```
93
74
 
94
75
  ```rb
95
- me.elder_relative.take(5)
96
-
97
- #=> [10003000082, 10005999902, 10008999848, 10011999774, 10014999610]
76
+ me.elder_relative.take(5) #=> [10003000082, 10005999902, 10008999848, 10011999774, 10014999610]
98
77
  ```
99
78
 
100
79
  And so on.
101
80
 
81
+ ## Anatomy of the Turkish ID Number
82
+
83
+ The Turkish Identification Number consists of ```11``` digits.
84
+
85
+ There are three conditions for a valid identification number:
86
+
87
+ 1. ```d1 > 0```
88
+ 2. ```d10 == ((d1 + d3 + d5 + d7 + d9) * 7 - (d2 + d4 + d6 + d8)) mod 10```
89
+ 3. ```d11 == (d1 + d2 + d3 + d4 + d5 + d6 + d8 + d9 + d10) mod 10```
90
+
91
+ Where ```dn``` refers to the ```n-th``` digit of the identification number.
92
+
93
+ Remember that a valid identification number does not imply the existence of an ID. It could only be used as a preliminary check e.g. before querying a government website. This is very similar to credit card validation.
94
+
95
+ ## Support
96
+
97
+ This gem is used in production and tested against the following Ruby versions: `ruby-head`,  `2.5.1`, `2.4.4`, `2.3.7`, `2.2.10`, `2.1.8`, `1.9.3`. It has no dependencies and will likely work in any Ruby version above `1.9.3`. To make sure there are no breaking changes add it to your Gemfile using the pessimistic operator: `gem 'turkish_id', '~> 0.5.0'`.
98
+
99
+
102
100
  ## Development
103
101
 
104
102
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -115,9 +113,12 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
115
113
 
116
114
  Bug reports and pull requests are welcome on GitHub at https://github.com/krmbzds/turkish_id.
117
115
 
116
+ ## Is it any good?
117
+
118
+ Yes.
118
119
 
119
120
  ## License
120
121
 
121
- Copyright © 2015 Kerem Bozdaş
122
+ Copyright © 2015 [Kerem Bozdaş](http://kerembozdas.com/)
122
123
 
123
124
  This gem is available under the terms of the [MIT License](https://github.com/krmbzds/turkish_id/blob/master/LICENSE.txt).
data/lib/turkish_id.rb CHANGED
@@ -55,6 +55,7 @@ class TurkishId
55
55
  id = join_num(id_array)
56
56
  loop do
57
57
  id = next_relative(id, direction)
58
+ break unless id.between?(100000001, 999999999)
58
59
  y << append_checksum(id)
59
60
  end
60
61
  end
@@ -1,3 +1,3 @@
1
1
  class TurkishId
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turkish_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kerem Bozdas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-25 00:00:00.000000000 Z
11
+ date: 2018-07-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Validate Turkish Identification Numbers and More!
14
14
  email: