br_documents 0.2.2 → 0.2.4
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.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +16 -0
- data/.github/workflows/config.yml +4 -4
- data/.rubocop.yml +4 -0
- data/Gemfile.lock +2 -2
- data/README.md +6 -1
- data/br_documents.gemspec +0 -2
- data/lib/br_documents/ie/ap.rb +6 -0
- data/lib/br_documents/ie/mg.rb +1 -1
- data/lib/br_documents/version.rb +1 -1
- data/spec/br_documents/ie/ap_spec.rb +13 -6
- data/spec/br_documents/ie/factory_spec.rb +1 -1
- data/spec/br_documents/ie/mg_spec.rb +3 -3
- data/spec/br_documents/ie_validator_spec.rb +3 -7
- data/spec/spec_helper.rb +1 -1
- metadata +4 -6
- data/.tool-versions +0 -1
- data/spec/support/utilities.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c47ea3ab192fe4d301ccd704cabc9f431d7704f007d70b66d4d76c1013b947b0
|
4
|
+
data.tar.gz: ff5e539d6d9b69ff58b9a92e4fac158367ca720c225aca0f28f08be41de48e8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59a2c4bc0ffbd277d1b71db6c6eeb465b2a4f81893e8d78ee42e0fbbf38590083558b1e250592a6508a7e78502431cdbd4f8b13b1d3acb0d0b92e9b4ab4b05b3
|
7
|
+
data.tar.gz: d08b9dd1428f39a50537957b99fb04b0866d81d93329ba61a8dab6c43c4c9ae063bd5976f20370a2323afa7a426143e4c1eb9b14b6e1904b355c952bba650fbc
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
3
|
+
# Please see the documentation for all configuration options:
|
4
|
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
5
|
+
|
6
|
+
version: 2
|
7
|
+
updates:
|
8
|
+
- package-ecosystem: "" # See documentation for possible values
|
9
|
+
directory: "/" # Location of package manifests
|
10
|
+
schedule:
|
11
|
+
interval: "monthly"
|
12
|
+
open-pull-requests-limit: 10
|
13
|
+
allow:
|
14
|
+
- dependency-type: "direct"
|
15
|
+
pull-request-branch-name:
|
16
|
+
separator: "-"
|
@@ -8,11 +8,11 @@ jobs:
|
|
8
8
|
|
9
9
|
steps:
|
10
10
|
|
11
|
-
- uses: actions/checkout@
|
11
|
+
- uses: actions/checkout@v3
|
12
12
|
|
13
13
|
- uses: ruby/setup-ruby@v1
|
14
14
|
with:
|
15
|
-
ruby-version:
|
15
|
+
ruby-version: 3.0.4
|
16
16
|
bundler-cache: true
|
17
17
|
|
18
18
|
- run: bundle exec rubocop --display-cop-names --parallel
|
@@ -21,11 +21,11 @@ jobs:
|
|
21
21
|
runs-on: ubuntu-latest
|
22
22
|
|
23
23
|
steps:
|
24
|
-
- uses: actions/checkout@
|
24
|
+
- uses: actions/checkout@v3
|
25
25
|
|
26
26
|
- uses: ruby/setup-ruby@v1
|
27
27
|
with:
|
28
|
-
ruby-version:
|
28
|
+
ruby-version: 3.0.4
|
29
29
|
bundler-cache: true
|
30
30
|
|
31
31
|
- run: |
|
data/.rubocop.yml
CHANGED
@@ -37,6 +37,7 @@ Metrics/AbcSize:
|
|
37
37
|
Metrics/BlockLength:
|
38
38
|
Exclude:
|
39
39
|
- 'spec/**/*.rb'
|
40
|
+
- 'br_documents.gemspec'
|
40
41
|
|
41
42
|
Style/Documentation:
|
42
43
|
Enabled: false
|
@@ -50,6 +51,9 @@ RSpec/MultipleExpectations:
|
|
50
51
|
RSpec/NestedGroups:
|
51
52
|
Enabled: false # default: true
|
52
53
|
|
54
|
+
RSpec/ExampleLength:
|
55
|
+
Enabled: false # default: true
|
56
|
+
|
53
57
|
Style/RegexpLiteral:
|
54
58
|
Enabled: false # default: true
|
55
59
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -193,7 +193,12 @@ RAILS_ENV | no | no | yes | no | test
|
|
193
193
|
|
194
194
|
## Deploy to Rubygems
|
195
195
|
|
196
|
-
|
196
|
+
1. Increment the version `lib/br_documents/version.rb` and commit
|
197
|
+
2. Run
|
198
|
+
|
199
|
+
```
|
200
|
+
$ bundle exec rake release # Create tag vX.X.X, build and push br_documents-X.X.X.gem to Rubygems
|
201
|
+
```
|
197
202
|
|
198
203
|
You can build or install using one of the above tasks
|
199
204
|
|
data/br_documents.gemspec
CHANGED
@@ -2,7 +2,6 @@ lib = File.expand_path('lib', __dir__)
|
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
require 'br_documents/version'
|
4
4
|
|
5
|
-
# rubocop:disable Metrics/BlockLength
|
6
5
|
Gem::Specification.new do |spec|
|
7
6
|
spec.name = 'br_documents'
|
8
7
|
spec.version = BrDocuments::VERSION
|
@@ -34,4 +33,3 @@ Gem::Specification.new do |spec|
|
|
34
33
|
spec.add_development_dependency 'rubocop-rspec', '~> 2.3.0'
|
35
34
|
spec.add_development_dependency 'simplecov', '>= 0.21.2'
|
36
35
|
end
|
37
|
-
# rubocop:enable Metrics/BlockLength
|
data/lib/br_documents/ie/ap.rb
CHANGED
@@ -6,6 +6,10 @@ module BrDocuments
|
|
6
6
|
class AP < Base
|
7
7
|
include Commons::Mod11
|
8
8
|
|
9
|
+
def valid?
|
10
|
+
@number.to_s.size == 9 && super
|
11
|
+
end
|
12
|
+
|
9
13
|
protected
|
10
14
|
|
11
15
|
def format_ie(number)
|
@@ -18,6 +22,8 @@ module BrDocuments
|
|
18
22
|
end
|
19
23
|
|
20
24
|
def valid_check_digit?
|
25
|
+
return false if @number.to_i.zero?
|
26
|
+
|
21
27
|
weight = [9, 8, 7, 6, 5, 4, 3, 2]
|
22
28
|
detect_range_digits
|
23
29
|
@number[-1] == generate_check_digit(@number, weight).to_s
|
data/lib/br_documents/ie/mg.rb
CHANGED
data/lib/br_documents/version.rb
CHANGED
@@ -11,24 +11,31 @@ RSpec.describe BrDocuments::IE::AP do
|
|
11
11
|
|
12
12
|
describe '#valid?' do
|
13
13
|
it 'is invalid with length different to 9' do
|
14
|
-
['
|
14
|
+
['12345678', '1234567890'].each do |number|
|
15
15
|
ie = described_class.new(number)
|
16
16
|
expect(ie).not_to be_valid
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'is invalid with invalid check number' do
|
21
|
-
['030123456', '030182454'].each do |number|
|
21
|
+
['030123456', '030182454', '000000000'].each do |number|
|
22
22
|
ie = described_class.new(number)
|
23
23
|
expect(ie).not_to be_valid
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'is valid with valid number' do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
first_range_number = '030123459'
|
29
|
+
ie = described_class.new(first_range_number)
|
30
|
+
expect(ie).to be_valid
|
31
|
+
|
32
|
+
second_range_number = '030183458'
|
33
|
+
ie = described_class.new(second_range_number)
|
34
|
+
expect(ie).to be_valid
|
35
|
+
|
36
|
+
third_range_number = '030192455'
|
37
|
+
ie = described_class.new(third_range_number)
|
38
|
+
expect(ie).to be_valid
|
32
39
|
end
|
33
40
|
|
34
41
|
include_examples 'for to remove all masks', '030213452'
|
@@ -195,7 +195,7 @@ describe BrDocuments::IE::Factory do
|
|
195
195
|
it 'is returns an error' do
|
196
196
|
expect do
|
197
197
|
described_class.create('', '')
|
198
|
-
end.to raise_error(ArgumentError, t('validator.ie.uf.invalid'))
|
198
|
+
end.to raise_error(ArgumentError, I18n.t('validator.ie.uf.invalid'))
|
199
199
|
end
|
200
200
|
end
|
201
201
|
end
|
@@ -11,7 +11,7 @@ RSpec.describe BrDocuments::IE::MG do
|
|
11
11
|
|
12
12
|
describe '#valid?' do
|
13
13
|
it 'is invalid with malformed number' do
|
14
|
-
['
|
14
|
+
['363.112.657.12-75', '4.168.836.973-423', '560.139.778.87-12'].each do |number|
|
15
15
|
ie = described_class.new(number)
|
16
16
|
expect(ie).not_to be_valid
|
17
17
|
end
|
@@ -32,12 +32,12 @@ RSpec.describe BrDocuments::IE::MG do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'is valid with valid number' do
|
35
|
-
['4193434759899', '9427301981820'].each do |number|
|
35
|
+
['4193434759899', '9427301981820', '0043982240026'].each do |number|
|
36
36
|
ie = described_class.new(number)
|
37
37
|
expect(ie).to be_valid
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
include_examples 'for to remove all masks', '942.730.198
|
41
|
+
include_examples 'for to remove all masks', '942.730.198/1820'
|
42
42
|
end
|
43
43
|
end
|
@@ -55,7 +55,7 @@ RSpec.describe IeValidator do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'adds error in model' do
|
58
|
-
expect(record.errors.messages['ie']).to include t('validator.ie.uf.invalid')
|
58
|
+
expect(record.errors.messages['ie']).to include I18n.t('validator.ie.uf.invalid')
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -66,9 +66,7 @@ RSpec.describe IeValidator do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'adds error in model' do
|
69
|
-
expect(record.errors.messages[:base]).to eql [
|
70
|
-
t('validator.ie.uf.no_present', uf: 'uf')
|
71
|
-
]
|
69
|
+
expect(record.errors.messages[:base]).to eql [I18n.t('validator.ie.uf.no_present', uf: 'uf')]
|
72
70
|
end
|
73
71
|
end
|
74
72
|
|
@@ -78,9 +76,7 @@ RSpec.describe IeValidator do
|
|
78
76
|
before { subject.validate_each(record, 'ie', '253667852') }
|
79
77
|
|
80
78
|
it 'adds error in model' do
|
81
|
-
expect(record.errors.messages[:base]).to eql [
|
82
|
-
t('validator.ie.uf.no_configured')
|
83
|
-
]
|
79
|
+
expect(record.errors.messages[:base]).to eql [I18n.t('validator.ie.uf.no_configured')]
|
84
80
|
end
|
85
81
|
end
|
86
82
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: br_documents
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ASSEINFO - Sistemas de Informação
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -199,11 +199,11 @@ executables: []
|
|
199
199
|
extensions: []
|
200
200
|
extra_rdoc_files: []
|
201
201
|
files:
|
202
|
+
- ".github/dependabot.yml"
|
202
203
|
- ".github/workflows/config.yml"
|
203
204
|
- ".gitignore"
|
204
205
|
- ".rspec"
|
205
206
|
- ".rubocop.yml"
|
206
|
-
- ".tool-versions"
|
207
207
|
- Gemfile
|
208
208
|
- Gemfile.lock
|
209
209
|
- README.md
|
@@ -295,7 +295,6 @@ files:
|
|
295
295
|
- spec/br_documents/suframa_spec.rb
|
296
296
|
- spec/br_documents/suframa_validator_spec.rb
|
297
297
|
- spec/spec_helper.rb
|
298
|
-
- spec/support/utilities.rb
|
299
298
|
homepage: http://github.com/asseinfo/br_documents
|
300
299
|
licenses:
|
301
300
|
- MIT
|
@@ -315,7 +314,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
315
314
|
- !ruby/object:Gem::Version
|
316
315
|
version: '0'
|
317
316
|
requirements: []
|
318
|
-
rubygems_version: 3.
|
317
|
+
rubygems_version: 3.2.33
|
319
318
|
signing_key:
|
320
319
|
specification_version: 4
|
321
320
|
summary: Validates brazilian documents like CPF, CNPJ and IE. It can be used with
|
@@ -361,4 +360,3 @@ test_files:
|
|
361
360
|
- spec/br_documents/suframa_spec.rb
|
362
361
|
- spec/br_documents/suframa_validator_spec.rb
|
363
362
|
- spec/spec_helper.rb
|
364
|
-
- spec/support/utilities.rb
|
data/.tool-versions
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ruby 2.7.4
|
data/spec/support/utilities.rb
DELETED