br_documents 0.1.3 → 0.2.0

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.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/config.yml +54 -0
  3. data/.rubocop.yml +65 -0
  4. data/Gemfile +1 -1
  5. data/Gemfile.lock +76 -42
  6. data/README.md +33 -0
  7. data/Rakefile +3 -3
  8. data/br_documents.gemspec +23 -19
  9. data/lib/br_documents.rb +3 -3
  10. data/lib/br_documents/cnpj_cpf/cnpj.rb +2 -2
  11. data/lib/br_documents/cnpj_cpf/cpf.rb +2 -2
  12. data/lib/br_documents/cnpj_cpf/document.rb +9 -9
  13. data/lib/br_documents/cnpj_validator.rb +4 -4
  14. data/lib/br_documents/commons/mod11.rb +1 -2
  15. data/lib/br_documents/commons/mod14.rb +1 -2
  16. data/lib/br_documents/cpf_validator.rb +4 -4
  17. data/lib/br_documents/gtin/gtin.rb +1 -1
  18. data/lib/br_documents/gtin_validator.rb +6 -6
  19. data/lib/br_documents/ie/ac.rb +3 -2
  20. data/lib/br_documents/ie/al.rb +2 -1
  21. data/lib/br_documents/ie/am.rb +3 -2
  22. data/lib/br_documents/ie/ap.rb +20 -16
  23. data/lib/br_documents/ie/ba.rb +28 -25
  24. data/lib/br_documents/ie/base.rb +1 -1
  25. data/lib/br_documents/ie/ce.rb +3 -2
  26. data/lib/br_documents/ie/df.rb +3 -2
  27. data/lib/br_documents/ie/es.rb +2 -1
  28. data/lib/br_documents/ie/factory.rb +3 -3
  29. data/lib/br_documents/ie/go.rb +3 -2
  30. data/lib/br_documents/ie/ma.rb +2 -1
  31. data/lib/br_documents/ie/mg.rb +14 -17
  32. data/lib/br_documents/ie/ms.rb +2 -1
  33. data/lib/br_documents/ie/mt.rb +6 -5
  34. data/lib/br_documents/ie/pa.rb +3 -2
  35. data/lib/br_documents/ie/pattern1.rb +10 -7
  36. data/lib/br_documents/ie/pattern2.rb +9 -8
  37. data/lib/br_documents/ie/pb.rb +3 -2
  38. data/lib/br_documents/ie/pe.rb +10 -10
  39. data/lib/br_documents/ie/pi.rb +2 -1
  40. data/lib/br_documents/ie/pr.rb +3 -2
  41. data/lib/br_documents/ie/rj.rb +3 -2
  42. data/lib/br_documents/ie/rn.rb +19 -16
  43. data/lib/br_documents/ie/ro.rb +16 -13
  44. data/lib/br_documents/ie/rr.rb +4 -3
  45. data/lib/br_documents/ie/rs.rb +3 -2
  46. data/lib/br_documents/ie/sc.rb +3 -2
  47. data/lib/br_documents/ie/se.rb +3 -2
  48. data/lib/br_documents/ie/sp.rb +17 -14
  49. data/lib/br_documents/ie/to.rb +6 -5
  50. data/lib/br_documents/ie_validator.rb +7 -7
  51. data/lib/br_documents/suframa/suframa.rb +60 -0
  52. data/lib/br_documents/suframa_validator.rb +8 -0
  53. data/lib/br_documents/version.rb +1 -1
  54. data/spec/cnpj_cpf/cnpj_spec.rb +21 -21
  55. data/spec/cnpj_cpf/cpf_spec.rb +21 -21
  56. data/spec/cnpj_validator_spec.rb +12 -12
  57. data/spec/cpf_validator_spec.rb +12 -12
  58. data/spec/gtin/gtin_spec.rb +2 -2
  59. data/spec/gtin_validator_spec.rb +13 -13
  60. data/spec/ie/ac_spec.rb +16 -16
  61. data/spec/ie/al_spec.rb +14 -14
  62. data/spec/ie/am_spec.rb +16 -16
  63. data/spec/ie/ap_spec.rb +14 -14
  64. data/spec/ie/ba_spec.rb +28 -28
  65. data/spec/ie/ce_spec.rb +9 -9
  66. data/spec/ie/df_spec.rb +16 -16
  67. data/spec/ie/es_spec.rb +9 -9
  68. data/spec/ie/factory_spec.rb +88 -89
  69. data/spec/ie/go_spec.rb +16 -16
  70. data/spec/ie/ma_spec.rb +9 -9
  71. data/spec/ie/mg_spec.rb +16 -16
  72. data/spec/ie/ms_spec.rb +9 -9
  73. data/spec/ie/mt_spec.rb +17 -17
  74. data/spec/ie/pa_spec.rb +16 -16
  75. data/spec/ie/pb_spec.rb +9 -9
  76. data/spec/ie/pe_spec.rb +27 -27
  77. data/spec/ie/pi_spec.rb +9 -9
  78. data/spec/ie/pr_spec.rb +14 -14
  79. data/spec/ie/rj_spec.rb +16 -16
  80. data/spec/ie/rn_spec.rb +27 -27
  81. data/spec/ie/ro_spec.rb +27 -27
  82. data/spec/ie/rr_spec.rb +16 -16
  83. data/spec/ie/rs_spec.rb +16 -16
  84. data/spec/ie/sc_spec.rb +16 -16
  85. data/spec/ie/se_spec.rb +9 -9
  86. data/spec/ie/shared_examples_for_pattern1.rb +11 -11
  87. data/spec/ie/shared_examples_for_to_remove_all_masks.rb +7 -8
  88. data/spec/ie/sp_spec.rb +19 -19
  89. data/spec/ie/to_spec.rb +35 -35
  90. data/spec/ie_validator_spec.rb +7 -5
  91. data/spec/spec_helper.rb +6 -6
  92. data/spec/suframa/suframa_spec.rb +109 -0
  93. data/spec/suframa_validator_spec.rb +36 -0
  94. data/spec/support/utilities.rb +2 -2
  95. metadata +86 -23
  96. data/.circleci/config.yml +0 -42
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25cf99032b0bea6b2a016595a560e0a7ea5777154f74d9259009b50323473a61
4
- data.tar.gz: f19aa466afa9077bfbe14184d8311bc7db6486d36d1f73ed855c2b00218a062a
3
+ metadata.gz: 26654dc4bd73502f9cf3fadf4a33104f218a47fb81e02c71c8a23f9d78c75d91
4
+ data.tar.gz: 5ec58159f531151f3b759ac907d3d16dfd269fb3a26091f559a6e23798bcce07
5
5
  SHA512:
