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 +4 -4
- data/Gemfile.lock +2 -2
- data/lib/br_documents/ie/ap.rb +6 -2
- data/lib/br_documents/version.rb +1 -1
- data/spec/br_documents/ie/ap_spec.rb +11 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91d2ac26c3f7fa33806675aa10ca8d08b6d276983724e373a872ab5540ea369c
|
4
|
+
data.tar.gz: 2ce24db58349653730f9338e16bda7b96459bb3670f21fb7383dbf9e6ce498be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
+
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 (
|
32
|
+
rack (3.0.0)
|
33
33
|
rainbow (3.0.0)
|
34
34
|
rake (13.0.6)
|
35
35
|
regexp_parser (2.1.1)
|
data/lib/br_documents/ie/ap.rb
CHANGED
@@ -22,7 +22,7 @@ module BrDocuments
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def valid_check_digit?
|
25
|
-
return false if
|
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 =
|
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
|
data/lib/br_documents/version.rb
CHANGED
@@ -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'
|
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 = '
|
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 = '
|
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 = '
|
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
|
+
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-
|
11
|
+
date: 2022-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|