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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5cef58c59196f0191df63c18b9780dff69ae3ae5412af8b2fdabfba0eb426295
4
- data.tar.gz: c7d0adf7e96974485cf665d49697122490dbd99b9c312315f310eda7ea41528e
3
+ metadata.gz: b0510a1eea1c9a417a70c0d5fbb91a275495569963e745dea6d369df11f91e32
4
+ data.tar.gz: a0d7f593151788aab9617dbc9922778d214b29e73784734a76874925188ce937
5
5
  SHA512:
6
- metadata.gz: 4db0e12e84f59d1e60d39dbd4409dfa9ed243c2ef5d2a7d1c1b77574ff957a1f931e4cafc4bf40aa548c663bc02407b8f3bbcc05f7183d423b64dfa024739968
7
- data.tar.gz: dd13a735a96de5d038d822effac798e0b577a80077fdb8bc66dbe15a59883437dd1ea7e98c25643fb1f95e71165af0ef368a5d9fa45219a44be9ea92359c6ba9
6
+ metadata.gz: 69ef59d65dbc4403b74a74da2d848682277855d862e30056201bc24f1c0f4c49ccba60f2396ce30cdaa4396201c04930a3ef4cd165e38cc08844b6509c948cc8
7
+ data.tar.gz: fe5325bdf5a020c0da7d0f1832261da154ec8a48e926c33b97ae261a03e28c448eed62a07069c3b17d413324c3f4d83bdfa631475aee1e05786992748b406d36
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  *.gem
2
- test/cfs.txt
2
+ test/cfs.txt
3
+ Gemfile.lock
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 = '2021-06-02'
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']
@@ -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
- @fiscal_code[12..14]
84
- .split(//)
85
- .map do |c|
86
- i = OMOCODICI.index(c)
87
- i ? i.to_s : c
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
@@ -4,5 +4,5 @@
4
4
  module Cfita
5
5
  require 'cfita/codice_fiscale'
6
6
 
7
- VERSION='0.3.0'
7
+ VERSION='0.4.0'
8
8
  end
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.3.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: 2021-06-02 00:00:00.000000000 Z
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.2.15
48
+ rubygems_version: 3.3.26
48
49
  signing_key:
49
50
  specification_version: 4
50
51
  summary: Italian fiscal code checker