6
- metadata.gz: 3f37a4a5244a984e8ed4bf93077e43dd92caec88ea2e9ee7243b8819c6c520050658d7fdcc3164518a7b324f0e777b78346cbe3e024bc019515e258d251d68a3
7
- data.tar.gz: 67cf2292f3ca90a52ff6790155c6a32382f7c54475b7d572c3fd491f63a756676c88c333f83bd6f961cc97a6fc321df5139c2c7f10881a0af3239bafac313a5c
6
+ metadata.gz: 724248b106f9db144d555521a59728e100e881e77261d25d2399d630e10461694adc241b027f6b53577db2d3f68ab11806d6fecaf76261bf98401d0daef780a8
7
+ data.tar.gz: 05b814e328dec4ef44f0ebe2f5af18a86ea35d920cb5537ca235e8ba30c2786a550577e4f86fc232d6760d9b589557a76c29f1c09f2848ad305ae1e8d184707b
@@ -0,0 +1,54 @@
1
+ name: Containers
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+
9
+ steps:
10
+ - uses: actions/checkout@v2
11
+
12
+ - uses: ruby/setup-ruby@v1
13
+ with:
14
+ ruby-version: 2.7.3
15
+ bundler-cache: true
16
+
17
+ rspec:
18
+ runs-on: ubuntu-latest
19
+
20
+ needs: build
21
+
22
+ steps:
23
+ - uses: actions/checkout@v2
24
+
25
+ - uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: 2.7.3
28
+ bundler-cache: true
29
+
30
+ - run: |
31
+ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
32
+ chmod +x ./cc-test-reporter
33
+ - run: |
34
+ ./cc-test-reporter before-build
35
+ bundle exec rspec
36
+ ./cc-test-reporter after-build -r $CC_TEST_REPORTER_ID --exit-code $?
37
+ env:
38
+ CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
39
+
40
+ lint:
41
+ runs-on: ubuntu-latest
42
+
43
+ needs: build
44
+
45
+ steps:
46
+
47
+ - uses: actions/checkout@v2
48
+
49
+ - uses: ruby/setup-ruby@v1
50
+ with:
51
+ ruby-version: 2.7.3
52
+ bundler-cache: true
53
+
54
+ - run: bundle exec rubocop --display-cop-names --parallel
data/.rubocop.yml ADDED
@@ -0,0 +1,65 @@
1
+ # Offense count: 1
2
+ # Configuration parameters: Include.
3
+ # Include: **/*.gemspec
4
+ Gemspec/RequiredRubyVersion:
5
+ Exclude:
6
+ - 'br_documents.gemspec'
7
+
8
+ # Offense count: 1
9
+ # Configuration parameters: Include.
10
+ # Include: **/*.gemspec
11
+ Gemspec/RubyVersionGlobalsUsage:
12
+ Exclude:
13
+ - 'br_documents.gemspec'
14
+
15
+ # Offense count: 1
16
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
17
+ Metrics/AbcSize:
18
+ Max: 20
19
+
20
+ Metrics/BlockLength:
21
+ Exclude:
22
+ - 'spec/**/*.rb'
23
+
24
+ Style/Documentation:
25
+ Enabled: false
26
+
27
+ Style/FrozenStringLiteralComment:
28
+ EnforcedStyle: never # default: always
29
+
30
+ # Offense count: 39
31
+ # Cop supports --auto-correct.
32
+ Style/RedundantRegexpEscape:
33
+ Enabled: false
34
+
35
+ # Offense count: 18
36
+ # Cop supports --auto-correct.
37
+ # Configuration parameters: EnforcedStyle, AllowInnerSlashes.
38
+ # SupportedStyles: slashes, percent_r, mixed
39
+ Style/RegexpLiteral:
40
+ Exclude:
41
+ - 'lib/br_documents/cnpj_cpf/cnpj.rb'
42
+ - 'lib/br_documents/cnpj_cpf/document.rb'
43
+ - 'lib/br_documents/ie/ac.rb'
44
+ - 'lib/br_documents/ie/ba.rb'
45
+ - 'lib/br_documents/ie/mg.rb'
46
+ - 'lib/br_documents/ie/mt.rb'
47
+ - 'lib/br_documents/ie/pattern1.rb'
48
+ - 'lib/br_documents/ie/pattern2.rb'
49
+ - 'lib/br_documents/ie/pe.rb'
50
+ - 'lib/br_documents/ie/rn.rb'
51
+ - 'lib/br_documents/ie/ro.rb'
52
+ - 'lib/br_documents/ie/rs.rb'
53
+ - 'lib/br_documents/ie/sp.rb'
54
+ - 'spec/ie/shared_examples_for_to_remove_all_masks.rb'
55
+
56
+ # Offense count: 1
57
+ # Cop supports --auto-correct.
58
+ # Configuration parameters: EnforcedStyle.
59
+ # SupportedStyles: use_perl_names, use_english_names
60
+ Style/SpecialGlobalVars:
61
+ Exclude:
62
+ - 'br_documents.gemspec'
63
+
64
+ Style/WordArray:
65
+ EnforcedStyle: brackets
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
data/Gemfile.lock CHANGED
@@ -1,54 +1,84 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- br_documents (0.1.3)
4
+ br_documents (0.2.0)
5
5
  activemodel (>= 4.0.0)
