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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90d241e12a7657fe09501ed8d060af1f0b563c4e
4
- data.tar.gz: 84a309812ff7c1e5161446d88882a6dae3dbdf6b
3
+ metadata.gz: 2e4beff53f9889d87b462d70ef89626a465c47fd
4
+ data.tar.gz: 2c3a42b7c21b0799d0d88581917476c86a054cc9
5
5
  SHA512:
6
- metadata.gz: 793b87293071c2ae0870bf405bc531119f891eaad72816061c03c32d841fb2355230d86efb979169cac04593987b707199d02d58c5ec339e7649b0da67f8c664
7
- data.tar.gz: 580a7adbfb39eaf743274a3827d547e8ea5ca30e15b21558cb3b6c67097ac2b6b28b6171258faf5802e53a544667751f2a5b1288f6859f66ddf918fabc5626c3
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
- ## Contributing
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 << @homoclave).calculate
16
+ @verification_digit = VerificationDigitCalculator.new("#{@ten_digits_code}#{@homoclave}").calculate
17
17
  end
18
18
 
19
19
  def to_s
@@ -1,3 +1,3 @@
1
1
  module RfcFacil
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
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://github.com/acrogenesis/rfc_facil'
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'), 'LN')
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', 'Perez', 'Garcia'),
8
- homoclave('Juan', 'Pérez', 'García'))
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'), 'N9')
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'), 'T6')
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'), 'RZ')
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', 'Muñoz', 'Ortega'),
25
- homoclave('Juan', 'Munoz', 'Ortega'))
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'), 'JF')
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', 'Argüelles', 'Ortega'),
34
- homoclave('Jesus', 'Arguelles', 'Ortega'))
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'), '2R')
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', 'Mc.Gregor', "O'Connor-Juarez"),
43
- homoclave('Juan', 'McGregor', 'OConnorJuarez'))
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', 'Perez&Gomez', 'Garcia'),
48
- homoclave('Juan', 'PerezGomez', 'Garcia'))
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', 1, 1, 1901)).calculate,
54
- HomoclaveCalculator.new(Person.new('Juan', 'Perez', 'Garcia', 5, 8, 1987)).calculate
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
 
@@ -1,11 +1,11 @@
1
1
  class TestRfc < Minitest::Test
2
- def should_build_rfc
3
- Rfc.new(name: 'Adrian Marcelo', first_last_name: 'Rangel',
4
- second_last_name: 'Araujo', day: 27, month: 11, year: 1992)
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, 'RAAA921127')
7
- assert_equal(rfc.homoclave, 'RI')
8
- assert_equal(rfc.verification_digit, '6')
9
- assert_equal(rfc.to_s, 'RAAA921127RI6')
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), 'BAFJ701213')
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), 'BAFJ011201')
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), 'GEJE701213')
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), 'ZATJ701213')
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), 'TOZJ701213')
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), 'JIPA701213')
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), 'POJA701213')
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), 'OLAL701213')
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), 'ERER701213')
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), 'FEJL701213')
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), 'CAHA701213')
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), 'RASL701213')
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), 'MAJU701213')
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), 'MAJU701213')
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), 'ZAGE701213')
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), 'ZAGE701213')
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), 'BUEX701213')
69
+ assert_equal('BUEX701213', ten_digits_code('Ingrid', 'Bueno', 'Ezquerra', 13, 12, 1970))
70
70
  end
71
71
 
72
72
  private
@@ -1,6 +1,6 @@
1
1
  class VerificationDigitCalculatorTest < Minitest::Test
2
2
  def test_calculate_verification_digit
3
- assert_equal(verification_digit('GODE561231GR'), '8')
3
+ assert_equal('8', verification_digit('GODE561231GR'))
4
4
  end
5
5
 
6
6
  def verification_digit(rfc12Digit)
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.0
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 00:00:00.000000000 Z
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://github.com/acrogenesis/rfc_facil
111
+ homepage: https://acrogenesis.com/rfc_facil/
112
112
  licenses: []
113
113
  metadata: {}
114
114
  post_install_message: