br_documents 0.2.4 → 0.2.5

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: c47ea3ab192fe4d301ccd704cabc9f431d7704f007d70b66d4d76c1013b947b0
4
- data.tar.gz: ff5e539d6d9b69ff58b9a92e4fac158367ca720c225aca0f28f08be41de48e8f
3
+ metadata.gz: 91d2ac26c3f7fa33806675aa10ca8d08b6d276983724e373a872ab5540ea369c
4
+ data.tar.gz: 2ce24db58349653730f9338e16bda7b96459bb3670f21fb7383dbf9e6ce498be
5
5
  SHA512:
6
- metadata.gz: 59a2c4bc0ffbd277d1b71db6c6eeb465b2a4f81893e8d78ee42e0fbbf38590083558b1e250592a6508a7e78502431cdbd4f8b13b1d3acb0d0b92e9b4ab4b05b3
7
- data.tar.gz: d08b9dd1428f39a50537957b99fb04b0866d81d93329ba61a8dab6c43c4c9ae063bd5976f20370a2323afa7a426143e4c1eb9b14b6e1904b355c952bba650fbc
6
+ metadata.gz: 7f2a2eedad3ce0394be82a13f019f0236044992e9e87f63a933889e99ff9e282a8b3c6e561520c22de4e6e3311b88fa7772b89c94e8955baf564683a0190e44a
7
+ data.tar.gz: c03ce1f4d3c38ccf37b11a8ae725f0b7478fe9aae4124c7c2cb84d116d93878d2de451146f854e6e191406ec8a6e1ab63295013366a89d775c68bfa24a149669
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- br_documents (0.2.4)
4
+ br_documents (0.2.5)
5
5
  activemodel (>= 4.0.0)
6
6
  i18n (>= 0.6.5)
7
7
 
@@ -29,7 +29,7 @@ GEM
29
29
  parallel (1.20.1)
30
30
  parser (3.0.1.1)
31
31
  ast (~> 2.4.1)
32
- rack (2.2.3)
32
+ rack (3.0.0)
33
33
  rainbow (3.0.0)
34
34
  rake (13.0.6)
35
35
  regexp_parser (2.1.1)
@@ -22,7 +22,7 @@ module BrDocuments
22
22
  end
23
23
 
24
24
  def valid_check_digit?
25
- return false if @number.to_i.zero?
25
+ return false if number_to_calculate_digits < 3_000_001
26
26
 
27
27
  weight = [9, 8, 7, 6, 5, 4, 3, 2]
28
28
  detect_range_digits
@@ -33,7 +33,7 @@ module BrDocuments
33
33
 
34
34
  # rubocop:disable Metrics/MethodLength
35
35
  def detect_range_digits
36
- number = @number[0, 8].to_i
36
+ number = number_to_calculate_digits
37
37
 
38
38
  if number >= 3_000_001 && number <= 3_017_000
39
39
  @p = 5
@@ -48,6 +48,10 @@ module BrDocuments
48
48
  end
49
49
  # rubocop:enable Metrics/MethodLength
50
50
 
51
+ def number_to_calculate_digits
52
+ @number[0, 8].to_i
53
+ end
54
+
51
55
  def generate_check_digit(values, weights)
52
56
  sum = reduce_weights(values, weights)
53
57
  sum += @p
@@ -1,3 +1,3 @@
1
1
  module BrDocuments
2
- VERSION = '0.2.4'.freeze
2
+ VERSION = '0.2.5'.freeze
3
3
  end
@@ -18,22 +18,29 @@ RSpec.describe BrDocuments::IE::AP do
18
18
  end
19
19
 
20
20
  it 'is invalid with invalid check number' do
21
- ['030123456', '030182454', '000000000'].each do |number|
21
+ ['030123456', '030182454'].each do |number|
22
+ ie = described_class.new(number)
23
+ expect(ie).not_to be_valid
24
+ end
25
+ end
26
+
27
+ it 'is invalid if the number is less than 3_000_001' do
28
+ ['030000000', '000000000'].each do |number|
22
29
  ie = described_class.new(number)
23
30
  expect(ie).not_to be_valid
24
31
  end
25
32
  end
26
33
 
27
34
  it 'is valid with valid number' do
28
- first_range_number = '030123459'
35
+ first_range_number = '030000012'
29
36
  ie = described_class.new(first_range_number)
30
37
  expect(ie).to be_valid
31
38
 
32
- second_range_number = '030183458'
39
+ second_range_number = '030170011'
33
40
  ie = described_class.new(second_range_number)
34
41
  expect(ie).to be_valid
35
42
 
36
- third_range_number = '030192455'
43
+ third_range_number = '030190231'
37
44
  ie = described_class.new(third_range_number)
38
45
  expect(ie).to be_valid
39
46
  end
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
4
+ version: 0.2.5
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-10 00:00:00.000000000 Z
11
+ date: 2022-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel