br_documents 0.2.5 → 1.0.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 (44) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/config.yml +7 -10
  3. data/.rubocop.yml +17 -2
  4. data/Gemfile.lock +87 -48
  5. data/br_documents.gemspec +7 -7
  6. data/lib/br_documents/ie/ap.rb +2 -2
  7. data/lib/br_documents/ie/ba.rb +5 -5
  8. data/lib/br_documents/ie/pe.rb +2 -6
  9. data/lib/br_documents/ie/rn.rb +4 -5
  10. data/lib/br_documents/ie/ro.rb +6 -6
  11. data/lib/br_documents/suframa.rb +1 -1
  12. data/lib/br_documents/version.rb +1 -1
  13. data/lib/br_documents.rb +1 -1
  14. data/spec/br_documents/ie/ac_spec.rb +1 -1
  15. data/spec/br_documents/ie/al_spec.rb +1 -1
  16. data/spec/br_documents/ie/am_spec.rb +1 -1
  17. data/spec/br_documents/ie/ap_spec.rb +1 -1
  18. data/spec/br_documents/ie/ba_spec.rb +2 -2
  19. data/spec/br_documents/ie/ce_spec.rb +1 -1
  20. data/spec/br_documents/ie/df_spec.rb +1 -1
  21. data/spec/br_documents/ie/es_spec.rb +1 -1
  22. data/spec/br_documents/ie/go_spec.rb +1 -1
  23. data/spec/br_documents/ie/ma_spec.rb +1 -1
  24. data/spec/br_documents/ie/mg_spec.rb +1 -1
  25. data/spec/br_documents/ie/ms_spec.rb +1 -1
  26. data/spec/br_documents/ie/mt_spec.rb +1 -1
  27. data/spec/br_documents/ie/pa_spec.rb +1 -1
  28. data/spec/br_documents/ie/pb_spec.rb +1 -1
  29. data/spec/br_documents/ie/pe_spec.rb +1 -1
  30. data/spec/br_documents/ie/pi_spec.rb +1 -1
  31. data/spec/br_documents/ie/pr_spec.rb +1 -1
  32. data/spec/br_documents/ie/rj_spec.rb +1 -1
  33. data/spec/br_documents/ie/rn_spec.rb +1 -1
  34. data/spec/br_documents/ie/ro_spec.rb +1 -1
  35. data/spec/br_documents/ie/rr_spec.rb +1 -1
  36. data/spec/br_documents/ie/rs_spec.rb +1 -1
  37. data/spec/br_documents/ie/sc_spec.rb +1 -1
  38. data/spec/br_documents/ie/se_spec.rb +1 -1
  39. data/spec/br_documents/ie/sp_spec.rb +1 -1
  40. data/spec/br_documents/ie/to_spec.rb +1 -1
  41. data/spec/br_documents/ie_validator_spec.rb +1 -2
  42. data/spec/br_documents/suframa_validator_spec.rb +1 -1
  43. data/spec/spec_helper.rb +9 -2
  44. metadata +28 -70
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91d2ac26c3f7fa33806675aa10ca8d08b6d276983724e373a872ab5540ea369c
4
- data.tar.gz: 2ce24db58349653730f9338e16bda7b96459bb3670f21fb7383dbf9e6ce498be
3
+ metadata.gz: bb487d9d86c27524deb86b68a427f8eb375dee3c79b2ef3a51780e551c8eb08e
4
+ data.tar.gz: ab945dce20f45f5da54d47517ccb92fa51ac668932696d897f4981a915d86df8
5
5
  SHA512:
6
- metadata.gz: 7f2a2eedad3ce0394be82a13f019f0236044992e9e87f63a933889e99ff9e282a8b3c6e561520c22de4e6e3311b88fa7772b89c94e8955baf564683a0190e44a
7
- data.tar.gz: c03ce1f4d3c38ccf37b11a8ae725f0b7478fe9aae4124c7c2cb84d116d93878d2de451146f854e6e191406ec8a6e1ab63295013366a89d775c68bfa24a149669
6
+ metadata.gz: 9fe9865dc6c6b9c94988b6f67b371996fc3e287033e0587026e502606592041e8fb58088015fc084c964bde7edd297ebed756d5fb3914c065f220c4b779ef776
7
+ data.tar.gz: 2a7cb3d025e30a6019f7a2cec9774ef62ca7281c496187cc87f6e4e4c09ecb2c85c287e65ff8f3a89b15fa9d39eb0e9b32054688b1c5c2a8ecbddad4b41e2111
@@ -8,11 +8,11 @@ jobs:
8
8
 
9
9
  steps:
10
10
 
11
- - uses: actions/checkout@v3
11
+ - uses: actions/checkout@v4
12
12
 
13
13
  - uses: ruby/setup-ruby@v1
14
14
  with:
15
- ruby-version: 3.0.4
15
+ ruby-version: 3.4
16
16
  bundler-cache: true
17
17
 
18
18
  - run: bundle exec rubocop --display-cop-names --parallel
@@ -21,20 +21,17 @@ jobs:
21
21
  runs-on: ubuntu-latest
22
22
 
23
23
  steps:
24
- - uses: actions/checkout@v3
24
+ - uses: actions/checkout@v4
25
25
 
26
26
  - uses: ruby/setup-ruby@v1
27
27
  with:
28
- ruby-version: 3.0.4
28
+ ruby-version: 3.4
29
29
  bundler-cache: true
30
30
 
31
- - run: |
32
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
33
- chmod +x ./cc-test-reporter
31
+ - run: curl https://qlty.sh | sh
34
32
 
35
33
  - run: |
36
- ./cc-test-reporter before-build
37
34
  bundle exec rspec
38
- ./cc-test-reporter after-build -r $CC_TEST_REPORTER_ID --exit-code $?
35
+ ~/.qlty/bin/qlty coverage publish coverage/coverage.json
39
36
  env:
40
- CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
37
+ QLTY_COVERAGE_TOKEN: ${{secrets.QLTY_COVERAGE_TOKEN}}
data/.rubocop.yml CHANGED
@@ -4,13 +4,13 @@
4
4
  # These are the default options. The .rubocop.yml inherit and
5
5
  # override all the default options.
6
6
  # https://github.com/rubocop-hq/rubocop/blob/master/config/default.yml
7
- require:
7
+ plugins:
8
8
  - rubocop-rails
9
9
  - rubocop-performance
10
10
  - rubocop-rspec
11
11
  - rubocop-rake
12
12
  AllCops:
13
- TargetRubyVersion: 2.7.3
13
+ TargetRubyVersion: 3.4
14
14
  DisplayCopNames: true
15
15
  DisplayStyleGuide: true
16
16
  NewCops: enable
@@ -75,3 +75,18 @@ Style/SpecialGlobalVars:
75
75
 
76
76
  Style/WordArray:
77
77
  EnforcedStyle: brackets
78
+
79
+ Gemspec/DevelopmentDependencies:
80
+ Exclude:
81
+ - 'br_documents.gemspec'
82
+
83
+ Rails/DeprecatedActiveModelErrorsMethods:
84
+ Exclude:
85
+ - 'spec/**/*.rb'
86
+
87
+ Naming/PredicateMethod:
88
+ AllowedMethods:
89
+ - validate_each
90
+
91
+ RSpec/VerifiedDoubleReference:
92
+ Enabled: false
data/Gemfile.lock CHANGED
@@ -1,39 +1,64 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- br_documents (0.2.5)
4
+ br_documents (1.0.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.1.3.2)
12
- activesupport (= 6.1.3.2)
13
- activesupport (6.1.3.2)
14
- concurrent-ruby (~> 1.0, >= 1.0.2)
11
+ activemodel (8.1.2)
12
+ activesupport (= 8.1.2)
13
+ activesupport (8.1.2)
14
+ base64
15
+ bigdecimal
16
+ concurrent-ruby (~> 1.0, >= 1.3.1)
17
+ connection_pool (>= 2.2.5)
18
+ drb
15
19
  i18n (>= 1.6, < 2)
20
+ json
21
+ logger (>= 1.4.2)
16
22
  minitest (>= 5.1)
17
- tzinfo (~> 2.0)
18
- zeitwerk (~> 2.3)
19
- ast (2.4.2)
23
+ securerandom (>= 0.3)
24
+ tzinfo (~> 2.0, >= 2.0.5)
25
+ uri (>= 0.13.1)
26
+ addressable (2.8.9)
27
+ public_suffix (>= 2.0.2, < 8.0)
28
+ ast (2.4.3)
29
+ base64 (0.3.0)
30
+ bigdecimal (4.0.1)
20
31
  byebug (11.1.3)
21
- codeclimate-test-reporter (1.0.7)
22
- simplecov
23
- concurrent-ruby (1.1.9)
32
+ concurrent-ruby (1.3.6)
33
+ connection_pool (3.0.2)
24
34
  diff-lcs (1.4.4)
25
35
  docile (1.4.0)
26
- i18n (1.8.10)
36
+ drb (2.2.3)
37
+ i18n (1.14.8)
27
38
  concurrent-ruby (~> 1.0)
28
- minitest (5.14.4)
29
- parallel (1.20.1)
30
- parser (3.0.1.1)
39
+ json (2.18.1)
40
+ json-schema (6.1.0)
41
+ addressable (~> 2.8)
42
+ bigdecimal (>= 3.1, < 5)
43
+ language_server-protocol (3.17.0.5)
44
+ lint_roller (1.1.0)
45
+ logger (1.7.0)
46
+ mcp (0.7.1)
47
+ json-schema (>= 4.1)
48
+ minitest (6.0.2)
49
+ drb (~> 2.0)
50
+ prism (~> 1.5)
51
+ parallel (1.27.0)
52
+ parser (3.3.10.2)
31
53
  ast (~> 2.4.1)
32
- rack (3.0.0)
33
- rainbow (3.0.0)
34
- rake (13.0.6)
35
- regexp_parser (2.1.1)
36
- rexml (3.2.5)
54
+ racc
55
+ prism (1.9.0)
56
+ public_suffix (7.0.2)
57
+ racc (1.8.1)
58
+ rack (3.2.5)
59
+ rainbow (3.1.1)
60
+ rake (13.3.1)
61
+ regexp_parser (2.11.3)
37
62
  rspec (3.10.0)
38
63
  rspec-core (~> 3.10.0)
39
64
  rspec-expectations (~> 3.10.0)
@@ -47,40 +72,54 @@ GEM
47
72
  diff-lcs (>= 1.2.0, < 2.0)
48
73
  rspec-support (~> 3.10.0)
49
74
  rspec-support (3.10.2)
50
- rubocop (1.15.0)
75
+ rubocop (1.85.0)
76
+ json (~> 2.3)
77
+ language_server-protocol (~> 3.17.0.2)
78
+ lint_roller (~> 1.1.0)
79
+ mcp (~> 0.6)
51
80
  parallel (~> 1.10)
52
- parser (>= 3.0.0.0)
81
+ parser (>= 3.3.0.2)
53
82
  rainbow (>= 2.2.2, < 4.0)
54
- regexp_parser (>= 1.8, < 3.0)
55
- rexml
56
- rubocop-ast (>= 1.5.0, < 2.0)
83
+ regexp_parser (>= 2.9.3, < 3.0)
84
+ rubocop-ast (>= 1.49.0, < 2.0)
57
85
  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.4)
62
- rubocop (>= 1.7.0, < 2.0)
63
- rubocop-ast (>= 0.4.0)
64
- rubocop-rails (2.10.1)
86
+ unicode-display_width (>= 2.4.0, < 4.0)
87
+ rubocop-ast (1.49.0)
88
+ parser (>= 3.3.7.2)
89
+ prism (~> 1.7)
90
+ rubocop-performance (1.26.1)
91
+ lint_roller (~> 1.1)
92
+ rubocop (>= 1.75.0, < 2.0)
93
+ rubocop-ast (>= 1.47.1, < 2.0)
94
+ rubocop-rails (2.34.3)
65
95
  activesupport (>= 4.2.0)
96
+ lint_roller (~> 1.1)
66
97
  rack (>= 1.1)
67
- rubocop (>= 1.7.0, < 2.0)
68
- rubocop-rake (0.5.1)
69
- rubocop
70
- rubocop-rspec (2.3.0)
71
- rubocop (~> 1.0)
72
- rubocop-ast (>= 1.1.0)
73
- ruby-progressbar (1.11.0)
98
+ rubocop (>= 1.75.0, < 2.0)
99
+ rubocop-ast (>= 1.44.0, < 2.0)
100
+ rubocop-rake (0.7.1)
101
+ lint_roller (~> 1.1)
102
+ rubocop (>= 1.72.1)
103
+ rubocop-rspec (3.9.0)
104
+ lint_roller (~> 1.1)
105
+ rubocop (~> 1.81)
106
+ ruby-progressbar (1.13.0)
107
+ securerandom (0.4.1)
74
108
  simplecov (0.21.2)
75
109
  docile (~> 1.1)
76
110
  simplecov-html (~> 0.11)
77
111
  simplecov_json_formatter (~> 0.1)
78
112
  simplecov-html (0.12.3)
113
+ simplecov-json (0.2.3)
114
+ json
115
+ simplecov
79
116
  simplecov_json_formatter (0.1.3)
80
- tzinfo (2.0.4)
117
+ tzinfo (2.0.6)
81
118
  concurrent-ruby (~> 1.0)
82
- unicode-display_width (2.0.0)
83
- zeitwerk (2.4.2)
119
+ unicode-display_width (3.2.0)
120
+ unicode-emoji (~> 4.1)
121
+ unicode-emoji (4.2.0)
122
+ uri (1.1.1)
84
123
 
85
124
  PLATFORMS
86
125
  ruby
@@ -89,15 +128,15 @@ DEPENDENCIES
89
128
  br_documents!
90
129
  bundler (>= 1.3)
91
130
  byebug (= 11.1.3)
92
- codeclimate-test-reporter (>= 1.0.7)
93
131
  rake (>= 13.0.3)
94
132
  rspec (>= 3.10.0)
95
- rubocop (~> 1.15.0)
96
- rubocop-performance (~> 1.11.3)
97
- rubocop-rails (~> 2.10.1)
133
+ rubocop (>= 1.15.0)
134
+ rubocop-performance (>= 1.11.3)
135
+ rubocop-rails (>= 2.10.1)
98
136
  rubocop-rake (>= 0.5.1)
99
- rubocop-rspec (~> 2.3.0)
137
+ rubocop-rspec (>= 2.3.0)
100
138
  simplecov (>= 0.21.2)
139
+ simplecov-json (>= 0.2.3)
101
140
 
102
141
  BUNDLED WITH
103
- 2.2.33
142
+ 4.0.2
data/br_documents.gemspec CHANGED
@@ -8,14 +8,13 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ['ASSEINFO - Sistemas de Informação']
9
9
  spec.email = ['asseinfo@asseinfo.com.br']
10
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 '\
11
+ spec.summary = 'Validates brazilian documents like CPF, CNPJ and IE. It can be used with active record ' \
12
12
  'or just in ruby.'
13
13
  spec.homepage = 'http://github.com/asseinfo/br_documents'
14
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
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
18
  spec.require_paths = ['lib']
20
19
 
21
20
  spec.add_dependency 'activemodel', '>= 4.0.0'
@@ -23,13 +22,14 @@ Gem::Specification.new do |spec|
23
22
 
24
23
  spec.add_development_dependency 'bundler', '>= 1.3'
25
24
  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
25
  spec.add_development_dependency 'rake', '>= 13.0.3'
28
26
  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'
27
+ spec.add_development_dependency 'rubocop', '>= 1.15.0'
28
+ spec.add_development_dependency 'rubocop-performance', '>= 1.11.3'
29
+ spec.add_development_dependency 'rubocop-rails', '>= 2.10.1'
32
30
  spec.add_development_dependency 'rubocop-rake', '>= 0.5.1'
33
- spec.add_development_dependency 'rubocop-rspec', '~> 2.3.0'
31
+ spec.add_development_dependency 'rubocop-rspec', '>= 2.3.0'
34
32
  spec.add_development_dependency 'simplecov', '>= 0.21.2'
33
+ spec.add_development_dependency 'simplecov-json', '>= 0.2.3'
34
+ spec.metadata['rubygems_mfa_required'] = 'true'
35
35
  end
@@ -35,10 +35,10 @@ module BrDocuments
35
35
  def detect_range_digits
36
36
  number = number_to_calculate_digits
37
37
 
38
- if number >= 3_000_001 && number <= 3_017_000
38
+ if number.between?(3_000_001, 3_017_000)
39
39
  @p = 5
40
40
  @d = 0
41
- elsif number >= 3_017_001 && number <= 3_019_022
41
+ elsif number.between?(3_017_001, 3_019_022)
42
42
  @p = 9
43
43
  @d = 1
44
44
  elsif number >= 3_019_023
@@ -17,7 +17,7 @@ module BrDocuments
17
17
  end
18
18
 
19
19
  def valid_format?
20
- valid_8_digits_format || valid_9_digits_format
20
+ valid_8_digits_format? || valid_9_digits_format?
21
21
  end
22
22
 
23
23
  def valid_check_digit?
@@ -35,13 +35,13 @@ module BrDocuments
35
35
 
36
36
  private
37
37
 
38
- def valid_9_digits_format
38
+ def valid_9_digits_format?
39
39
  regex_mask1 = /^(\d{7}\-\d{2})$|^(\d{9})$/
40
40
  regex_mask2 = /^(\d{3}\.\d{3}\.\d{3})$|^(\d{9})$/
41
41
  regex_mask1.match(@number).present? || regex_mask2.match(@number).present?
42
42
  end
43
43
 
44
- def valid_8_digits_format
44
+ def valid_8_digits_format?
45
45
  regex = /^(\d{6}\-\d{2})$|^(\d{8})$/
46
46
  regex.match(@number).present?
47
47
  end
@@ -63,14 +63,14 @@ module BrDocuments
63
63
  end
64
64
 
65
65
  def digital_check_generator(number, weight)
66
- if use_digital_check_mod10
66
+ if use_digital_check_mod10?
67
67
  generate_check_digit_mod10(number, weight)
68
68
  else
69
69
  generate_check_digit(number, weight)
70
70
  end
71
71
  end
72
72
 
73
- def use_digital_check_mod10
73
+ def use_digital_check_mod10?
74
74
  position = position_of_the_element_to_define_module
75
75
  @number[position].to_i <= 5 || @number[position].to_i == 8
76
76
  end
@@ -8,13 +8,9 @@ module BrDocuments
8
8
  @validator = number.gsub(/[\.\/-]/, '').length <= 9 ? PE9.new(number) : PE14.new(number)
9
9
  end
10
10
 
11
- def valid?
12
- @validator.valid?
13
- end
11
+ delegate :valid?, to: :@validator
14
12
 
15
- def formatted
16
- @validator.formatted
17
- end
13
+ delegate :formatted, to: :@validator
18
14
 
19
15
  class PE14 < Pattern1
20
16
  def initialize(number)
@@ -17,26 +17,25 @@ module BrDocuments
17
17
  end
18
18
 
19
19
  def valid_format?
20
- valid_old_format or valid_new_format
20
+ valid_old_format? or valid_new_format?
21
21
  end
22
22
 
23
23
  def valid_check_digit?
24
24
  @number.gsub!(/[\.\/-]/, '')
25
25
 
26
- weight = []
27
- @number.length.downto(2).each { |w| weight << w }
26
+ weight = @number.length.downto(2).map { it }
28
27
 
29
28
  @number[-1] == generate_check_digit(@number, weight).to_s
30
29
  end
31
30
 
32
31
  private
33
32
 
34
- def valid_old_format
33
+ def valid_old_format?
35
34
  regex = /^(\d{2}\.\d{3}\.\d{3}\-\d{1})$|^(\d{9})$/
36
35
  regex.match(@number).present?
37
36
  end
38
37
 
39
- def valid_new_format
38
+ def valid_new_format?
40
39
  regex = /^(\d{2}\.\d{1}\.\d{3}\.\d{3}\-\d{1})$|^(\d{10})$/
41
40
  regex.match(@number).present?
42
41
  end
@@ -17,32 +17,32 @@ module BrDocuments
17
17
  end
18
18
 
19
19
  def valid_format?
20
- valid_old_format or valid_new_format
20
+ valid_old_format? or valid_new_format?
21
21
  end
22
22
 
23
23
  def valid_check_digit?
24
- valid_old_digital_check or valid_new_digital_check
24
+ valid_old_digital_check? or valid_new_digital_check?
25
25
  end
26
26
 
27
27
  private
28
28
 
29
- def valid_old_format
29
+ def valid_old_format?
30
30
  regex = /^(\d{3}\.\d{5}\-\d{1})$|^(\d{9})$/
31
31
  regex.match(@number).present?
32
32
  end
33
33
 
34
- def valid_new_format
34
+ def valid_new_format?
35
35
  regex = /^(\d{13}\-\d{1})$|^(\d{14})$/
36
36
  regex.match(@number).present?
37
37
  end
38
38
 
39
- def valid_old_digital_check
39
+ def valid_old_digital_check?
40
40
  weight = [3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
41
41
  remove_mask!
42
42
  @number[-1] == generate_check_digit(@number[-6, 6], weight).to_s
43
43
  end
44
44
 
45
- def valid_new_digital_check
45
+ def valid_new_digital_check?
46
46
  weight = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
47
47
  remove_mask!
48
48
  @number[-1] == generate_check_digit(@number, weight).to_s
@@ -1,4 +1,4 @@
1
- require_relative './commons/mod11'
1
+ require_relative 'commons/mod11'
2
2
 
3
3
  module BrDocuments
4
4
  class Suframa
@@ -1,3 +1,3 @@
1
1
  module BrDocuments
2
- VERSION = '0.2.5'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
data/lib/br_documents.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'active_model'
2
2
 
3
- Dir["#{File.dirname(__FILE__)}/**/*.rb"].sort.each { |f| require f }
3
+ Dir["#{File.dirname(__FILE__)}/**/*.rb"].each { |f| require f }
4
4
 
5
5
  I18n.load_path << File.expand_path('../config/locales/pt-BR.yml', __dir__)
@@ -38,6 +38,6 @@ RSpec.describe BrDocuments::IE::AC do
38
38
  end
39
39
  end
40
40
 
41
- include_examples 'for to remove all masks', '01.047.545/609-01'
41
+ it_behaves_like 'for to remove all masks', '01.047.545/609-01'
42
42
  end
43
43
  end
@@ -31,6 +31,6 @@ describe BrDocuments::IE::AL do
31
31
  end
32
32
  end
33
33
 
34
- include_examples 'for to remove all masks', '248466313'
34
+ it_behaves_like 'for to remove all masks', '248466313'
35
35
  end
36
36
  end
@@ -38,6 +38,6 @@ describe BrDocuments::IE::AM do
38
38
  end
39
39
  end
40
40
 
41
- include_examples 'for to remove all masks', '31.063.639-6'
41
+ it_behaves_like 'for to remove all masks', '31.063.639-6'
42
42
  end
43
43
  end
@@ -45,6 +45,6 @@ RSpec.describe BrDocuments::IE::AP do
45
45
  expect(ie).to be_valid
46
46
  end
47
47
 
48
- include_examples 'for to remove all masks', '030213452'
48
+ it_behaves_like 'for to remove all masks', '030213452'
49
49
  end
50
50
  end
@@ -63,7 +63,7 @@ RSpec.describe BrDocuments::IE::BA do
63
63
  end
64
64
  end
65
65
 
66
- include_examples 'for to remove all masks', '1000003-06'
67
- include_examples 'for to remove all masks', '100.000.306'
66
+ it_behaves_like 'for to remove all masks', '1000003-06'
67
+ it_behaves_like 'for to remove all masks', '100.000.306'
68
68
  end
69
69
  end
@@ -12,5 +12,5 @@ describe BrDocuments::IE::CE do
12
12
 
13
13
  it_behaves_like 'a pattern1', 'CE'
14
14
 
15
- include_examples 'for to remove all masks', '12345678-9'
15
+ it_behaves_like 'for to remove all masks', '12345678-9'
16
16
  end
@@ -38,6 +38,6 @@ describe BrDocuments::IE::DF do
38
38
  end
39
39
  end
40
40
 
41
- include_examples 'for to remove all masks', '07847481562-11'
41
+ it_behaves_like 'for to remove all masks', '07847481562-11'
42
42
  end
43
43
  end
@@ -12,5 +12,5 @@ describe BrDocuments::IE::ES do
12
12
 
13
13
  it_behaves_like 'a pattern1', 'ES'
14
14
 
15
- include_examples 'for to remove all masks', '12345678-9'
15
+ it_behaves_like 'for to remove all masks', '12345678-9'
16
16
  end
@@ -38,6 +38,6 @@ describe BrDocuments::IE::GO do
38
38
  end
39
39
  end
40
40
 
41
- include_examples 'for to remove all masks', '91.687.647-0'
41
+ it_behaves_like 'for to remove all masks', '91.687.647-0'
42
42
  end
43
43
  end
@@ -12,5 +12,5 @@ describe BrDocuments::IE::MA do
12
12
 
13
13
  it_behaves_like 'a pattern1', 'MA'
14
14
 
15
- include_examples 'for to remove all masks', '12345678-9'
15
+ it_behaves_like 'for to remove all masks', '12345678-9'
16
16
  end
@@ -38,6 +38,6 @@ RSpec.describe BrDocuments::IE::MG do
38
38
  end
39
39
  end
40
40
 
41
- include_examples 'for to remove all masks', '942.730.198/1820'
41
+ it_behaves_like 'for to remove all masks', '942.730.198/1820'
42
42
  end
43
43
  end
@@ -12,5 +12,5 @@ describe BrDocuments::IE::MS do
12
12
 
13
13
  it_behaves_like 'a pattern1', 'MS'
14
14
 
15
- include_examples 'for to remove all masks', '12345678-9'
15
+ it_behaves_like 'for to remove all masks', '12345678-9'
16
16
  end
@@ -44,6 +44,6 @@ RSpec.describe BrDocuments::IE::MT do
44
44
  end
45
45
  end
46
46
 
47
- include_examples 'for to remove all masks', '0013000001-9'
47
+ it_behaves_like 'for to remove all masks', '0013000001-9'
48
48
  end
49
49
  end
@@ -38,6 +38,6 @@ describe BrDocuments::IE::PA do
38
38
  end
39
39
  end
40
40
 
41
- include_examples 'for to remove all masks', '15-866779-4'
41
+ it_behaves_like 'for to remove all masks', '15-866779-4'
42
42
  end
43
43
  end
@@ -12,5 +12,5 @@ describe BrDocuments::IE::PB do
12
12
 
13
13
  it_behaves_like 'a pattern1', 'PB'
14
14
 
15
- include_examples 'for to remove all masks', '12345678-9'
15
+ it_behaves_like 'for to remove all masks', '12345678-9'
16
16
  end
@@ -57,6 +57,6 @@ describe BrDocuments::IE::PE do
57
57
  end
58
58
  end
59
59
 
60
- include_examples 'for to remove all masks', '18.1.001.0000004-9'
60
+ it_behaves_like 'for to remove all masks', '18.1.001.0000004-9'
61
61
  end
62
62
  end
@@ -12,5 +12,5 @@ describe BrDocuments::IE::PI do
12
12
 
13
13
  it_behaves_like 'a pattern1', 'PI'
14
14
 
15
- include_examples 'for to remove all masks', '12345678-9'
15
+ it_behaves_like 'for to remove all masks', '12345678-9'
16
16
  end
@@ -31,6 +31,6 @@ describe BrDocuments::IE::PR do
31
31
  end
32
32
  end
33
33
 
34
- include_examples 'for to remove all masks', '10163238-50'
34
+ it_behaves_like 'for to remove all masks', '10163238-50'
35
35
  end
36
36
  end
@@ -38,6 +38,6 @@ describe BrDocuments::IE::RJ do
38
38
  end
39
39
  end
40
40
 
41
- include_examples 'for to remove all masks', '31.864.95-0'
41
+ it_behaves_like 'for to remove all masks', '31.864.95-0'
42
42
  end
43
43
  end
@@ -57,6 +57,6 @@ describe BrDocuments::IE::RN do
57
57
  end
58
58
  end
59
59
 
60
- include_examples 'for to remove all masks', '20.0.040.040-0'
60
+ it_behaves_like 'for to remove all masks', '20.0.040.040-0'
61
61
  end
62
62
  end
@@ -57,6 +57,6 @@ describe BrDocuments::IE::RO do
57
57
  end
58
58
  end
59
59
 
60
- include_examples 'for to remove all masks', '0000000062521-3'
60
+ it_behaves_like 'for to remove all masks', '0000000062521-3'
61
61
  end
62
62
  end
@@ -38,6 +38,6 @@ describe BrDocuments::IE::RR do
38
38
  end
39
39
  end
40
40
 
41
- include_examples 'for to remove all masks', '24088645-6'
41
+ it_behaves_like 'for to remove all masks', '24088645-6'
42
42
  end
43
43
  end
@@ -36,6 +36,6 @@ describe BrDocuments::IE::RS do
36
36
  end
37
37
  end
38
38
 
39
- include_examples 'for to remove all masks', '034/0112115'
39
+ it_behaves_like 'for to remove all masks', '034/0112115'
40
40
  end
41
41
  end
@@ -38,6 +38,6 @@ describe BrDocuments::IE::SC do
38
38
  end
39
39
  end
40
40
 
41
- include_examples 'for to remove all masks', '254.062.407'
41
+ it_behaves_like 'for to remove all masks', '254.062.407'
42
42
  end
43
43
  end
@@ -12,5 +12,5 @@ describe BrDocuments::IE::SE do
12
12
 
13
13
  it_behaves_like 'a pattern1', 'SE'
14
14
 
15
- include_examples 'for to remove all masks', '12345678-9'
15
+ it_behaves_like 'for to remove all masks', '12345678-9'
16
16
  end
@@ -40,6 +40,6 @@ describe BrDocuments::IE::SP do
40
40
  end
41
41
  end
42
42
 
43
- include_examples 'for to remove all masks', 'P-01100424.3/002'
43
+ it_behaves_like 'for to remove all masks', 'P-01100424.3/002'
44
44
  end
45
45
  end
@@ -95,6 +95,6 @@ describe BrDocuments::IE::TO do
95
95
  end
96
96
  end
97
97
 
98
- include_examples 'for to remove all masks', '29.99.231741-7'
98
+ it_behaves_like 'for to remove all masks', '29.99.231741-7'
99
99
  end
100
100
  end
@@ -6,8 +6,7 @@ RSpec.describe IeValidator do
6
6
  let(:record) { instance_double('model') }
7
7
 
8
8
  before do
9
- allow(record).to receive(:uf).and_return('SC')
10
- allow(record).to receive(:errors).and_return({})
9
+ allow(record).to receive_messages(uf: 'SC', errors: {})
11
10
  allow(record.errors).to receive(:messages).and_return({})
12
11
  allow(record.errors).to receive(:add) do |attribute, error|
13
12
  record.errors[attribute] ||= []
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe SuframaValidator do
4
4
  subject { described_class.new(attributes: 'suframa') }
5
5
 
6
- let(:mock) { instance_double('mode') }
6
+ let(:mock) { instance_double('model') }
7
7
 
8
8
  before do
9
9
  allow(mock).to receive(:errors).and_return([])
data/spec/spec_helper.rb CHANGED
@@ -1,12 +1,19 @@
1
1
  require 'simplecov'
2
- SimpleCov.start unless ENV['NO_COVERAGE']
2
+ require 'simplecov-json'
3
+
4
+ unless ENV['NO_COVERAGE']
5
+ SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(
6
+ [SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::JSONFormatter]
7
+ )
8
+ SimpleCov.start
9
+ end
3
10
 
4
11
  require 'bundler/setup'
5
12
  Bundler.require(:default, :development)
6
13
 
7
14
  require 'br_documents'
8
15
 
9
- Dir["#{File.dirname(__FILE__)}/support/*.rb"].sort.each { |f| require f }
16
+ Dir["#{File.dirname(__FILE__)}/support/*.rb"].each { |f| require f }
10
17
 
11
18
  I18n.default_locale = 'pt-BR'
12
19
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: br_documents
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ASSEINFO - Sistemas de Informação
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-11-11 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activemodel
@@ -66,20 +65,6 @@ dependencies:
66
65
  - - '='
67
66
  - !ruby/object:Gem::Version
68
67
  version: 11.1.3
69
- - !ruby/object:Gem::Dependency
70
- name: codeclimate-test-reporter
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: 1.0.7
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: 1.0.7
83
68
  - !ruby/object:Gem::Dependency
84
69
  name: rake
85
70
  requirement: !ruby/object:Gem::Requirement
@@ -112,42 +97,42 @@ dependencies:
112
97
  name: rubocop
113
98
  requirement: !ruby/object:Gem::Requirement
114
99
  requirements:
115
- - - "~>"
100
+ - - ">="
116
101
  - !ruby/object:Gem::Version
117
102
  version: 1.15.0
118
103
  type: :development
119
104
  prerelease: false
120
105
  version_requirements: !ruby/object:Gem::Requirement
121
106
  requirements:
122
- - - "~>"
107
+ - - ">="
123
108
  - !ruby/object:Gem::Version
124
109
  version: 1.15.0
125
110
  - !ruby/object:Gem::Dependency
126
111
  name: rubocop-performance
127
112
  requirement: !ruby/object:Gem::Requirement
128
113
  requirements:
129
- - - "~>"
114
+ - - ">="
130
115
  - !ruby/object:Gem::Version
131
116
  version: 1.11.3
132
117
  type: :development
133
118
  prerelease: false
134
119
  version_requirements: !ruby/object:Gem::Requirement
135
120
  requirements:
136
- - - "~>"
121
+ - - ">="
137
122
  - !ruby/object:Gem::Version
138
123
  version: 1.11.3
139
124
  - !ruby/object:Gem::Dependency
140
125
  name: rubocop-rails
141
126
  requirement: !ruby/object:Gem::Requirement
142
127
  requirements:
143
- - - "~>"
128
+ - - ">="
144
129
  - !ruby/object:Gem::Version
145
130
  version: 2.10.1
146
131
  type: :development
147
132
  prerelease: false
148
133
  version_requirements: !ruby/object:Gem::Requirement
149
134
  requirements:
150
- - - "~>"
135
+ - - ">="
151
136
  - !ruby/object:Gem::Version
152
137
  version: 2.10.1
153
138
  - !ruby/object:Gem::Dependency
@@ -168,14 +153,14 @@ dependencies:
168
153
  name: rubocop-rspec
169
154
  requirement: !ruby/object:Gem::Requirement
170
155
  requirements:
171
- - - "~>"
156
+ - - ">="
172
157
  - !ruby/object:Gem::Version
173
158
  version: 2.3.0
174
159
  type: :development
175
160
  prerelease: false
176
161
  version_requirements: !ruby/object:Gem::Requirement
177
162
  requirements:
178
- - - "~>"
163
+ - - ">="
179
164
  - !ruby/object:Gem::Version
180
165
  version: 2.3.0
181
166
  - !ruby/object:Gem::Dependency
@@ -192,6 +177,20 @@ dependencies:
192
177
  - - ">="
193
178
  - !ruby/object:Gem::Version
194
179
  version: 0.21.2
180
+ - !ruby/object:Gem::Dependency
181
+ name: simplecov-json
182
+ requirement: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: 0.2.3
187
+ type: :development
188
+ prerelease: false
189
+ version_requirements: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: 0.2.3
195
194
  description: Validates brazilian documents like CPF, CNPJ and IE.
196
195
  email:
197
196
  - asseinfo@asseinfo.com.br
@@ -298,8 +297,8 @@ files:
298
297
  homepage: http://github.com/asseinfo/br_documents
299
298
  licenses:
300
299
  - MIT
301
- metadata: {}
302
- post_install_message:
300
+ metadata:
301
+ rubygems_mfa_required: 'true'
303
302
  rdoc_options: []
304
303
  require_paths:
305
304
  - lib
@@ -314,49 +313,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
314
313
  - !ruby/object:Gem::Version
315
314
  version: '0'
316
315
  requirements: []
317
- rubygems_version: 3.2.33
318
- signing_key:
316
+ rubygems_version: 3.6.9
319
317
  specification_version: 4
320
318
  summary: Validates brazilian documents like CPF, CNPJ and IE. It can be used with
321
319
  active record or just in ruby.
322
- test_files:
323
- - spec/br_documents/cnpj_cpf/cnpj_spec.rb
324
- - spec/br_documents/cnpj_cpf/cpf_spec.rb
325
- - spec/br_documents/cnpj_validator_spec.rb
326
- - spec/br_documents/cpf_validator_spec.rb
327
- - spec/br_documents/gtin_spec.rb
328
- - spec/br_documents/gtin_validator_spec.rb
329
- - spec/br_documents/ie/ac_spec.rb
330
- - spec/br_documents/ie/al_spec.rb
331
- - spec/br_documents/ie/am_spec.rb
332
- - spec/br_documents/ie/ap_spec.rb
333
- - spec/br_documents/ie/ba_spec.rb
334
- - spec/br_documents/ie/ce_spec.rb
335
- - spec/br_documents/ie/df_spec.rb
336
- - spec/br_documents/ie/es_spec.rb
337
- - spec/br_documents/ie/factory_spec.rb
338
- - spec/br_documents/ie/go_spec.rb
339
- - spec/br_documents/ie/ma_spec.rb
340
- - spec/br_documents/ie/mg_spec.rb
341
- - spec/br_documents/ie/ms_spec.rb
342
- - spec/br_documents/ie/mt_spec.rb
343
- - spec/br_documents/ie/pa_spec.rb
344
- - spec/br_documents/ie/pb_spec.rb
345
- - spec/br_documents/ie/pe_spec.rb
346
- - spec/br_documents/ie/pi_spec.rb
347
- - spec/br_documents/ie/pr_spec.rb
348
- - spec/br_documents/ie/rj_spec.rb
349
- - spec/br_documents/ie/rn_spec.rb
350
- - spec/br_documents/ie/ro_spec.rb
351
- - spec/br_documents/ie/rr_spec.rb
352
- - spec/br_documents/ie/rs_spec.rb
353
- - spec/br_documents/ie/sc_spec.rb
354
- - spec/br_documents/ie/se_spec.rb
355
- - spec/br_documents/ie/shared_examples_for_pattern1.rb
356
- - spec/br_documents/ie/shared_examples_for_to_remove_all_masks.rb
357
- - spec/br_documents/ie/sp_spec.rb
358
- - spec/br_documents/ie/to_spec.rb
359
- - spec/br_documents/ie_validator_spec.rb
360
- - spec/br_documents/suframa_spec.rb
361
- - spec/br_documents/suframa_validator_spec.rb
362
- - spec/spec_helper.rb
320
+ test_files: []