6
6
  i18n (>= 0.6.5)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (6.0.0)
12
- activesupport (= 6.0.0)
13
- activesupport (6.0.0)
11
+ activemodel (6.1.3.2)
12
+ activesupport (= 6.1.3.2)
13
+ activesupport (6.1.3.2)
14
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
- i18n (>= 0.7, < 2)
16
- minitest (~> 5.1)
17
- tzinfo (~> 1.1)
18
- zeitwerk (~> 2.1, >= 2.1.8)
19
- byebug (10.0.2)
15
+ i18n (>= 1.6, < 2)
16
+ minitest (>= 5.1)
17
+ tzinfo (~> 2.0)
18
+ zeitwerk (~> 2.3)
19
+ ast (2.4.2)
20
+ byebug (11.1.3)
20
21
  codeclimate-test-reporter (1.0.7)
21
22
  simplecov
22
- concurrent-ruby (1.1.5)
23
- diff-lcs (1.3)
24
- docile (1.1.5)
25
- i18n (1.7.0)
23
+ concurrent-ruby (1.1.9)
24
+ diff-lcs (1.4.4)
25
+ docile (1.4.0)
26
+ i18n (1.8.10)
26
27
  concurrent-ruby (~> 1.0)
27
- json (2.0.3)
28
- minitest (5.13.0)
29
- rake (12.0.0)
30
- rspec (3.5.0)
31
- rspec-core (~> 3.5.0)
32
- rspec-expectations (~> 3.5.0)
33
- rspec-mocks (~> 3.5.0)
34
- rspec-core (3.5.4)
35
- rspec-support (~> 3.5.0)
36
- rspec-expectations (3.5.0)
28
+ minitest (5.14.4)
29
+ parallel (1.20.1)
30
+ parser (3.0.1.1)
31
+ ast (~> 2.4.1)
32
+ rack (2.2.3)
33
+ rainbow (3.0.0)
34
+ rake (13.0.3)
35
+ regexp_parser (2.1.1)
36
+ rexml (3.2.5)
37
+ rspec (3.10.0)
38
+ rspec-core (~> 3.10.0)
39
+ rspec-expectations (~> 3.10.0)
40
+ rspec-mocks (~> 3.10.0)
41
+ rspec-core (3.10.1)
42
+ rspec-support (~> 3.10.0)
43
+ rspec-expectations (3.10.1)
37
44
  diff-lcs (>= 1.2.0, < 2.0)
