henkilotunnus 1.1.0 → 1.2.1
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 +5 -5
- data/CHANGELOG.md +17 -0
- data/lib/henkilotunnus/hetu.rb +16 -5
- data/lib/henkilotunnus/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a78c226cd21e2b9b4cc960a942ade42e00bb6cf9d1ca875b9fda13ffed66cbfc
|
|
4
|
+
data.tar.gz: 4079582d66323e3a9363c746c46c590e3abbd1a0a6b42df35e1632178e41dacb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9df35116e20853ca09ce852d4f0a9eca2647b4b7035acaa4020350ccc3cd72f19d197b80c812094149042c7f960f65dbc6e67e4c4b9faf67f4415f095b05dcfe
|
|
7
|
+
data.tar.gz: d586716018d73b825d9abc7659e35f041f63474a56ddb33b668db5a21fa5d4e9a8cf9b3f5b327330f45039676567e8867fc370721a584d8e2ee1d390d02103d7
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.2.1 2026-03-xx
|
|
4
|
+
|
|
5
|
+
- Changed the `Hetu#gender_neutral?` method to always return `false` because the
|
|
6
|
+
originally planned government proposal GP 132/2022 (HE 132/2022) did not
|
|
7
|
+
become a law.
|
|
8
|
+
- Removed the excess logic from the `Hetu#gender` method to not check
|
|
9
|
+
`gender_neutral?` since it is unnecessary after the previous change.
|
|
10
|
+
|
|
11
|
+
## 1.2.0 2022-10-xx
|
|
12
|
+
|
|
13
|
+
Added new punctuation marks that will be added to identity codes in 2023.
|
|
14
|
+
|
|
15
|
+
Added gender_neutral? method. Using gender methods on gender neutral
|
|
16
|
+
identity codes will raise an exception. Gender neutral identity codes will
|
|
17
|
+
be introduced in 2027. Gender methods will still be available for pins using
|
|
18
|
+
the old punctuation.
|
|
19
|
+
|
|
3
20
|
## 1.1.0 - 2019-04-xx
|
|
4
21
|
|
|
5
22
|
Removed the lock down from the dependent gems in order to make the gem
|
data/lib/henkilotunnus/hetu.rb
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
module Henkilotunnus
|
|
2
2
|
class Hetu
|
|
3
3
|
GENDERS = ['female', 'male']
|
|
4
|
-
CENTURIES = { '+' => 1800, '-' => 1900, '
|
|
5
|
-
|
|
4
|
+
CENTURIES = { '+' => 1800, '-YXWVU' => 1900, 'ABCDEF' => 2000 }
|
|
5
|
+
NEW_CENTURY_SIGNS = 'YXWVUBCDEF'
|
|
6
|
+
PERSON_NUMBER_RANGE = 0..999
|
|
6
7
|
CHECKSUM_CHARS = '0123456789ABCDEFHJKLMNPRSTUVWXY'
|
|
7
8
|
|
|
8
9
|
def self.valid?(pin)
|
|
@@ -13,7 +14,9 @@ module Henkilotunnus
|
|
|
13
14
|
dob = opts.fetch(:date, Time.at(rand(Date.new(1800, 1, 1).to_time.to_i...Date.today.to_time.to_i)).to_date)
|
|
14
15
|
raw_dob = dob.strftime("%d%m%y")
|
|
15
16
|
person_number = opts.fetch(:person_number, rand(PERSON_NUMBER_RANGE)).to_s.rjust(3, "0")
|
|
16
|
-
|
|
17
|
+
century_str = CENTURIES.key(dob.year - (dob.year % 100))
|
|
18
|
+
sign_str_len = century_str.size - 1
|
|
19
|
+
century_sign = century_str[rand(0..sign_str_len)]
|
|
17
20
|
|
|
18
21
|
new(raw_dob + century_sign + person_number + compute_checksum(raw_dob, person_number))
|
|
19
22
|
end
|
|
@@ -44,6 +47,10 @@ module Henkilotunnus
|
|
|
44
47
|
GENDERS[person_number.to_i % 2]
|
|
45
48
|
end
|
|
46
49
|
|
|
50
|
+
def gender_neutral?
|
|
51
|
+
false
|
|
52
|
+
end
|
|
53
|
+
|
|
47
54
|
def male?
|
|
48
55
|
gender == 'male'
|
|
49
56
|
end
|
|
@@ -68,7 +75,11 @@ module Henkilotunnus
|
|
|
68
75
|
end
|
|
69
76
|
|
|
70
77
|
def century
|
|
71
|
-
CENTURIES
|
|
78
|
+
CENTURIES.keys.each do |string|
|
|
79
|
+
if string.include? century_sign
|
|
80
|
+
return CENTURIES[string]
|
|
81
|
+
end
|
|
82
|
+
end
|
|
72
83
|
end
|
|
73
84
|
|
|
74
85
|
def checksum
|
|
@@ -90,7 +101,7 @@ module Henkilotunnus
|
|
|
90
101
|
end
|
|
91
102
|
|
|
92
103
|
def valid_format?
|
|
93
|
-
!!(pin =~ /^\d{6}[-+
|
|
104
|
+
!!(pin =~ /^\d{6}[-+ABCDEFYXWVU]\d{3}[0-9A-Z]$/)
|
|
94
105
|
end
|
|
95
106
|
|
|
96
107
|
def valid_checksum?
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: henkilotunnus
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1
|
|
4
|
+
version: 1.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexander Hanhikoski
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-03-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -122,8 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
122
122
|
- !ruby/object:Gem::Version
|
|
123
123
|
version: '0'
|
|
124
124
|
requirements: []
|
|
125
|
-
|
|
126
|
-
rubygems_version: 2.6.13
|
|
125
|
+
rubygems_version: 3.0.3.1
|
|
127
126
|
signing_key:
|
|
128
127
|
specification_version: 4
|
|
129
128
|
summary: Validates Finnish personal identification numbers (henkilötunnus).
|