codice-fiscale 0.0.9 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1,216 @@
1
- CONTIN,SIGLA,DENOMINAZ,CODICE,DATAIST,DATASOP,CODRIF,DATAVARIAZ
1
+ Albania,Albania,Z100
2
+ Andorra,Andorra,Z101
3
+ Austria,Austria,Z102
4
+ Belgio,Belgium,Z103
5
+ Bulgaria,Bulgaria,Z104
6
+ Danimarca,Denmark,Z107
7
+ Finlandia,Finland,Z109
8
+ Francia,France,Z110
9
+ Germania,Germany,Z112
10
+ Regno Unito,United Kingdom,Z114
11
+ Grecia,Greece,Z115
12
+ Irlanda,Ireland,Z116
13
+ Islanda,Iceland,Z117
14
+ Liechtenstein,Liechtenstein,Z119
15
+ Lussemburgo,Luxembourg,Z120
16
+ Malta,Malta,Z121
17
+ Monaco,Monaco,Z123
18
+ Norvegia,Norway,Z125
19
+ Paesi Bassi,Netherlands,Z126
20
+ Polonia,Poland,Z127
21
+ Portogallo,Portugal,Z128
22
+ Romania,Romania,Z129
23
+ San Marino,San Marino,Z130
24
+ Spagna,Spain,Z131
25
+ Svezia,Sweden,Z132
26
+ Svizzera,Switzerland,Z133
27
+ Ucraina,Ukraine,Z138
28
+ Ungheria,Hungary,Z134
29
+ Federazione russa,Russian Federation,Z154
30
+ Stato della Città del Vaticano,Vatican City State,Z106
31
+ Estonia,Estonia,Z144
32
+ Lettonia,Latvia,Z145
33
+ Lituania,Lithuania,Z146
34
+ Croazia,Croatia,Z149
35
+ Slovenia,Slovenia,Z150
36
+ Bosnia-Erzegovina,Bosnia and Herzegovina,Z153
37
+ Ex Repubblica Jugoslava di Macedonia,The former Yugoslav Republic of Macedonia,Z148
38
+ Moldova,Moldova,Z140
39
+ Slovacchia,Slovakia,Z155
40
+ Bielorussia,Belarus,Z139
41
+ Repubblica ceca,Czech Republic,Z156
42
+ Montenegro,Montenegro,Z159
43
+ Serbia,Serbia,Z158
44
+ Kosovo,Kosovo,Z160
45
+ Afghanistan,Afghanistan,Z200
46
+ Arabia Saudita,Saudi Arabia,Z203
47
+ Bahrein,Bahrain,Z204
48
+ Bangladesh,Bangladesh,Z249
49
+ Bhutan,Bhutan,Z205
50
+ Myanmar/Birmania,Myanmar/Burma,Z206
51
+ Brunei Darussalam,Brunei Darussalam,Z207
52
+ Cambogia,Cambodia,Z208
53
+ Sri Lanka,Sri Lanka,Z209
54
+ Cina,China,Z210
55
+ Cipro,Cyprus,Z211
56
+ Corea del Nord,North Korea,Z214
57
+ Corea del Sud,South Korea,Z213
58
+ Emirati Arabi Uniti,United Arab Emirates,Z215
59
+ Filippine,Philippines,Z216
60
+ Palestina,Palestine,Z161
61
+ Giappone,Japan,Z219
62
+ Giordania,Jordan,Z220
63
+ India,India,Z222
64
+ Indonesia,Indonesia,Z223
65
+ Iran,Iran,Z224
66
+ Iraq,Iraq,Z225
67
+ Israele,Israel,Z226
68
+ Kuwait,Kuwait,Z227
69
+ Laos,Laos,Z228
70
+ Libano,Lebanon,Z229
71
+ Timor Leste,Timor Leste,Z242
72
+ Maldive,Maldives,Z232
73
+ Malaysia,Malaysia,Z247
74
+ Mongolia,Mongolia,Z233
75
+ Nepal,Nepal,Z234
76
+ Oman,Oman,Z235
77
+ Pakistan,Pakistan,Z236
78
+ Qatar,Qatar,Z237
79
+ Singapore,Singapore,Z248
80
+ Siria,Syria,Z240
81
+ Thailandia,Thailand,Z241
82
+ Turchia,Turkey,Z243
83
+ Vietnam,Vietnam,Z251
84
+ Yemen,Yemen,Z246
85
+ Kazakhstan,Kazakhstan,Z255
86
+ Uzbekistan,Uzbekistan,Z259
87
+ Armenia,Armenia,Z252
88
+ Azerbaigian,Azerbaijan,Z253
89
+ Georgia,Georgia,Z254
90
+ Kirghizistan,Kyrgyzstan,Z256
91
+ Tagikistan,Tajikistan,Z257
92
+ Taiwan,Taiwan,Z217
93
+ Turkmenistan,Turkmenistan,Z258
94
+ Algeria,Algeria,Z301
95
+ Angola,Angola,Z302
96
+ Costa d'Avorio,Côte d'Ivoire,Z313
97
+ Benin,Benin,Z314
98
+ Botswana,Botswana,Z358
99
+ Burkina Faso,Burkina Faso,Z354
100
+ Burundi,Burundi,Z305
101
+ Camerun,Cameroon,Z306
102
+ Capo Verde,Cape Verde,Z307
103
+ Repubblica Centrafricana,Central African Republic,Z308
104
+ Ciad,Chad,Z309
105
+ Comore,Comoros,Z310
106
+ Congo,Congo,Z311
107
+ Egitto,Egypt,Z336
108
+ Etiopia,Ethiopia,Z315
109
+ Gabon,Gabon,Z316
110
+ Gambia,Gambia,Z317
111
+ Ghana,Ghana,Z318
112
+ Gibuti,Djibouti,Z361
113
+ Guinea,Guinea,Z319
114
+ Guinea-Bissau,Guinea-Bissau,Z320
115
+ Guinea equatoriale,Equatorial Guinea,Z321
116
+ Kenya,Kenya,Z322
117
+ Lesotho,Lesotho,Z359
118
+ Liberia,Liberia,Z325
119
+ Libia,Libya,Z326
120
+ Madagascar,Madagascar,Z327
121
+ Malawi,Malawi,Z328
122
+ Mali,Mali,Z329
123
+ Marocco,Morocco,Z330
124
+ Mauritania,Mauritania,Z331
125
+ Maurizio,Mauritius,Z332
126
+ Mozambico,Mozambique,Z333
127
+ Namibia,Namibia,Z300
128
+ Niger,Niger,Z334
129
+ Nigeria,Nigeria,Z335
130
+ Ruanda,Rwanda,Z338
131
+ Sao Tomé e Principe,Sao Tome and Principe,Z341
132
+ Seychelles,Seychelles,Z342
133
+ Senegal,Senegal,Z343
134
+ Sierra Leone,Sierra Leone,Z344
135
+ Somalia,Somalia,Z345
136
+ Sudafrica,South Africa,Z347
137
+ Sudan,Sudan,Z348
138
+ Eswatini,Eswatini,Z349
139
+ Tanzania,Tanzania,Z357
140
+ Togo,Togo,Z351
141
+ Tunisia,Tunisia,Z352
142
+ Uganda,Uganda,Z353
143
+ Repubblica Democratica del Congo,Democratic Republic of the Congo,Z312
144
+ Zambia,Zambia,Z355
145
+ Zimbabwe,Zimbabwe,Z337
146
+ Eritrea,Eritrea,Z368
147
+ Sud Sudan,South Sudan,Z907
148
+ Antigua e Barbuda,Antigua and Barbuda,Z532
149
+ Bahamas,Bahamas,Z502
150
+ Barbados,Barbados,Z522
151
+ Belize,Belize,Z512
152
+ Canada,Canada,Z401
153
+ Costa Rica,Costa Rica,Z503
154
+ Cuba,Cuba,Z504
155
+ Dominica,Dominica,Z526
156
+ Repubblica Dominicana,Dominican Republic,Z505
157
+ El Salvador,El Salvador,Z506
158
+ Giamaica,Jamaica,Z507
159
+ Grenada,Grenada,Z524
160
+ Guatemala,Guatemala,Z509
161
+ Haiti,Haiti,Z510
162
+ Honduras,Honduras,Z511
163
+ Messico,Mexico,Z514
164
+ Nicaragua,Nicaragua,Z515
165
+ Panama,Panama,Z516
166
+ Santa Lucia,Saint Lucia,Z527
167
+ Saint Vincent e Grenadine,Saint Vincent and the Grenadines,Z528
168
+ Saint Kitts e Nevis,Saint Kitts and Nevis,Z533
169
+ Stati Uniti d'America,United States of America,Z404
170
+ Argentina,Argentina,Z600
171
+ Bolivia,Bolivia,Z601
172
+ Brasile,Brazil,Z602
173
+ Cile,Chile,Z603
174
+ Colombia,Colombia,Z604
175
+ Ecuador,Ecuador,Z605
176
+ Guyana,Guyana,Z606
177
+ Paraguay,Paraguay,Z610
178
+ Perù,Peru,Z611
179
+ Suriname,Suriname,Z608
180
+ Trinidad e Tobago,Trinidad and Tobago,Z612
181
+ Uruguay,Uruguay,Z613
182
+ Venezuela,Venezuela,Z614
183
+ Australia,Australia,Z700
184
+ Figi,Fiji,Z704
185
+ Kiribati,Kiribati,Z731
186
+ Isole Marshall,Marshall Islands,Z711
187
+ Stati Federati di Micronesia,Federated States of Micronesia,Z735
188
+ Nauru,Nauru,Z713
189
+ Nuova Zelanda,New Zealand,Z719
190
+ Palau,Palau,Z734
191
+ Papua Nuova Guinea,Papua New Guinea,Z730
192
+ Isole Salomone,Solomon Islands,Z724
193
+ Samoa,Samoa,Z726
194
+ Tonga,Tonga,Z728
195
+ Tuvalu,Tuvalu,Z732
196
+ Vanuatu,Vanuatu,Z733
197
+ Nuova Caledonia,New Caledonia,Z716
198
+ Sahara occidentale,Western Sahara,Z339
199
+ Bermuda,Bermuda,Z400
200
+ Isole Cook (NZ),Cook Islands (NZ),Z703
201
+ Gibilterra,Gibraltar,Z113
202
+ Isole Cayman,Cayman Islands,Z530
203
+ Anguilla,Anguilla,Z529
204
+ Polinesia francese,French Polynesia,Z723
205
+ Isole Fær Øer,Faroe Islands,Z108
206
+ Aruba,Aruba,Z501
207
+ Groenlandia,Greenland,Z402
208
+ Isole Falkland (Malvine),Falkland Islands (Malvinas),Z609
209
+ Isola di Man,Isle of Man,Z122
210
+ Montserrat,Montserrat,Z531
211
+ Isole Pitcairn,Pitcairn,Z722
212
+ Saint Pierre e Miquelon,Saint Pierre and Miquelon,Z403
213
+ Sant'Elena,Saint Helena,Z340
214
+ Isole Turks e Caicos,Turks and Caicos Islands,Z519
215
+ Isole Vergini britanniche,British Virgin Islands,Z525
216
+ Wallis e Futuna,Wallis and Futuna Islands,Z729
@@ -1,3 +1,3 @@
1
1
  module CodiceFiscale
