itax_code 2.0.3 → 2.0.4
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/.github/workflows/test.yml +1 -1
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +12 -0
- data/lib/itax_code/encoder.rb +1 -1
- data/lib/itax_code/omocode.rb +1 -1
- data/lib/itax_code/parser.rb +1 -1
- data/lib/itax_code/utils.rb +126 -122
- data/lib/itax_code/version.rb +1 -1
- 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: 28b67a1393b6940ab8824514b430ecfee7cb9a7eca1208b6f6656b25049d933b
|
4
|
+
data.tar.gz: 8d2b668cb365b5831cfa2c384ab3b1525fb50f289e7c470310bcb4c963d88217
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cda714e70c20caefb01d356b281fac5dd8eb600149ecaaba77ad40dc58240e69bedc63d7259e0b4578724be756f960af07584977f3e90b9539cdb65be1c4167e
|
7
|
+
data.tar.gz: 877e5c56c488137c377a7a93fe4de8bf1b7ff7f49fbd23a1ed6ce483628d2b919edc2bed32d87eb9cace9987a55743c4f3fb5537a390ac6e1b1cbd93bdc49728
|
data/.github/workflows/test.yml
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [2.0.4](https://github.com/matteoredz/itax-code/compare/v2.0.3...v2.0.4) (2024-05-02)
|
4
|
+
|
5
|
+
|
6
|
+
### Continuous Integration
|
7
|
+
|
8
|
+
* update paambaati/codeclimate-action to v6.0.0 ([#55](https://github.com/matteoredz/itax-code/issues/55)) ([e7aad01](https://github.com/matteoredz/itax-code/commit/e7aad0168aa18df97235171082e9bd40287dee84))
|
9
|
+
|
10
|
+
|
11
|
+
### Code Refactoring
|
12
|
+
|
13
|
+
* converted Utils class in module ([#53](https://github.com/matteoredz/itax-code/issues/53)) ([99dddee](https://github.com/matteoredz/itax-code/commit/99dddee715b3bc5deccd27c6734832e7f9ec7cd0))
|
14
|
+
|
3
15
|
## [2.0.3](https://github.com/matteoredz/itax-code/compare/v2.0.2...v2.0.3) (2024-02-20)
|
4
16
|
|
5
17
|
|
data/lib/itax_code/encoder.rb
CHANGED
@@ -22,7 +22,7 @@ module ItaxCode
|
|
22
22
|
# @option data [String] :gender The user gender
|
23
23
|
# @option data [String, Date] :birthdate The user birthdate
|
24
24
|
# @option data [String] :birthplace The user birthplace
|
25
|
-
def initialize(data = {}, utils = Utils
|
25
|
+
def initialize(data = {}, utils = Utils)
|
26
26
|
@utils = utils
|
27
27
|
|
28
28
|
@surname = data[:surname]
|
data/lib/itax_code/omocode.rb
CHANGED
data/lib/itax_code/parser.rb
CHANGED
data/lib/itax_code/utils.rb
CHANGED
@@ -4,148 +4,152 @@ require "csv"
|
|
4
4
|
require "itax_code/transliterator"
|
5
5
|
|
6
6
|
module ItaxCode
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
def present?(obj)
|
13
|
-
!blank?(obj)
|
14
|
-
end
|
15
|
-
|
16
|
-
def slugged(string)
|
17
|
-
transliterated = transliterate(string.downcase.strip)
|
18
|
-
transliterated.gsub(/[^\w-]+/, "-").gsub(/-{2,}/, "-").gsub(/^-+|-+$/, "")
|
19
|
-
end
|
20
|
-
|
21
|
-
def transliterate(string)
|
22
|
-
return string if string.ascii_only?
|
23
|
-
|
24
|
-
transliterator = Transliterator.new
|
25
|
-
transliterator.transliterate(string.unicode_normalize(:nfc))
|
26
|
-
end
|
27
|
-
|
28
|
-
def tax_code_sections_regex
|
29
|
-
/^([A-Z]{3})([A-Z]{3})
|
30
|
-
(([A-Z\d]{2})([ABCDEHLMPRST]{1})([A-Z\d]{2}))
|
31
|
-
([A-Z]{1}[A-Z\d]{3})
|
32
|
-
([A-Z]{1})$/x
|
33
|
-
end
|
34
|
-
|
35
|
-
def months
|
36
|
-
%w[A B C D E H L M P R S T]
|
37
|
-
end
|
7
|
+
module Utils
|
8
|
+
class << self
|
9
|
+
def blank?(obj)
|
10
|
+
obj.respond_to?(:empty?) ? !!obj.empty? : !obj
|
11
|
+
end
|
38
12
|
|
39
|
-
|
40
|
-
|
41
|
-
|
13
|
+
def present?(obj)
|
14
|
+
!blank?(obj)
|
15
|
+
end
|
42
16
|
|
43
|
-
|
44
|
-
|
45
|
-
|
17
|
+
def slugged(string)
|
18
|
+
transliterated = transliterate(string.downcase.strip)
|
19
|
+
transliterated.gsub(/[^\w-]+/, "-").gsub(/-{2,}/, "-").gsub(/^-+|-+$/, "")
|
20
|
+
end
|
46
21
|
|
47
|
-
|
48
|
-
|
49
|
-
"0" => [0, 1],
|
50
|
-
"1" => [1, 0],
|
51
|
-
"2" => [2, 5],
|
52
|
-
"3" => [3, 7],
|
53
|
-
"4" => [4, 9],
|
54
|
-
"5" => [5, 13],
|
55
|
-
"6" => [6, 15],
|
56
|
-
"7" => [7, 17],
|
57
|
-
"8" => [8, 19],
|
58
|
-
"9" => [9, 21],
|
59
|
-
"A" => [0, 1],
|
60
|
-
"B" => [1, 0],
|
61
|
-
"C" => [2, 5],
|
62
|
-
"D" => [3, 7],
|
63
|
-
"E" => [4, 9],
|
64
|
-
"F" => [5, 13],
|
65
|
-
"G" => [6, 15],
|
66
|
-
"H" => [7, 17],
|
67
|
-
"I" => [8, 19],
|
68
|
-
"J" => [9, 21],
|
69
|
-
"K" => [10, 2],
|
70
|
-
"L" => [11, 4],
|
71
|
-
"M" => [12, 18],
|
72
|
-
"N" => [13, 20],
|
73
|
-
"O" => [14, 11],
|
74
|
-
"P" => [15, 3],
|
75
|
-
"Q" => [16, 6],
|
76
|
-
"R" => [17, 8],
|
77
|
-
"S" => [18, 12],
|
78
|
-
"T" => [19, 14],
|
79
|
-
"U" => [20, 16],
|
80
|
-
"V" => [21, 10],
|
81
|
-
"W" => [22, 22],
|
82
|
-
"X" => [23, 25],
|
83
|
-
"Y" => [24, 24],
|
84
|
-
"Z" => [25, 23]
|
85
|
-
}
|
86
|
-
end
|
22
|
+
def transliterate(string)
|
23
|
+
return string if string.ascii_only?
|
87
24
|
|
88
|
-
|
89
|
-
|
90
|
-
|
25
|
+
transliterator = Transliterator.new
|
26
|
+
transliterator.transliterate(string.unicode_normalize(:nfc))
|
27
|
+
end
|
91
28
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
29
|
+
def tax_code_sections_regex
|
30
|
+
/^([A-Z]{3})([A-Z]{3})
|
31
|
+
(([A-Z\d]{2})([ABCDEHLMPRST]{1})([A-Z\d]{2}))
|
32
|
+
([A-Z]{1}[A-Z\d]{3})
|
33
|
+
([A-Z]{1})$/x
|
34
|
+
end
|
98
35
|
|
99
|
-
|
100
|
-
|
101
|
-
|
36
|
+
def months
|
37
|
+
%w[A B C D E H L M P R S T]
|
38
|
+
end
|
102
39
|
|
103
|
-
|
104
|
-
|
105
|
-
|
40
|
+
def omocodia_indexes
|
41
|
+
[6, 7, 9, 10, 12, 13, 14].reverse
|
42
|
+
end
|
106
43
|
|
107
|
-
|
108
|
-
|
109
|
-
|
44
|
+
def omocodia_indexes_combos
|
45
|
+
(1..omocodia_indexes.size).flat_map do |index|
|
46
|
+
omocodia_indexes.combination(index).to_a
|
47
|
+
end
|
48
|
+
end
|
110
49
|
|
111
|
-
|
112
|
-
|
113
|
-
omocodia_indexes.combination(index).to_a
|
50
|
+
def omocodia_encode(val)
|
51
|
+
val.tr omocodia_digits, omocodia_letters
|
114
52
|
end
|
115
|
-
end
|
116
53
|
|
117
|
-
|
118
|
-
|
119
|
-
|
54
|
+
def omocodia_decode(val)
|
55
|
+
val.tr omocodia_letters, omocodia_digits
|
56
|
+
end
|
120
57
|
|
121
|
-
|
122
|
-
|
123
|
-
|
58
|
+
def extract_consonants(str)
|
59
|
+
str.select { |c| consonants.include? c }.join
|
60
|
+
end
|
124
61
|
|
125
|
-
|
126
|
-
|
127
|
-
|
62
|
+
def extract_vowels(str)
|
63
|
+
str.select { |c| vowels.include? c }.join
|
64
|
+
end
|
128
65
|
|
129
|
-
|
130
|
-
|
131
|
-
end
|
66
|
+
def encode_cin(code)
|
67
|
+
cin_tot = 0
|
132
68
|
|
133
|
-
|
134
|
-
|
69
|
+
code[0..14].each_char.with_index do |char, i|
|
70
|
+
cin_tot += cin[char][((i + 1) % 2).to_i]
|
71
|
+
end
|
135
72
|
|
136
|
-
|
137
|
-
cin_tot += cin[char][((i + 1) % 2).to_i]
|
73
|
+
cin_remainders[cin_tot % 26]
|
138
74
|
end
|
139
75
|
|
140
|
-
|
141
|
-
|
76
|
+
def cities
|
77
|
+
CSV.foreach("#{__dir__}/data/cities.csv", headers: true)
|
78
|
+
end
|
142
79
|
|
143
|
-
|
144
|
-
|
145
|
-
|
80
|
+
def countries
|
81
|
+
CSV.foreach("#{__dir__}/data/countries.csv", headers: true)
|
82
|
+
end
|
146
83
|
|
147
|
-
|
148
|
-
|
84
|
+
private
|
85
|
+
|
86
|
+
def omocodia_letters
|
87
|
+
omocodia.values.join
|
88
|
+
end
|
89
|
+
|
90
|
+
def omocodia_digits
|
91
|
+
omocodia.keys.join
|
92
|
+
end
|
93
|
+
|
94
|
+
def consonants
|
95
|
+
%w[b c d f g h j k l m n p q r s t v w x y z]
|
96
|
+
end
|
97
|
+
|
98
|
+
def vowels
|
99
|
+
%w[a e i o u]
|
100
|
+
end
|
101
|
+
|
102
|
+
def cin
|
103
|
+
{
|
104
|
+
"0" => [0, 1],
|
105
|
+
"1" => [1, 0],
|
106
|
+
"2" => [2, 5],
|
107
|
+
"3" => [3, 7],
|
108
|
+
"4" => [4, 9],
|
109
|
+
"5" => [5, 13],
|
110
|
+
"6" => [6, 15],
|
111
|
+
"7" => [7, 17],
|
112
|
+
"8" => [8, 19],
|
113
|
+
"9" => [9, 21],
|
114
|
+
"A" => [0, 1],
|
115
|
+
"B" => [1, 0],
|
116
|
+
"C" => [2, 5],
|
117
|
+
"D" => [3, 7],
|
118
|
+
"E" => [4, 9],
|
119
|
+
"F" => [5, 13],
|
120
|
+
"G" => [6, 15],
|
121
|
+
"H" => [7, 17],
|
122
|
+
"I" => [8, 19],
|
123
|
+
"J" => [9, 21],
|
124
|
+
"K" => [10, 2],
|
125
|
+
"L" => [11, 4],
|
126
|
+
"M" => [12, 18],
|
127
|
+
"N" => [13, 20],
|
128
|
+
"O" => [14, 11],
|
129
|
+
"P" => [15, 3],
|
130
|
+
"Q" => [16, 6],
|
131
|
+
"R" => [17, 8],
|
132
|
+
"S" => [18, 12],
|
133
|
+
"T" => [19, 14],
|
134
|
+
"U" => [20, 16],
|
135
|
+
"V" => [21, 10],
|
136
|
+
"W" => [22, 22],
|
137
|
+
"X" => [23, 25],
|
138
|
+
"Y" => [24, 24],
|
139
|
+
"Z" => [25, 23]
|
140
|
+
}
|
141
|
+
end
|
142
|
+
|
143
|
+
def cin_remainders
|
144
|
+
("A".."Z").to_a
|
145
|
+
end
|
146
|
+
|
147
|
+
def omocodia
|
148
|
+
{
|
149
|
+
"0": "L", "1": "M", "2": "N", "3": "P", "4": "Q",
|
150
|
+
"5": "R", "6": "S", "7": "T", "8": "U", "9": "V"
|
151
|
+
}
|
152
|
+
end
|
149
153
|
end
|
150
154
|
end
|
151
155
|
end
|
data/lib/itax_code/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itax_code
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matteo Rossi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: csv
|