codice-fiscale 0.0.9 → 1.0.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/.travis.yml +12 -0
- data/Guardfile +63 -26
- data/README.md +43 -34
- data/Rakefile +4 -0
- data/codice_fiscale.gemspec +5 -6
- data/lib/codice_fiscale/codes/city_codes.csv +7924 -1
- data/lib/codice_fiscale/codes/country_codes.csv +216 -1
- data/lib/codice_fiscale/codes.rb +3 -3
- data/lib/codice_fiscale/version.rb +1 -1
- data/lib/codice_fiscale.rb +79 -0
- data/spec/lib/codice_fiscale/alphabet_spec.rb +16 -8
- data/spec/lib/codice_fiscale/codes_spec.rb +7 -3
- data/spec/lib/codice_fiscale/fiscal_code_spec.rb +39 -23
- data/spec/lib/codice_fiscale/italian_citizen_spec.rb +8 -8
- data/spec/lib/codice_fiscale_spec.rb +16 -7
- data/spec/spec_helper.rb +0 -2
- metadata +20 -26
- data/spec/fixtures/city_codes.csv +0 -1
- data/spec/fixtures/country_codes.csv +0 -1
- data/spec/lib/codice_fiscale/helpers_spec.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 89e95f933b63caed0471e5f122e8c75edec7103d60c60ffe7ec94cbba683406a
|
4
|
+
data.tar.gz: 37f446137438d2d3ff95d7d559b2a0f860bd03e557fa6da60ae37efcaef51185
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e98eaa75284471bd9b3cbd1828dc3ba12c724121b75c998188850433817aab1e69e898e7232230a0f6bfed96be469c0dd087631fe1fa441ac2392776b0b9b872
|
7
|
+
data.tar.gz: e7a39273e69faa6dcdc3291971775d40372e0abd18b8418dc986a0f831fccf21b215728bb630a09329a4b765215f4db0301a46e5af535c950cc97798913bd130
|
data/.travis.yml
ADDED
data/Guardfile
CHANGED
@@ -1,33 +1,70 @@
|
|
1
1
|
# A sample Guardfile
|
2
2
|
# More info at https://github.com/guard/guard#readme
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
+
# rspec may be run, below are examples of the most common uses.
|
20
|
+
# * bundler: 'bundle exec rspec'
|
21
|
+
# * bundler binstubs: 'bin/rspec'
|
22
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
+
# installed the spring binstubs per the docs)
|
24
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
+
# * 'just' rspec: 'rspec'
|
26
|
+
|
27
|
+
guard :rspec, :cmd => "bundle exec rspec" do
|
28
|
+
require "guard/rspec/dsl"
|
29
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
30
|
+
|
31
|
+
# Feel free to open issues for suggestions and improvements
|
32
|
+
|
33
|
+
# RSpec files
|
34
|
+
rspec = dsl.rspec
|
35
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
36
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
37
|
+
watch(rspec.spec_files)
|
38
|
+
|
39
|
+
# Ruby files
|
40
|
+
ruby = dsl.ruby
|
41
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
42
|
+
|
43
|
+
# Rails files
|
44
|
+
rails = dsl.rails(:view_extensions => %w(erb haml slim))
|
45
|
+
dsl.watch_spec_files_for(rails.app_files)
|
46
|
+
dsl.watch_spec_files_for(rails.views)
|
47
|
+
|
48
|
+
watch(rails.controllers) do |m|
|
49
|
+
[
|
50
|
+
rspec.spec.call("routing/#{m[1]}_routing"),
|
51
|
+
rspec.spec.call("controllers/#{m[1]}_controller"),
|
52
|
+
rspec.spec.call("acceptance/#{m[1]}")
|
53
|
+
]
|
54
|
+
end
|
55
|
+
|
56
|
+
# Rails config changes
|
57
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
58
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
59
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
60
|
+
|
61
|
+
# Capybara features specs
|
62
|
+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
63
|
+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
|
28
64
|
|
29
65
|
# Turnip features and steps
|
30
66
|
watch(%r{^spec/acceptance/(.+)\.feature$})
|
31
|
-
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$})
|
67
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
68
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
69
|
+
end
|
32
70
|
end
|
33
|
-
|
data/README.md
CHANGED
@@ -1,10 +1,26 @@
|
|
1
|
-
|
1
|
+
[](https://badge.fury.io/rb/codice-fiscale)
|
2
|
+
[](https://travis-ci.org/topac/codice_fiscale)
|
2
3
|
|
3
|
-
|
4
|
-
that is an ID assigned to each italian citizen by the "Agenzia delle entrate".
|
4
|
+
# Codice Fiscale (Italian Tax ID)
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
A Ruby gem that calculates the *Codice Fiscale* (Italian Tax ID).
|
7
|
+
|
8
|
+
The *Codice Fiscale* is an identifier unique to each person that is used when dealing with Italian government offices or for private concerns and is formulated using a combination of the person’s name, place and date of birth. Usually it is attributed by the Office of Income Revenue (*Agenzia delle Entrate*) through local tax offices.
|
9
|
+
|
10
|
+
The code is 16 characters long and includes both letters and numbers, for e.g: `RSSMRA90A01H501W` (taken from [this sample card](https://i.imgur.com/UVXKDX8.png)). Read more on [wikipedia](http://en.wikipedia.org/wiki/Italian_fiscal_code_card) or [here](https://itamcap.com/italian-tax-id).
|
11
|
+
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
**WARNING:** The gem name on rubygems.org is "codice-fiscale" not "codice_fiscale"
|
16
|
+
|
17
|
+
Add this line to your application's Gemfile:
|
18
|
+
```ruby
|
19
|
+
source 'https://rubygems.org'
|
20
|
+
gem 'codice-fiscale'
|
21
|
+
```
|
22
|
+
|
23
|
+
And then execute the `bundle install` command.
|
8
24
|
|
9
25
|
## Usage
|
10
26
|
|
@@ -13,18 +29,18 @@ gender, birthdate and the birthplace. Read more on [wikipedia](http://en.wikiped
|
|
13
29
|
|
14
30
|
CodiceFiscale.calculate(
|
15
31
|
:name => 'Mario',
|
16
|
-
:surname => 'Rossi',
|
32
|
+
:surname => 'Rossi',
|
17
33
|
:gender => :male,
|
18
34
|
:birthdate => Date.new(1987, 1, 1),
|
19
|
-
:province_code => '
|
20
|
-
:city_name => '
|
35
|
+
:province_code => 'MI',
|
36
|
+
:city_name => 'Milano'
|
21
37
|
)
|
22
|
-
|
38
|
+
# => RSSMRA87A01F205E
|
23
39
|
```
|
24
40
|
|
25
|
-
## City codes (Codici
|
26
|
-
As explained above, one of the information required to calculate the
|
27
|
-
If a person was born outside Italy, only the italian name of the
|
41
|
+
## City codes (Codici Catastali)
|
42
|
+
As explained above, one of the information required to calculate the tax ID is the birthplace.
|
43
|
+
If a person was born outside Italy, only the italian name of the country is required.
|
28
44
|
For example, an italian citizen born in France:
|
29
45
|
|
30
46
|
```ruby
|
@@ -35,49 +51,42 @@ For example, an italian citizen born in France:
|
|
35
51
|
:birthdate => Date.new(1987, 1, 1),
|
36
52
|
:country_name => 'Francia'
|
37
53
|
)
|
54
|
+
# => RSSMRA87A01Z110I
|
38
55
|
```
|
39
56
|
|
40
|
-
If a person was born in Italy you have to specify the *code* of the province and the *name* of the city. These informations are actually contained in
|
41
|
-
document downloaded from [istat.it](http://www.istat.it/it/archivio/6789), converted
|
57
|
+
If a person was born in Italy you have to specify the *code* of the province and the *name* of the city. These informations are actually contained in a CSV
|
58
|
+
document downloaded from [istat.it](http://www.istat.it/it/archivio/6789), converted and shipped with this gem.
|
59
|
+
|
42
60
|
|
43
61
|
**But what if you have your own table with all those codes?**
|
44
62
|
|
45
|
-
In this case, you can add a custom block that fetches the codes from your
|
63
|
+
In this case, you can add a custom block that fetches the codes from your database:
|
46
64
|
|
47
65
|
|
48
66
|
*config/initializers/codice_fiscale_initializer.rb*:
|
49
67
|
|
50
68
|
```ruby
|
51
|
-
# Fetching the codes using ActiveRecord:
|
52
|
-
|
53
69
|
CodiceFiscale.config.country_code do |country_name|
|
54
|
-
|
70
|
+
# Place your code here, for e.g.:
|
71
|
+
YourCountryActiveRecordModel.find_by_name(country_name).code
|
72
|
+
# So that given for e.g. country_name="Denmark" the returned code must be "Z107"
|
73
|
+
# Checkout the file ./lib/codice_fiscale/codes/country_codes.csv
|
55
74
|
end
|
56
75
|
|
57
76
|
CodiceFiscale.config.city_code do |city_name, province_code|
|
58
|
-
|
77
|
+
# Place your code here, for e.g.:
|
78
|
+
YourCityActiveRecordModel.find_by_province_and_city(province_code, city_name).code
|
79
|
+
# So that given for e.g. city_name="Fiumicino", province_code="RM" the returned code must be "M297"
|
80
|
+
# Checkout the file ./lib/codice_fiscale/codes/city_codes.csv
|
59
81
|
end
|
60
82
|
```
|
61
83
|
|
62
|
-
## Installation
|
63
|
-
|
64
|
-
I'm currently supporting only **ruby 1.9+**
|
65
|
-
|
66
|
-
**Note:** The gem name on rubygems.org is "codice-fiscale" not "codice_fiscale"
|
67
|
-
|
68
|
-
Add this line to your application's Gemfile:
|
69
|
-
|
70
|
-
gem 'codice-fiscale'
|
71
|
-
|
72
|
-
And then execute:
|
73
|
-
|
74
|
-
$ bundle
|
75
84
|
|
76
85
|
## Testing
|
77
86
|
|
78
|
-
|
87
|
+
$ bundle exec rspec
|
79
88
|
|
80
|
-
|
89
|
+
This gem is tested with all ruby versions starting from 1.9.3.
|
81
90
|
|
82
91
|
## Contributing
|
83
92
|
|
data/Rakefile
CHANGED
data/codice_fiscale.gemspec
CHANGED
@@ -3,10 +3,10 @@ require File.expand_path('../lib/codice_fiscale/version', __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["topac"]
|
6
|
-
gem.email = ["
|
7
|
-
gem.description = %q{Calculate the
|
8
|
-
gem.summary = %q{Calculate the
|
9
|
-
gem.homepage = "https://github.com/
|
6
|
+
gem.email = ["topac@users.noreply.github.com"]
|
7
|
+
gem.description = %q{Calculate the Italian Tax ID (Codice Fiscale)}
|
8
|
+
gem.summary = %q{Calculate the Italian Tax ID (Codice Fiscale)}
|
9
|
+
gem.homepage = "https://github.com/topac/codice_fiscale"
|
10
10
|
gem.platform = Gem::Platform::RUBY
|
11
11
|
|
12
12
|
gem.files = `git ls-files`.split($\)
|
@@ -16,11 +16,10 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.require_paths = ["lib"]
|
17
17
|
gem.version = CodiceFiscale::VERSION
|
18
18
|
|
19
|
+
gem.add_development_dependency 'rake'
|
19
20
|
gem.add_development_dependency 'rspec'
|
20
21
|
gem.add_development_dependency 'guard-rspec'
|
21
22
|
gem.add_development_dependency 'rb-fsevent', '~> 0.9.1'
|
22
|
-
# The growl app must be separately downloaded and installed
|
23
|
-
gem.add_development_dependency 'growl'
|
24
23
|
|
25
24
|
gem.add_dependency 'activesupport'
|
26
25
|
gem.add_dependency 'activemodel'
|