codice-fiscale 0.0.9 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2e072ece1130ef8f44d55c4cc5302a5f75e5a9e7
4
- data.tar.gz: 0bf6f20346f36a33672630176c8da7bcc260320c
2
+ SHA256:
3
+ metadata.gz: 89e95f933b63caed0471e5f122e8c75edec7103d60c60ffe7ec94cbba683406a
4
+ data.tar.gz: 37f446137438d2d3ff95d7d559b2a0f860bd03e557fa6da60ae37efcaef51185
5
5
  SHA512:
6
- metadata.gz: 552e467c8f707cbfac1204f653a2fcef45ab2e3bcdc40c52cc15aeeccbf0a20010da084922cd68befb0aaf59dc75d2f2f16a6fef5e3be07a2890da2e380ffacd
7
- data.tar.gz: c97c3375af51451728abea74762ea1c87836be9a7dc9c488ca8374c297daea8cff02126aef9a6985f60fef610835ae3e496b00c7fb875da46dc360f209eeb9af
6
+ metadata.gz: e98eaa75284471bd9b3cbd1828dc3ba12c724121b75c998188850433817aab1e69e898e7232230a0f6bfed96be469c0dd087631fe1fa441ac2392776b0b9b872
7
+ data.tar.gz: e7a39273e69faa6dcdc3291971775d40372e0abd18b8418dc986a0f831fccf21b215728bb630a09329a4b765215f4db0301a46e5af535c950cc97798913bd130
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ sudo: false
3
+ cache: bundler
4
+ rvm:
5
+ - 1.9.3
6
+ - 2.0
7
+ - 2.1
8
+ - 2.2
9
+ - 2.4
10
+ - 2.5
11
+ - 2.6
12
+ - ruby-head
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
- guard_options = {
5
- :all_after_pass => false,
6
- :all_on_start => false,
7
- :bundler => true,
8
- :notification => true,
9
- :keep_failed => false,
10
- :cli => "-c -f doc"
11
- }
12
-
13
- guard('rspec', guard_options) do
14
- watch(%r{^spec/.+_spec\.rb$})
15
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
16
- watch('spec/spec_helper.rb') { "spec" }
17
-
18
- # Rails example
19
- watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
20
- watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
21
- watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
22
- watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
23
- watch('config/routes.rb') { "spec/routing" }
24
- watch('app/controllers/application_controller.rb') { "spec/controllers" }
25
-
26
- # Capybara request specs
27
- watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
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$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
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
- # Codice fiscale
1
+ [![Gem Version](https://badge.fury.io/rb/codice-fiscale.svg)](https://badge.fury.io/rb/codice-fiscale)
2
+ [![Build Status](https://travis-ci.org/topac/codice_fiscale.svg?branch=master)](https://travis-ci.org/topac/codice_fiscale)
2
3
 
3
- A ruby gem to support the calculation of the italian fiscal code ("Cofice fiscale"),
4
- that is an ID assigned to each italian citizen by the "Agenzia delle entrate".
4
+ # Codice Fiscale (Italian Tax ID)
5
5
 
6
- To calculate the fiscal code you need the following information: name, surname,
7
- gender, birthdate and the birthplace. Read more on [wikipedia](http://en.wikipedia.org/wiki/Italian_fiscal_code_card).
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 => 'LC',
20
- :city_name => 'Abbadia Lariana'
35
+ :province_code => 'MI',
36
+ :city_name => 'Milano'
21
37
  )
22
- #=> RSSMRA87A01A005V
38
+ # => RSSMRA87A01F205E
23
39
  ```
24
40
 
25
- ## City codes (Codici catastali)
26
- As explained above, one of the information required to calculate the fiscal code is the birthplace.
27
- If a person was born outside Italy, only the italian name of the county is required.
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 an XLS
41
- document downloaded from [istat.it](http://www.istat.it/it/archivio/6789), converted to CSV and shipped with this gem.
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 tables/files:
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
- Country.find_by_name(country_name).code
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
- City.in_italy.find_by_province_and_city(province_code, city_name).code
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
- I'm using RSpec + guard (+ growl for notifications)
87
+ $ bundle exec rspec
79
88
 
80
- $ bundle exec guard
89
+ This gem is tested with all ruby versions starting from 1.9.3.
81
90
 
82
91
  ## Contributing
83
92
 
data/Rakefile CHANGED
@@ -1,2 +1,6 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+
4
+ task :default => :spec
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new
@@ -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 = ["dani.m.mobile@gmail.com"]
7
- gem.description = %q{Calculate the italian fiscal code}
8
- gem.summary = %q{Calculate the italian fiscal code}
9
- gem.homepage = "https://github.com/daniele-m/codice_fiscale"
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'