38
- rspec-support (~> 3.5.0)
39
- rspec-mocks (3.5.0)
45
+ rspec-support (~> 3.10.0)
46
+ rspec-mocks (3.10.2)
40
47
  diff-lcs (>= 1.2.0, < 2.0)
41
- rspec-support (~> 3.5.0)
42
- rspec-support (3.5.0)
43
- simplecov (0.14.0)
44
- docile (~> 1.1.0)
45
- json (>= 1.8, < 3)
46
- simplecov-html (~> 0.10.0)
47
- simplecov-html (0.10.0)
48
- thread_safe (0.3.6)
49
- tzinfo (1.2.6)
50
- thread_safe (~> 0.1)
51
- zeitwerk (2.2.2)
48
+ rspec-support (~> 3.10.0)
49
+ rspec-support (3.10.2)
50
+ rubocop (1.15.0)
51
+ parallel (~> 1.10)
52
+ parser (>= 3.0.0.0)
53
+ rainbow (>= 2.2.2, < 4.0)
54
+ regexp_parser (>= 1.8, < 3.0)
55
+ rexml
56
+ rubocop-ast (>= 1.5.0, < 2.0)
57
+ ruby-progressbar (~> 1.7)
58
+ unicode-display_width (>= 1.4.0, < 3.0)
59
+ rubocop-ast (1.7.0)
60
+ parser (>= 3.0.1.1)
61
+ rubocop-performance (1.11.3)
62
+ rubocop (>= 1.7.0, < 2.0)
63
+ rubocop-ast (>= 0.4.0)
64
+ rubocop-rails (2.10.1)
65
+ activesupport (>= 4.2.0)
66
+ rack (>= 1.1)
67
+ rubocop (>= 1.7.0, < 2.0)
68
+ rubocop-rspec (2.3.0)
69
+ rubocop (~> 1.0)
70
+ rubocop-ast (>= 1.1.0)
71
+ ruby-progressbar (1.11.0)
72
+ simplecov (0.21.2)
73
+ docile (~> 1.1)
74
+ simplecov-html (~> 0.11)
75
+ simplecov_json_formatter (~> 0.1)
76
+ simplecov-html (0.12.3)
77
+ simplecov_json_formatter (0.1.3)
78
+ tzinfo (2.0.4)
79
+ concurrent-ruby (~> 1.0)
80
+ unicode-display_width (2.0.0)
81
+ zeitwerk (2.4.2)
52
82
 
53
83
  PLATFORMS
54
84
  ruby
@@ -56,11 +86,15 @@ PLATFORMS
56
86
  DEPENDENCIES
57
87
  br_documents!
58
88
  bundler (>= 1.3)
