cfita 0.3.0 → 0.4.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/.gitignore +2 -1
- data/CHANGELOG.md +23 -0
- data/README.md +1 -4
- data/cfita.gemspec +1 -1
- data/lib/cfita/codice_fiscale.rb +15 -11
- data/lib/cfita/codici_catastali.rb +3 -2
- data/lib/cfita.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0510a1eea1c9a417a70c0d5fbb91a275495569963e745dea6d369df11f91e32
|
4
|
+
data.tar.gz: a0d7f593151788aab9617dbc9922778d214b29e73784734a76874925188ce937
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69ef59d65dbc4403b74a74da2d848682277855d862e30056201bc24f1c0f4c49ccba60f2396ce30cdaa4396201c04930a3ef4cd165e38cc08844b6509c948cc8
|
7
|
+
data.tar.gz: fe5325bdf5a020c0da7d0f1832261da154ec8a48e926c33b97ae261a03e28c448eed62a07069c3b17d413324c3f4d83bdfa631475aee1e05786992748b406d36
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## v0.4.0 - 2022-12-10
|
9
|
+
|
10
|
+
### Fix
|
11
|
+
|
12
|
+
- return nil from cf_sex, cf_birth_places and cf_birth_date when fiscal code is invalid
|
13
|
+
|
14
|
+
## v0.3.1 - 2022-12-10
|
15
|
+
|
16
|
+
### Added
|
17
|
+
|
18
|
+
- M433 - BARDELLO CON MALGESSO E BREGANO
|
19
|
+
|
20
|
+
### Renamed
|
21
|
+
|
22
|
+
- B418 - CALLIANO => CALLIANO MONFERRATO
|
23
|
+
- B991 - CASORZO => CASORZO MONFERRATO
|
data/README.md
CHANGED
@@ -30,7 +30,7 @@ require 'cfita'
|
|
30
30
|
p Cfita::CodiceFiscale.new('AAABBB50A50F839X')
|
31
31
|
=> #<Cfita::CodiceFiscale:0x00007fa4efd09558 @fiscal_code="AAABBB50A50F839X", @birth_place=nil, @birth_date=nil, @name=nil, @surname=nil, @sex=nil, @errors=["Checksum errato"]>
|
32
32
|
|
33
|
-
p Cfita::CodiceFiscale(
|
33
|
+
p Cfita::CodiceFiscale.new(
|
34
34
|
'AAABBB50A50F839U',
|
35
35
|
birth_place: 'Roma',
|
36
36
|
birth_date: '19600530',
|
@@ -49,6 +49,3 @@ p Cfita::CodiceFiscale(
|
|
49
49
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
50
|
4. Push to the branch (`git push origin my-new-feature`)
|
51
51
|
5. Create new Pull Request
|
52
|
-
|
53
|
-
##
|
54
|
-
|
data/cfita.gemspec
CHANGED
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
|
|
5
5
|
s.required_ruby_version = '>= 2.4'
|
6
6
|
s.name = 'cfita'
|
7
7
|
s.version = Cfita::VERSION
|
8
|
-
s.date = '
|
8
|
+
s.date = '2022-12-10'
|
9
9
|
s.summary = 'Italian fiscal code checker'
|
10
10
|
s.description = 'Controllo codici fiscali italiani'
|
11
11
|
s.authors = ['Stefano Savanelli']
|
data/lib/cfita/codice_fiscale.rb
CHANGED
@@ -46,12 +46,14 @@ module Cfita
|
|
46
46
|
def cf_sex
|
47
47
|
return @cf_sex if @cf_sex
|
48
48
|
case @fiscal_code[9]
|
49
|
+
when nil
|
49
50
|
when /[0-3LMNP]/
|
50
51
|
@cf_sex = 'M'
|
51
52
|
when /[4-7QRST]/
|
52
53
|
@cf_sex = 'F'
|
53
54
|
else
|
54
55
|
@errors << 'Cifra decina giorno di nascita errata'
|
56
|
+
nil
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
@@ -63,10 +65,12 @@ module Cfita
|
|
63
65
|
|
64
66
|
def cf_birth_date
|
65
67
|
return @cf_birth_date if @cf_birth_date
|
68
|
+
|
66
69
|
yy = cifre(6..7)
|
67
70
|
day = cifre(9..10)
|
71
|
+
return unless yy && day
|
68
72
|
@errors << 'Cifra decina giorno di nascita errata' if day && day > 71
|
69
|
-
|
73
|
+
|
70
74
|
month = MESI.index(@fiscal_code[8])
|
71
75
|
@errors << 'Mese errato' unless month
|
72
76
|
return unless yy && month && day
|
@@ -76,17 +80,15 @@ module Cfita
|
|
76
80
|
|
77
81
|
private
|
78
82
|
|
79
|
-
def codice_catastale
|
83
|
+
def codice_catastale
|
80
84
|
return @codice_catastale if @codice_catastale
|
81
|
-
letter = @fiscal_code[11]
|
82
|
-
numbers =
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end
|
89
|
-
.join
|
85
|
+
return unless letter = @fiscal_code[11]
|
86
|
+
return unless numbers = @fiscal_code[12..14]
|
87
|
+
|
88
|
+
numbers = numbers.chars.map do |c|
|
89
|
+
i = OMOCODICI.index(c)
|
90
|
+
i ? i.to_s : c
|
91
|
+
end.join
|
90
92
|
letter + numbers
|
91
93
|
end
|
92
94
|
|
@@ -194,6 +196,8 @@ module Cfita
|
|
194
196
|
result = 0
|
195
197
|
range.each do |position|
|
196
198
|
char = @fiscal_code[position]
|
199
|
+
return nil unless char
|
200
|
+
|
197
201
|
value = CIFRE.index(char)
|
198
202
|
@errors << "Carattere '#{char}' errato in posizione #{position}" unless value
|
199
203
|
return nil unless value
|
@@ -1415,7 +1415,7 @@ module Cfita
|
|
1415
1415
|
'B415' => ["CALITRI"],
|
1416
1416
|
'B416' => ["CALIZZANO"],
|
1417
1417
|
'B417' => ["CALLABIANA"],
|
1418
|
-
'B418' => ["CALLIANO"],
|
1418
|
+
'B418' => ["CALLIANO MONFERRATO"],
|
1419
1419
|
'B419' => ["CALLIANO"],
|
1420
1420
|
'B420' => ["CALO'"],
|
1421
1421
|
'B421' => ["CALOGNA"],
|
@@ -1988,7 +1988,7 @@ module Cfita
|
|
1988
1988
|
'B988' => ["CASORATE PRIMO"],
|
1989
1989
|
'B989' => ["CASOREZZO"],
|
1990
1990
|
'B990' => ["CASORIA"],
|
1991
|
-
'B991' => ["CASORZO"],
|
1991
|
+
'B991' => ["CASORZO MONFERRATO"],
|
1992
1992
|
'B992' => ["CASOTTO"],
|
1993
1993
|
'B993' => ["CASPOGGIO"],
|
1994
1994
|
'B994' => ["CASSACCO"],
|
@@ -10416,6 +10416,7 @@ module Cfita
|
|
10416
10416
|
'M430' => ["NOVELLA"],
|
10417
10417
|
'M431' => ["VILLE DI FIEMME"],
|
10418
10418
|
'M432' => ["MISILISCEMI"],
|
10419
|
+
'M433' => ["BARDELLO CON MALGESSO E BREGANO"],
|
10419
10420
|
'Z100' => ["ALBANIA"],
|
10420
10421
|
'Z101' => ["ANDORRA"],
|
10421
10422
|
'Z102' => ["AUSTRIA"],
|
data/lib/cfita.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfita
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefano Savanelli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Controllo codici fiscali italiani
|
14
14
|
email: stefano@savanelli.it
|
@@ -18,6 +18,7 @@ extra_rdoc_files: []
|
|
18
18
|
files:
|
19
19
|
- ".gitignore"
|
20
20
|
- ".rubocop.yml"
|
21
|
+
- CHANGELOG.md
|
21
22
|
- Gemfile
|
22
23
|
- README.md
|
23
24
|
- cfita.gemspec
|
@@ -44,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
45
|
- !ruby/object:Gem::Version
|
45
46
|
version: '0'
|
46
47
|
requirements: []
|
47
|
-
rubygems_version: 3.
|
48
|
+
rubygems_version: 3.3.26
|
48
49
|
signing_key:
|
49
50
|
specification_version: 4
|
50
51
|
summary: Italian fiscal code checker
|