2
- VERSION = "0.0.9"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -3,23 +3,31 @@ require 'spec_helper'
3
3
  describe CodiceFiscale::Alphabet do
4
4
  describe '#letters' do
5
5
  it 'is 26 long' do
6
- subject.letters.size.should == 26
6
+ expect(subject.letters.size).to eq 26
7
7
  end
8
8
 
9
- it 'return only upcased letters' do
10
- subject.letters.each { |letter| letter.upcase.should == letter }
9
+ it 'consists only of upcased letters' do
10
+ expect(subject.letters.join).to match /^[A-Z]{1,}$/
11
11
  end
12
12
  end
13
13
 
14
14
  describe '#consonants' do
15
15
  it 'is 21 long' do
16
- subject.consonants.size.should == 21
16
+ expect(subject.consonants.size).to eq 21
17
+ end
18
+
19
+ it 'consists only of upcased letters' do
20
+ expect(subject.vowels.join).to match /^[A-Z]{1,}$/
17
21
  end
18
22
  end
19
23
 
20
- describe '#vocals' do
21
- it 'return only upcased letters' do
22
- subject.letters.each { |letter| letter.upcase.should == letter }
24
+ describe '#vowels' do
25
+ it 'is 5 long' do
26
+ expect(subject.vowels.size).to eq 5
27
+ end
28
+
29
+ it 'consists only of upcased letters' do
30
+ expect(subject.vowels.join).to match /^[A-Z]{1,}$/
23
31
  end
