README.md in codice-fiscale-0.0.9 vs README.md in codice-fiscale-1.0.0

- old
+ new

@@ -1,84 +1,93 @@ -# Codice fiscale +[![Gem Version](https://badge.fury.io/rb/codice-fiscale.svg)](https://badge.fury.io/rb/codice-fiscale) +[![Build Status](https://travis-ci.org/topac/codice_fiscale.svg?branch=master)](https://travis-ci.org/topac/codice_fiscale) -A ruby gem to support the calculation of the italian fiscal code ("Cofice fiscale"), -that is an ID assigned to each italian citizen by the "Agenzia delle entrate". +# Codice Fiscale (Italian Tax ID) -To calculate the fiscal code you need the following information: name, surname, -gender, birthdate and the birthplace. Read more on [wikipedia](http://en.wikipedia.org/wiki/Italian_fiscal_code_card). +A Ruby gem that calculates the *Codice FIscale* (Italian Tax ID). +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. + +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). + + +## Installation + +**WARNING:** The gem name on rubygems.org is "codice-fiscale" not "codice_fiscale" + +Add this line to your application's Gemfile: +```ruby + source 'https://rubygems.org' + gem 'codice-fiscale' +``` + +And then execute the `bundle install` command. + ## Usage ```ruby require 'codice_fiscale' CodiceFiscale.calculate( :name => 'Mario', - :surname => 'Rossi', + :surname => 'Rossi', :gender => :male, :birthdate => Date.new(1987, 1, 1), - :province_code => 'LC', - :city_name => 'Abbadia Lariana' + :province_code => 'MI', + :city_name => 'Milano' ) - #=> RSSMRA87A01A005V + # => RSSMRA87A01F205E ``` -## City codes (Codici catastali) +## City codes (Codici Catastali) As explained above, one of the information required to calculate the fiscal code is the birthplace. -If a person was born outside Italy, only the italian name of the county is required. +If a person was born outside Italy, only the italian name of the country is required. For example, an italian citizen born in France: ```ruby CodiceFiscale.calculate( :name => 'Mario', :surname => 'Rossi', :gender => :male, :birthdate => Date.new(1987, 1, 1), :country_name => 'Francia' ) + # => RSSMRA87A01Z110I ``` -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 an XLS -document downloaded from [istat.it](http://www.istat.it/it/archivio/6789), converted to CSV and shipped with this gem. +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 +document downloaded from [istat.it](http://www.istat.it/it/archivio/6789), converted and shipped with this gem. + **But what if you have your own table with all those codes?** -In this case, you can add a custom block that fetches the codes from your tables/files: +In this case, you can add a custom block that fetches the codes from your database: *config/initializers/codice_fiscale_initializer.rb*: ```ruby - # Fetching the codes using ActiveRecord: - CodiceFiscale.config.country_code do |country_name| - Country.find_by_name(country_name).code + # Place your code here, for e.g.: + YourCountryActiveRecordModel.find_by_name(country_name).code + # So that given for e.g. country_name="Denmark" the returned code must be "Z107" + # Checkout the file ./lib/codice_fiscale/codes/country_codes.csv end CodiceFiscale.config.city_code do |city_name, province_code| - City.in_italy.find_by_province_and_city(province_code, city_name).code + # Place your code here, for e.g.: + YourCityActiveRecordModel.find_by_province_and_city(province_code, city_name).code + # So that given for e.g. city_name="Fiumicino", province_code="RM" the returned code must be "M297" + # Checkout the file ./lib/codice_fiscale/codes/city_codes.csv end ``` -## Installation -I'm currently supporting only **ruby 1.9+** - -**Note:** The gem name on rubygems.org is "codice-fiscale" not "codice_fiscale" - -Add this line to your application's Gemfile: - - gem 'codice-fiscale' - -And then execute: - - $ bundle - ## Testing -I'm using RSpec + guard (+ growl for notifications) + $ bundle exec rspec - $ bundle exec guard +This gem is tested with all ruby versions starting from 1.9.3. ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`)