br_documents 0.2.3 → 0.2.4

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
  SHA256:
3
- metadata.gz: a893a246eb1c07b45241c0eec46268a58a01aa7e2bbb0f02f8294e3c1f6c0ccf
4
- data.tar.gz: 8ad80b4d402567412752ed48eab9c0adec82fa6d92cf8dcf6bfbf788e72e8a6b
3
+ metadata.gz: c47ea3ab192fe4d301ccd704cabc9f431d7704f007d70b66d4d76c1013b947b0
4
+ data.tar.gz: ff5e539d6d9b69ff58b9a92e4fac158367ca720c225aca0f28f08be41de48e8f
5
5
  SHA512:
6
- metadata.gz: 43d5217a448c6ed1297084b59c4935021a0bfda1968be33b109985cd169ea80b435adaec30373ba84b3125828842e7cce71033e3f7d842db3af0610f2c0e87d0
7
- data.tar.gz: 63538e8845f2143637a685af12b944cc37c2b5ecb34fc32f3eb67c859cbd28968daaadac4669146322794e2029a0a0034c9fbdf94a90dcf887a309e125ca4e7d
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: "-"
@@ -12,7 +12,7 @@ jobs:
12
12
 
13
13
  - uses: ruby/setup-ruby@v1
14
14
  with:
15
- ruby-version: 2.7.3
15
+ ruby-version: 3.0.4
16
16
  bundler-cache: true
17
17
 
18
18
  - run: bundle exec rubocop --display-cop-names --parallel
@@ -25,7 +25,7 @@ jobs:
25
25
 
26
26
  - uses: ruby/setup-ruby@v1
27
27
  with:
28
- ruby-version: 2.7.3
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- br_documents (0.2.3)
4
+ br_documents (0.2.4)
5
5
  activemodel (>= 4.0.0)
6
6
  i18n (>= 0.6.5)
7
7
 
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
- $ bundle exec rake release # Create tag vX.X.X, build and push br_documents-X.X.X.gem to Rubygems
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module BrDocuments
2
- VERSION = '0.2.3'.freeze
2
+ VERSION = '0.2.4'.freeze
3
3
  end
@@ -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
- ['1234567', '123456789012'].each do |number|
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
- ['030123459', '030183458', '030213452', '030213460'].each do |number|
29
- ie = described_class.new(number)
30
- expect(ie).to be_valid
31
- end
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
@@ -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
@@ -1,5 +1,5 @@
1
1
  require 'simplecov'
2
- SimpleCov.start
2
+ SimpleCov.start unless ENV['NO_COVERAGE']
3
3
 
4
4
  require 'bundler/setup'
5
5
  Bundler.require(:default, :development)
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.3
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-08-25 00:00:00.000000000 Z
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.1.6
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
@@ -1,3 +0,0 @@
1
- def t(string, options = {})
2
- I18n.t(string, options)
3
- end