59
- byebug (= 10.0.2)
60
- codeclimate-test-reporter
61
- rake (>= 10.1.0)
62
- rspec (>= 3.0.0)
63
- simplecov (>= 0.9.0)
89
+ byebug (= 11.1.3)
90
+ codeclimate-test-reporter (>= 1.0.7)
91
+ rake (>= 13.0.3)
92
+ rspec (>= 3.10.0)
93
+ rubocop (~> 1.15.0)
94
+ rubocop-performance (~> 1.11.3)
95
+ rubocop-rails (~> 2.10.1)
96
+ rubocop-rspec (~> 2.3.0)
97
+ simplecov (>= 0.21.2)
64
98
 
65
99
  BUNDLED WITH
66
- 1.17.2
100
+ 2.1.4
data/README.md CHANGED
@@ -115,6 +115,29 @@ pj.ie = "111.111.111"
115
115
  pj.valid? # => false
116
116
  ```
117
117
 
118
+ #### SUFRAMA
119
+
120
+ ```ruby
121
+ class Person < ActiveRecord::Base
122
+
123
+ attr_accessor :suframa
124
+
125
+ validates :suframa,
126
+ suframa: true
127
+ end
128
+
129
+
130
+ pj = Person.new
131
+ pj.suframa = "100698107"
132
+ pj.valid? # => true
133
+
134
+ pj.suframa = "10.0698.107" # with mask
135
+ pj.valid? # => true
136
+
137
+ pj.suframa = "11.1111.111"
138
+ pj.valid? # => false
139
+ ```
140
+
118
141
  ### Ruby
119
142
 
120
143
  #### CNPJ
@@ -147,6 +170,16 @@ ie.formatted # => "254.062.407"
147
170
  ie.valid? # => true
148
171
  ```
149
172
 
173
+ #### SUFRAMA
174
+
175
+ ```ruby
176
+ require "br_documents"
177
+
178
+ suframa = BrDocuments::Suframa.new("100698107")
179
+ suframa.formatted # => "10.0698.107"
180
+ suframa.valid? # => true
181
+ ```
182
+
150
183
  ## Environment variables
151
184
 
152
185
  The following variables are necessary to be set:
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
- require "rspec/core/rake_task"
2
- require "bundler/gem_tasks"
1
+ require 'rspec/core/rake_task'
2
+ require 'bundler/gem_tasks'
3
3
 
4
4
  task default: :spec
5
5
  RSpec::Core::RakeTask.new
6
6
 
7
7
  desc "Open an irb session preloaded class's"
8
8
  task :console do
9
- sh "irb -rubygems -I lib -r br_documents.rb"
9
+ sh 'irb -rubygems -I lib -r br_documents.rb'
10
10
  end
data/br_documents.gemspec CHANGED
@@ -1,30 +1,34 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "br_documents/version"
3
+ require 'br_documents/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "br_documents"
6
+ spec.name = 'br_documents'
8
7
  spec.version = BrDocuments::VERSION
9
- spec.authors = ["ASSEINFO - Sistemas de Informação"]
10
- spec.email = ["asseinfo@asseinfo.com.br"]
11
- spec.description = "Validates brazilian documents like CPF, CNPJ and IE."
12
- spec.summary = "Validates brazilian documents like CPF, CNPJ and IE. It can be used with active record or just in ruby."
13
- spec.homepage = "http://github.com/asseinfo/br_documents"
14
- spec.license = "MIT"
8
+ spec.authors = ['ASSEINFO - Sistemas de Informação']
9
+ spec.email = ['asseinfo@asseinfo.com.br']
10
+ spec.description = 'Validates brazilian documents like CPF, CNPJ and IE.'
11
+ spec.summary = 'Validates brazilian documents like CPF, CNPJ and IE. It can be used with active record '\
12
+ 'or just in ruby.'
13
+ spec.homepage = 'http://github.com/asseinfo/br_documents'
14
+ spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency "activemodel", ">= 4.0.0"
22
- spec.add_dependency "i18n", ">= 0.6.5"
21
+ spec.add_dependency 'activemodel', '>= 4.0.0'
22
+ spec.add_dependency 'i18n', '>= 0.6.5'
23
23
 