24
32
  end
25
- end
33
+ end
@@ -4,19 +4,23 @@ describe CodiceFiscale::Codes do
4
4
  describe '#month_letter' do
5
5
  context 'the given number is greater than 0 and less than 12' do
6
6
  it 'return a letter' do
7
- subject.month_letter(1).should == 'A'
7
+ 1.upto(12).each do |n|
8
+ expect(subject.month_letter(1)).to match /^[A-Z]{1,}$/
9
+ end
8
10
  end
9
11
  end
10
12
 
11
13
  context 'the given number is greater than 12' do
12
14
  it 'return nil' do
13
- subject.month_letter(13).should be_nil
15
+ expect(subject.month_letter(13)).to be_nil
14
16
  end
15
17
  end
16
18
 
17
19
  context 'the given number is less than 1' do
18
20
  it 'return nil' do
19
- subject.month_letter(0).should be_nil
21
+ -1.upto(0).each do |n|
22
+ expect(subject.month_letter(n)).to be_nil
23
+ end
20
24
  end
21
25
  end
22
26
  end
@@ -1,23 +1,33 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe CodiceFiscale::FiscalCode do
4
- let(:citizen_marco_galli) { CodiceFiscale::ItalianCitizen.new :name => 'Marco', :surname => 'Galli', :gender => :male, :birthdate => Date.new(1983, 5, 3), :city_name => 'Oggiono', :province_code => 'LC' }
4
+ let(:citizen_marco_galli) do
5
+ CodiceFiscale::ItalianCitizen.new(
6
+ :name => 'Marco',
7
+ :surname => 'Galli',
8
+ :gender => :male,
9
+ :birthdate => Date.new(1983, 5, 3),
10
+ :city_name => 'Oggiono',
11
+ :province_code => 'LC'
12
+ )
13
+ end
14
+
5
15
  let(:fiscal_code) { described_class.new citizen_marco_galli }
6
16
 
7
17
  describe '#surname_part' do
8
18
  it 'takes the first 3 consonants' do
9
- fiscal_code.surname_part.should == 'GLL'
19
+ expect(fiscal_code.surname_part).to eq 'GLL'
10
20
  end
11
21
 
12
22
  it 'is 3 chrs long' do
13
- fiscal_code.surname_part.size.should == 3
23
+ expect(fiscal_code.surname_part.size).to eq 3
14
24
  end
15
25
 
16
26
  context 'when surname has only 1 consonant' do
17
27
  before { fiscal_code.citizen.surname = 'oof' }
18
28
 
19
29
  it 'puts the vowels after the consonants' do
20
- fiscal_code.surname_part.should == 'FOO'
30
+ expect(fiscal_code.surname_part).to eq 'FOO'
21
31
  end
22
32
  end
23
33
 
@@ -25,21 +35,21 @@ describe CodiceFiscale::FiscalCode do
25
35
  before { fiscal_code.citizen.surname = 'm' }
26
36
 
27
37
  it 'pads with the "X" character' do
28
- fiscal_code.surname_part.should == 'MXX'
38
+ expect(fiscal_code.surname_part).to eq 'MXX'
29
39
  end
30
40
  end
31
41
  end
32
42
 
33
43
  describe '#name_part' do
34
44
  it 'is 3 chrs long' do
35
- fiscal_code.name_part.size.should == 3
45
+ expect(fiscal_code.name_part.size).to eq 3
36
46
  end
37
47
 
38
48
  context 'when name has 4 or more consonants' do
39
49
  before { fiscal_code.citizen.name = 'danielino' }
40
50
 
41
51
  it 'takes the 1st the 3rd and the 4th' do
42
- fiscal_code.name_part.should == 'DLN'
52
+ expect(fiscal_code.name_part).to eq 'DLN'
43
53
  end
44
54
  end
45
55
 
@@ -47,7 +57,7 @@ describe CodiceFiscale::FiscalCode do
47
57
  before { fiscal_code.citizen.name = 'daniele' }
48
58
 
49
59
  it 'takes the first 3 consonants' do
50
- fiscal_code.name_part.should == 'DNL'
60
+ expect(fiscal_code.name_part).to eq 'DNL'
51
61
  end
52
62
  end
53
63
 
@@ -55,7 +65,7 @@ describe CodiceFiscale::FiscalCode do
55
65
  before { fiscal_code.citizen.name = 'bar' }
56
66
 
57
67
  it 'puts the vowels after the consonants' do
58
- fiscal_code.name_part.should == 'BRA'
68
+ expect(fiscal_code.name_part).to eq 'BRA'
59
69
  end
60
70
  end
61
71
 
