rfc_facil 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/rfc_facil/homoclave_calculator.rb +0 -1
- data/lib/rfc_facil/rfc.rb +1 -1
- data/lib/rfc_facil/version.rb +1 -1
- data/rfc_facil.gemspec +1 -1
- data/tests/rfc_facil/test_homoclave_calculator.rb +18 -18
- data/tests/rfc_facil/test_rfc.rb +7 -7
- data/tests/rfc_facil/test_ten_digits_code_calculator.rb +17 -17
- data/tests/rfc_facil/test_verification_digit_calculator.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e4beff53f9889d87b462d70ef89626a465c47fd
|
4
|
+
data.tar.gz: 2c3a42b7c21b0799d0d88581917476c86a054cc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef619a13b09e212df01f75df492fc5d616de7c546d647fc7fbc01f752a1f656baa624c6e304f94c904e22c74f7b1a2bc7c4769d6b21901fd6865716cb010bc91
|
7
|
+
data.tar.gz: 21b4428b04a98f0f5acf266a8984ea0201f85e62b53ed4f80e43601b3b9167efda69b7ab3be5f95cfbbcdc66416ef9da5eb2c34fddc4c04dc500d8304bc46f07
|
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# Rfc Fácil
|
2
|
-
![](logo.png)
|
2
|
+
![](https://github.com/acrogenesis/rfc_facil/raw/master/logo.png)
|
3
3
|
|
4
4
|
Libreria para calcular el Registro Federal de Contribuyentes en México (RFC) en Ruby.
|
5
5
|
|
6
|
+
[![Build Status](https://travis-ci.org/acrogenesis/rfc_facil.svg?branch=master)](https://travis-ci.org/acrogenesis/rfc_facil)
|
7
|
+
|
6
8
|
## Uso
|
7
9
|
|
8
10
|
```ruby
|
@@ -20,5 +22,5 @@ Esta librería se basa en documentación oficial obtenida por medio del IFAI (In
|
|
20
22
|
### Agradecimiento
|
21
23
|
El código es una version en Ruby de [rfc-facil](https://github.com/josketres/rfc-facil) hecha en Java por [josketres](https://github.com/josketres)
|
22
24
|
|
23
|
-
##
|
25
|
+
## Colabora
|
24
26
|
Errores y pull requests son bienvenidos en Github: https://github.com/acrogenesis/rfc_facil.
|
@@ -35,7 +35,6 @@ class HomoclaveCalculator
|
|
35
35
|
|
36
36
|
def sum_pairs_of_digits
|
37
37
|
@pairs_of_digits_sum = 0
|
38
|
-
# @mapped_full_name[0..-2].each_char do |c, i|
|
39
38
|
(0..@mapped_full_name.length - 2).each do |i|
|
40
39
|
num1 = @mapped_full_name[i..i + 1].to_i
|
41
40
|
num2 = @mapped_full_name[i + 1..i + 1].to_i
|
data/lib/rfc_facil/rfc.rb
CHANGED
@@ -13,7 +13,7 @@ class Rfc
|
|
13
13
|
@person = Person.new(@name, @first_last_name, @second_last_name, @day, @month, @year)
|
14
14
|
@ten_digits_code = TenDigitsCodeCalculator.new(@person).calculate
|
15
15
|
@homoclave = HomoclaveCalculator.new(@person).calculate
|
16
|
-
@verification_digit = VerificationDigitCalculator.new(@ten_digits_code
|
16
|
+
@verification_digit = VerificationDigitCalculator.new("#{@ten_digits_code}#{@homoclave}").calculate
|
17
17
|
end
|
18
18
|
|
19
19
|
def to_s
|
data/lib/rfc_facil/version.rb
CHANGED
data/rfc_facil.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ['adrian.rangel@gmail.com']
|
11
11
|
|
12
12
|
spec.summary = 'Libreria para calcular el Registro Federal de Contribuyentes en México (RFC).'
|
13
|
-
spec.homepage = 'https://
|
13
|
+
spec.homepage = 'https://acrogenesis.com/rfc_facil/'
|
14
14
|
|
15
15
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
16
|
spec.bindir = 'exe'
|
@@ -1,57 +1,57 @@
|
|
1
1
|
class TestHomoclaveCalculator < Minitest::Test
|
2
2
|
def test_calculate_homoclave_for_simple_test_case
|
3
|
-
assert_equal(homoclave('Juan', 'Perez', 'Garcia')
|
3
|
+
assert_equal('LN', homoclave('Juan', 'Perez', 'Garcia'))
|
4
4
|
end
|
5
5
|
|
6
6
|
def test_calculate_same_homoclave_for_names_with_and_without_accents
|
7
|
-
assert_equal(homoclave('Juan', '
|
8
|
-
homoclave('Juan', '
|
7
|
+
assert_equal(homoclave('Juan', 'Pérez', 'García'),
|
8
|
+
homoclave('Juan', 'Perez', 'Garcia'))
|
9
9
|
end
|
10
10
|
|
11
11
|
def test_calculate_homoclave_for_person_with_more_than_one_name
|
12
|
-
assert_equal(homoclave('Jose Antonio', 'Del real', 'Anzures')
|
12
|
+
assert_equal('N9', homoclave('Jose Antonio', 'Del real', 'Anzures'))
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_calculate_homoclave_for_name_with_n_with_tilde
|
16
|
-
assert_equal(homoclave('Juan', 'Muñoz', 'Ortega')
|
16
|
+
assert_equal('T6', homoclave('Juan', 'Muñoz', 'Ortega'))
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_calculate_homoclave_for_name_with_multiple_n_with_tilde
|
20
|
-
assert_equal(homoclave('Juan', 'Muñoz', 'Muñoz')
|
20
|
+
assert_equal('RZ', homoclave('Juan', 'Muñoz', 'Muñoz'))
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_calculate_different_homoclave_for_name_with_n_with_tilde_and_without
|
24
|
-
refute_equal(homoclave('Juan', '
|
25
|
-
homoclave('Juan', '
|
24
|
+
refute_equal(homoclave('Juan', 'Munoz', 'Ortega'),
|
25
|
+
homoclave('Juan', 'Muñoz', 'Ortega'))
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_calculate_homoclave_for_name_with_u_with_umlaut
|
29
|
-
assert_equal(homoclave('Jesus', 'Argüelles', 'Ortega')
|
29
|
+
assert_equal('JF', homoclave('Jesus', 'Argüelles', 'Ortega'))
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_calculate_same_homoclave_for_name_with_u_with_umlaut_and_without
|
33
|
-
assert_equal(homoclave('Jesus', '
|
34
|
-
homoclave('Jesus', '
|
33
|
+
assert_equal(homoclave('Jesus', 'Arguelles', 'Ortega'),
|
34
|
+
homoclave('Jesus', 'Argüelles', 'Ortega'))
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_calculate_homoclave_for_name_with_ampersand
|
38
|
-
assert_equal(homoclave('Juan', 'Perez&Gomez', 'Garcia')
|
38
|
+
assert_equal('2R', homoclave('Juan', 'Perez&Gomez', 'Garcia'))
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_calculate_same_homoclave_for_name_with_and_without_special_characters
|
42
|
-
assert_equal(homoclave('Juan', '
|
43
|
-
homoclave('Juan', '
|
42
|
+
assert_equal(homoclave('Juan', 'McGregor', 'OConnorJuarez'),
|
43
|
+
homoclave('Juan', 'Mc.Gregor', "O'Connor-Juarez"))
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_calculate_different_homoclave_for_names_with_and_without_ampersand
|
47
|
-
refute_equal(homoclave('Juan', '
|
48
|
-
homoclave('Juan', '
|
47
|
+
refute_equal(homoclave('Juan', 'PerezGomez', 'Garcia'),
|
48
|
+
homoclave('Juan', 'Perez&Gomez', 'Garcia'))
|
49
49
|
end
|
50
50
|
|
51
51
|
def test_calculate_same_homoclave_for_different_birthdays
|
52
52
|
assert_equal(
|
53
|
-
HomoclaveCalculator.new(Person.new('Juan', 'Perez', 'Garcia',
|
54
|
-
HomoclaveCalculator.new(Person.new('Juan', 'Perez', 'Garcia',
|
53
|
+
HomoclaveCalculator.new(Person.new('Juan', 'Perez', 'Garcia', 5, 8, 1987)).calculate,
|
54
|
+
HomoclaveCalculator.new(Person.new('Juan', 'Perez', 'Garcia', 1, 1, 1901)).calculate
|
55
55
|
)
|
56
56
|
end
|
57
57
|
|
data/tests/rfc_facil/test_rfc.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
class TestRfc < Minitest::Test
|
2
|
-
def
|
3
|
-
Rfc.new(name: 'Adrian Marcelo', first_last_name: 'Rangel',
|
4
|
-
|
2
|
+
def test_rfc
|
3
|
+
rfc = Rfc.new(name: 'Adrian Marcelo', first_last_name: 'Rangel',
|
4
|
+
second_last_name: 'Araujo', day: 27, month: 11, year: 1992)
|
5
5
|
|
6
|
-
assert_equal(rfc.ten_digits_code
|
7
|
-
assert_equal(rfc.homoclave
|
8
|
-
assert_equal(rfc.verification_digit
|
9
|
-
assert_equal(rfc.to_s
|
6
|
+
assert_equal('RAAA921127', rfc.ten_digits_code)
|
7
|
+
assert_equal('RI', rfc.homoclave)
|
8
|
+
assert_equal('6', rfc.verification_digit)
|
9
|
+
assert_equal('RAAA921127RI6', rfc.to_s)
|
10
10
|
end
|
11
11
|
end
|
@@ -1,72 +1,72 @@
|
|
1
1
|
class TestTenDigitsCodeCalculator < Minitest::Test
|
2
2
|
def test_calculate_ten_digits_code_for_simple_test_case
|
3
|
-
assert_equal(ten_digits_code('Juan', 'Barrios', 'Fernandez', 13, 12, 1970)
|
3
|
+
assert_equal('BAFJ701213', ten_digits_code('Juan', 'Barrios', 'Fernandez', 13, 12, 1970))
|
4
4
|
end
|
5
5
|
|
6
6
|
def test_calculate_ten_digits_code_for_date_after_year_2000
|
7
|
-
assert_equal(ten_digits_code('Juan', 'Barrios', 'Fernandez', 1, 12, 2001)
|
7
|
+
assert_equal('BAFJ011201', ten_digits_code('Juan', 'Barrios', 'Fernandez', 1, 12, 2001))
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_exclude_special_particles_in_both_last_names
|
11
11
|
# DE, LA, LAS, MC, VON, DEL, LOS, Y, MAC, VAN, MI
|
12
|
-
assert_equal(ten_digits_code('Eric', 'Mc Gregor', 'Von Juarez', 13, 12, 1970)
|
12
|
+
assert_equal('GEJE701213', ten_digits_code('Eric', 'Mc Gregor', 'Von Juarez', 13, 12, 1970))
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_exclude_special_particles_in_the_first_last_name
|
16
|
-
assert_equal(ten_digits_code('Josue', 'Zarzosa', 'de la Torre', 13, 12, 1970)
|
16
|
+
assert_equal('ZATJ701213', ten_digits_code('Josue', 'Zarzosa', 'de la Torre', 13, 12, 1970))
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_exclude_special_particles_in_the_second_last_name
|
20
|
-
assert_equal(ten_digits_code('Josue', 'de la Torre', 'Zarzosa', 13, 12, 1970)
|
20
|
+
assert_equal('TOZJ701213', ten_digits_code('Josue', 'de la Torre', 'Zarzosa', 13, 12, 1970))
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_use_first_word_of_compound_second_last_name
|
24
|
-
assert_equal(ten_digits_code('Antonio', 'Jiménez', 'Ponce de León', 13, 12, 1970)
|
24
|
+
assert_equal('JIPA701213', ten_digits_code('Antonio', 'Jiménez', 'Ponce de León', 13, 12, 1970))
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_use_first_word_of_compound_first_last_name
|
28
|
-
assert_equal(ten_digits_code('Antonio', 'Ponce de León', 'Juarez', 13, 12, 1970)
|
28
|
+
assert_equal('POJA701213', ten_digits_code('Antonio', 'Ponce de León', 'Juarez', 13, 12, 1970))
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_use_use_first_two_letters_of_first_name_if_first_last_name_has_just_one_letter
|
32
|
-
assert_equal(ten_digits_code('Alvaro', 'de la O', 'Lozano', 13, 12, 1970)
|
32
|
+
assert_equal('OLAL701213', ten_digits_code('Alvaro', 'de la O', 'Lozano', 13, 12, 1970))
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_use_use_first_two_letters_of_first_name_if_first_last_name_has_just_two_letters
|
36
|
-
assert_equal(ten_digits_code('Ernesto', 'Ek', 'Rivera', 13, 12, 1970)
|
36
|
+
assert_equal('ERER701213', ten_digits_code('Ernesto', 'Ek', 'Rivera', 13, 12, 1970))
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_use_first_name_if_person_has_multiple_names
|
40
|
-
assert_equal(ten_digits_code('Luz María', 'Fernández', 'Juárez', 13, 12, 1970)
|
40
|
+
assert_equal('FEJL701213', ten_digits_code('Luz María', 'Fernández', 'Juárez', 13, 12, 1970))
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_use_second_name_if_person_has_multiple_names_and_first_name_is_jose
|
44
|
-
assert_equal(ten_digits_code('José Antonio', 'Camargo', 'Hernández', 13, 12, 1970)
|
44
|
+
assert_equal('CAHA701213', ten_digits_code('José Antonio', 'Camargo', 'Hernández', 13, 12, 1970))
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_use_second_name_if_person_has_multiple_names_and_first_name_is_maria
|
48
|
-
assert_equal(ten_digits_code('María Luisa', 'Ramírez', 'Sánchez', 13, 12, 1970)
|
48
|
+
assert_equal('RASL701213', ten_digits_code('María Luisa', 'Ramírez', 'Sánchez', 13, 12, 1970))
|
49
49
|
end
|
50
50
|
|
51
51
|
def test_use_first_two_letters_of_second_last_name_if_empty_first_last_name_is_provided
|
52
|
-
assert_equal(ten_digits_code('Juan', '', 'Martínez', 13, 12, 1970)
|
52
|
+
assert_equal('MAJU701213', ten_digits_code('Juan', '', 'Martínez', 13, 12, 1970))
|
53
53
|
end
|
54
54
|
|
55
55
|
def test_use_first_two_letters_of_second_last_name_if_nil_first_last_name_is_provided
|
56
|
-
assert_equal(ten_digits_code('Juan', nil, 'Martínez', 13, 12, 1970)
|
56
|
+
assert_equal('MAJU701213', ten_digits_code('Juan', nil, 'Martínez', 13, 12, 1970))
|
57
57
|
end
|
58
58
|
|
59
59
|
def test_use_first_two_letters_of_first_last_name_if_empty_second_last_name_is_provided
|
60
|
-
assert_equal(ten_digits_code('Gerarda', 'Zafra', '', 13, 12, 1970)
|
60
|
+
assert_equal('ZAGE701213', ten_digits_code('Gerarda', 'Zafra', '', 13, 12, 1970))
|
61
61
|
end
|
62
62
|
|
63
63
|
def test_use_first_two_letters_of_first_last_name_if_nil_second_last_name_is_provided
|
64
|
-
assert_equal(ten_digits_code('Gerarda', 'Zafra', nil, 13, 12, 1970)
|
64
|
+
assert_equal('ZAGE701213', ten_digits_code('Gerarda', 'Zafra', nil, 13, 12, 1970))
|
65
65
|
end
|
66
66
|
|
67
67
|
def test_replace_last_letter_with_x_if_code_makes_forbidden_word
|
68
68
|
# BUEI -> BUEX
|
69
|
-
assert_equal(ten_digits_code('Ingrid', 'Bueno', 'Ezquerra', 13, 12, 1970)
|
69
|
+
assert_equal('BUEX701213', ten_digits_code('Ingrid', 'Bueno', 'Ezquerra', 13, 12, 1970))
|
70
70
|
end
|
71
71
|
|
72
72
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rfc_facil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Rangel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -108,7 +108,7 @@ files:
|
|
108
108
|
- tests/rfc_facil/test_ten_digits_code_calculator.rb
|
109
109
|
- tests/rfc_facil/test_verification_digit_calculator.rb
|
110
110
|
- tests/tests_helper.rb
|
111
|
-
homepage: https://
|
111
|
+
homepage: https://acrogenesis.com/rfc_facil/
|
112
112
|
licenses: []
|
113
113
|
metadata: {}
|
114
114
|
post_install_message:
|