za_id_number 2.1.0 → 2.2.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 +4 -4
- data/CHANGES +6 -0
- data/README.md +2 -1
- data/lib/za_id_number/version.rb +1 -1
- data/lib/za_id_number.rb +19 -4
- 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: dd9d77d348b60523b50eb007e2f7d615b41e01291c8152427fc9aed33bbb9f97
|
|
4
|
+
data.tar.gz: 8f1edc87848ff3788b4039ca2f3492e133fac871a9237ced4bd99d6654638a2e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eada6d8d9ef2b92ab1237946123821d49ddabe6ce0131133f7253b1c355c791e8d822b5e495be8266a903d0a00c77b7a8164ccacf8da46b47643283827aa6be2
|
|
7
|
+
data.tar.gz: eb5a7a4b1cfdcd9e97ce0637df59c7799d927b20c96b5033b95663f8a4c775d04aad1228346e977cb6c5940e1f65dac6ae90fa0c8cefa201d218a3c4bd6858ea
|
data/CHANGES
CHANGED
|
@@ -9,6 +9,12 @@ and this project tries really hard to adhere to [Semantic Versioning](https://se
|
|
|
9
9
|
|
|
10
10
|
Nothing
|
|
11
11
|
|
|
12
|
+
## [2.2.0] - 2023-04-05
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- Support for [ID numbers where the citizen is a refugee.](https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/South-Africa-TIN.pdf)
|
|
17
|
+
|
|
12
18
|
## [2.1.0] - 2022-05-31
|
|
13
19
|
|
|
14
20
|
### Added
|
data/README.md
CHANGED
|
@@ -12,7 +12,7 @@ A South African ID number is a 13-digit number which is defined by the following
|
|
|
12
12
|
|
|
13
13
|
- The first 6 digits (`YYMMDD`) are based on your date of birth. **20 February 1992** is displayed as `920220`.
|
|
14
14
|
- The next 4 digits (`SSSS`) are used to define your gender. Females are assigned numbers in the range 0000-4999 and males from 5000-9999.
|
|
15
|
-
- The next digit (`C`) shows if you're a ZA citizen status, with 0 denoting that you were born a ZA citizen
|
|
15
|
+
- The next digit (`C`) shows if you're a ZA citizen status, with 0 denoting that you were born a ZA citizen, 1 denoting that you're a permanent resident and 2 denoting that you're a refugee.
|
|
16
16
|
- The last digit (`Z`) is a checksum digit – used to check that the number sequence is accurate using a set formula called the [Luhn algorithm](https://en.wikipedia.org/wiki/Luhn_algorithm).
|
|
17
17
|
|
|
18
18
|
The graphic below details the different sections of an ID number, based on the fictitious sequence `9202204720082`
|
|
@@ -77,6 +77,7 @@ id_num.male? # => false
|
|
|
77
77
|
id_num.citizenship # => :za_citizen
|
|
78
78
|
id_num.za_citizen? # => true
|
|
79
79
|
id_num.permanent_resident? # => false
|
|
80
|
+
id_num.refugee? # => false
|
|
80
81
|
```
|
|
81
82
|
|
|
82
83
|
Development
|
data/lib/za_id_number/version.rb
CHANGED
data/lib/za_id_number.rb
CHANGED
|
@@ -8,9 +8,10 @@ class ZAIDNumber
|
|
|
8
8
|
REQUIRED_ID_LENGTH = 13
|
|
9
9
|
FEMALE_RANGE = (0..4999)
|
|
10
10
|
MALE_RANGE = (5000..9999)
|
|
11
|
-
CITIZENSHIP_RANGE = (0..
|
|
11
|
+
CITIZENSHIP_RANGE = (0..2)
|
|
12
12
|
ZA_CITIZEN = 0
|
|
13
13
|
PERMANENT_RESIDENT = 1
|
|
14
|
+
REFUGEE = 2
|
|
14
15
|
|
|
15
16
|
attr_reader :id_number
|
|
16
17
|
alias to_s id_number
|
|
@@ -44,7 +45,7 @@ class ZAIDNumber
|
|
|
44
45
|
end
|
|
45
46
|
|
|
46
47
|
def valid_citizenship?
|
|
47
|
-
CITIZENSHIP_RANGE.include?
|
|
48
|
+
CITIZENSHIP_RANGE.include? citizenship_status
|
|
48
49
|
end
|
|
49
50
|
|
|
50
51
|
def date_of_birth
|
|
@@ -66,17 +67,25 @@ class ZAIDNumber
|
|
|
66
67
|
end
|
|
67
68
|
|
|
68
69
|
def citizenship
|
|
69
|
-
|
|
70
|
+
case citizenship_status
|
|
71
|
+
when ZA_CITIZEN then :za_citizen
|
|
72
|
+
when PERMANENT_RESIDENT then :permanent_resident
|
|
73
|
+
when REFUGEE then :refugee
|
|
74
|
+
end
|
|
70
75
|
end
|
|
71
76
|
|
|
72
77
|
def za_citizen?
|
|
73
|
-
|
|
78
|
+
citizenship_status == ZA_CITIZEN
|
|
74
79
|
end
|
|
75
80
|
|
|
76
81
|
def permanent_resident?
|
|
77
82
|
!za_citizen?
|
|
78
83
|
end
|
|
79
84
|
|
|
85
|
+
def refugee?
|
|
86
|
+
citizenship_status == REFUGEE
|
|
87
|
+
end
|
|
88
|
+
|
|
80
89
|
def ==(other)
|
|
81
90
|
return false unless other.is_a?(ZAIDNumber)
|
|
82
91
|
|
|
@@ -87,4 +96,10 @@ class ZAIDNumber
|
|
|
87
96
|
def hash
|
|
88
97
|
id_number.hash
|
|
89
98
|
end
|
|
99
|
+
|
|
100
|
+
private
|
|
101
|
+
|
|
102
|
+
def citizenship_status
|
|
103
|
+
@id_number[10].to_i
|
|
104
|
+
end
|
|
90
105
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: za_id_number
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gabriel Fortuna
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-04-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|