@@ -63,7 +73,7 @@ describe CodiceFiscale::FiscalCode do
63
73
  before { fiscal_code.citizen.name = 'd' }
64
74
 
65
75
  it 'pad with the "X" character' do
66
- fiscal_code.name_part.should == 'DXX'
76
+ expect(fiscal_code.name_part).to eq 'DXX'
67
77
  end
68
78
  end
69
79
  end
@@ -71,14 +81,16 @@ describe CodiceFiscale::FiscalCode do
71
81
 
72
82
  describe '#birthdate_part' do
73
83
  it 'start with the last 2 digit of the year' do
74
- fiscal_code.birthdate_part.should start_with '83'
84
+ expect(fiscal_code.birthdate_part).to start_with '83'
75
85
  end
76
86
 
77
87
  describe 'the 3rd character' do
78
- before { CodiceFiscale::Codes.stub(:month_letter).and_return('X') }
88
+ before do
89
+ allow(CodiceFiscale::Codes).to receive(:month_letter).and_return('X')
90
+ end
79
91
 
80
92
  it 'is the month code' do
81
- fiscal_code.birthdate_part[2].should == 'X'
93
+ expect(fiscal_code.birthdate_part[2]).to eq 'X'
82
94
  end
83
95
  end
84
96
 
@@ -86,13 +98,13 @@ describe CodiceFiscale::FiscalCode do
86
98
  context 'gender is male' do
87
99
  before { fiscal_code.citizen.gender = :male }
88
100
 
89
- it('is the birth day') { fiscal_code.birthdate_part[3..5].should == '03' }
101
+ it('is the birth day') { expect(fiscal_code.birthdate_part[3..5]).to eq '03' }
90
102
  end
91
103
 
92
104
  context 'gender is female' do
93
105
  before { fiscal_code.citizen.gender = :female }
94
106
 
95
- it('is the birth day + 40') { fiscal_code.birthdate_part[3..5].should == '43' }
107
+ it('is the birth day + 40') { expect(fiscal_code.birthdate_part[3..5]).to eq '43' }
96
108
  end
97
109
  end
98
110
  end
@@ -105,15 +117,17 @@ describe CodiceFiscale::FiscalCode do
105
117
  before { fiscal_code.config.city_code { 'Winterfell' } }
106
118
 
107
119
  it 'returns the result of the city-block execution' do
108
- fiscal_code.birthplace_part.should == 'Winterfell'
120
+ expect(fiscal_code.birthplace_part). to eq 'Winterfell'
109
121
  end
110
122
  end
111
123
 
112
124
  context 'when codes are fetched using csv' do
113
- before { CodiceFiscale::Codes.stub(:city).and_return('hello') }
125
+ before do
126
+ allow(CodiceFiscale::Codes).to receive(:city).and_return('hello')
127
+ end
114
128
 
115
129
  it 'returns the city code' do
116
- fiscal_code.birthplace_part.should == 'hello'
130
+ expect(fiscal_code.birthplace_part).to eq 'hello'
117
131
  end
118
132
  end
119
133
  end
@@ -125,15 +139,17 @@ describe CodiceFiscale::FiscalCode do
125
139
  before { fiscal_code.config.country_code { 'The North' } }
126
140
 
127
141
  it 'returns the result of the country-block execution' do
128
- fiscal_code.birthplace_part.should == 'The North'
142
+ expect(fiscal_code.birthplace_part).to eq 'The North'
129
143
  end
130
144
  end
131
145
 
132
146
  context 'when codes are fetched using csv' do
133
- before { CodiceFiscale::Codes.stub(:country).and_return('Middle-Earth') }
147
+ before do
148
+ allow(CodiceFiscale::Codes).to receive(:country).and_return('Middle-Earth')
149
+ end
134
150
 
135
151
  it 'returns the country code' do
136
- fiscal_code.birthplace_part.should == 'Middle-Earth'
152
+ expect(fiscal_code.birthplace_part).to eq 'Middle-Earth'
137
153
  end
138
154
  end
139
155
  end
@@ -141,7 +157,7 @@ describe CodiceFiscale::FiscalCode do
141
157
 
142
158
  describe '#control_character' do
143
159
  it 'returns the expected letter' do
144
- fiscal_code.control_character('RSSMRA87A01A005').should == 'V'
160
+ expect(fiscal_code.control_character('RSSMRA87A01A005')).to eq 'V'
145
161
  end
146
162
  end
147
- end
163
+ end