24
- spec.add_development_dependency "bundler", ">= 1.3"
25
- spec.add_development_dependency "rake", ">= 10.1.0"
26
- spec.add_development_dependency "rspec", ">= 3.0.0"
27
- spec.add_development_dependency "codeclimate-test-reporter"
28
- spec.add_development_dependency "simplecov", ">= 0.9.0"
29
- spec.add_development_dependency "byebug", "10.0.2" if RUBY_VERSION >= "2.0"
24
+ spec.add_development_dependency 'bundler', '>= 1.3'
25
+ spec.add_development_dependency 'byebug', '11.1.3' if RUBY_VERSION >= '2.0'
26
+ spec.add_development_dependency 'codeclimate-test-reporter', '>= 1.0.7'
27
+ spec.add_development_dependency 'rake', '>= 13.0.3'
28
+ spec.add_development_dependency 'rspec', '>= 3.10.0'
29
+ spec.add_development_dependency 'rubocop', '~> 1.15.0'
30
+ spec.add_development_dependency 'rubocop-performance', '~> 1.11.3'
31
+ spec.add_development_dependency 'rubocop-rails', '~> 2.10.1'
32
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.3.0'
33
+ spec.add_development_dependency 'simplecov', '>= 0.21.2'
30
34
  end
data/lib/br_documents.rb CHANGED
@@ -1,5 +1,5 @@
1
- require "active_model"
1
+ require 'active_model'
2
2
 
3
- Dir[File.dirname(__FILE__) + "/**/*.rb"].each { |f| require f }
3
+ Dir["#{File.dirname(__FILE__)}/**/*.rb"].sort.each { |f| require f }
4
4
 
5
- I18n.load_path << File.expand_path("../../config/locales/pt-BR.yml", __FILE__)
5
+ I18n.load_path << File.expand_path('../config/locales/pt-BR.yml', __dir__)
@@ -1,4 +1,4 @@
1
- require_relative "document"
1
+ require_relative 'document'
2
2
 
3
3
  module BrDocuments
4
4
  module CnpjCpf
@@ -16,7 +16,7 @@ module BrDocuments
16
16
  end
17
17
 
18
18
  def format_number
19
- @number.sub(/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/, "\\1.\\2.\\3/\\4-\\5")
19
+ @number.sub(/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/, '\\1.\\2.\\3/\\4-\\5')
20
20
  end
21
21
  end
22
22
  end
@@ -1,4 +1,4 @@
1
- require_relative "document"
1
+ require_relative 'document'
2
2
 
3
3
  module BrDocuments
4
4
  module CnpjCpf
@@ -16,7 +16,7 @@ module BrDocuments
16
16
  end
17
17
 
18
18
  def format_number
19
- @number.sub(/(\d{3})(\d{3})(\d{3})(\d{2})/, "\\1.\\2.\\3-\\4")
19
+ @number.sub(/(\d{3})(\d{3})(\d{3})(\d{2})/, '\\1.\\2.\\3-\\4')
20
20
  end
21
21
  end
22
22
  end
@@ -1,4 +1,4 @@
1
- require_relative "../commons/mod11"
1
+ require_relative '../commons/mod11'
2
2
 
3
3
  module BrDocuments
4
4
  module CnpjCpf
@@ -10,11 +10,11 @@ module BrDocuments
10
10
  end
11
11
 
12
12
  def valid?
13
- valid_format? && !sequence_of_equal_numbers? && valid_digital_check?
13
+ valid_format? && !sequence_of_equal_numbers? && valid_check_digit?
14
14
  end
15
15
 
16
16
  def formatted
17
- valid? ? format_number : ""
17
+ valid? ? format_number : ''
18
18
  end
19
19
 
20
20
  private
@@ -24,19 +24,19 @@ module BrDocuments
24
24
  end
25
25
 
26
26
  def sequence_of_equal_numbers?
27
- number_without_mask.split("").uniq.length == 1
27
+ number_without_mask.split('').uniq.length == 1
28
28
  end
29
29
 
30
- def valid_digital_check?
30
+ def valid_check_digit?
31
31
  weight1, weight2 = weights_for_digital_check
32
32
 
33
- digital_check1 = generate_digital_check(number_without_mask, weight1)
34
- digital_check2 = generate_digital_check(number_without_mask, weight2)
35
- @number[-2, 2].eql? "#{digital_check1}#{digital_check2}"
33
+ digital_check1 = generate_check_digit(number_without_mask, weight1)
34
+ digital_check2 = generate_check_digit(number_without_mask, weight2)
35
+ @number[-2, 2] == "#{digital_check1}#{digital_check2}"
36
36
  end
37
37
 
38
38
  def number_without_mask
39
- @number.gsub(/[\.\/-]/, "")
39
+ @number.gsub(/[\.\/-]/, '')
40
40
  end
41
41
  end
42
42
  end