br_documents 0.0.15 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/config.yml +54 -0
- data/.gitignore +1 -1
- data/.rubocop.yml +65 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +100 -0
- data/README.md +58 -1
- data/Rakefile +3 -3
- data/br_documents.gemspec +23 -19
- data/lib/br_documents.rb +3 -3
- data/lib/br_documents/cnpj_cpf/cnpj.rb +2 -2
- data/lib/br_documents/cnpj_cpf/cpf.rb +2 -2
- data/lib/br_documents/cnpj_cpf/document.rb +9 -9
- data/lib/br_documents/cnpj_validator.rb +4 -4
- data/lib/br_documents/commons/mod11.rb +1 -2
- data/lib/br_documents/commons/mod14.rb +20 -0
- data/lib/br_documents/cpf_validator.rb +4 -4
- data/lib/br_documents/gtin/gtin.rb +28 -0
- data/lib/br_documents/gtin_validator.rb +8 -0
- data/lib/br_documents/ie/ac.rb +3 -2
- data/lib/br_documents/ie/al.rb +2 -1
- data/lib/br_documents/ie/am.rb +3 -2
- data/lib/br_documents/ie/ap.rb +20 -16
- data/lib/br_documents/ie/ba.rb +28 -25
- data/lib/br_documents/ie/base.rb +1 -1
- data/lib/br_documents/ie/ce.rb +3 -2
- data/lib/br_documents/ie/df.rb +3 -2
- data/lib/br_documents/ie/es.rb +2 -1
- data/lib/br_documents/ie/factory.rb +3 -3
- data/lib/br_documents/ie/go.rb +3 -2
- data/lib/br_documents/ie/ma.rb +2 -1
- data/lib/br_documents/ie/mg.rb +14 -17
- data/lib/br_documents/ie/ms.rb +2 -1
- data/lib/br_documents/ie/mt.rb +6 -5
- data/lib/br_documents/ie/pa.rb +3 -2
- data/lib/br_documents/ie/pattern1.rb +10 -7
- data/lib/br_documents/ie/pattern2.rb +9 -8
- data/lib/br_documents/ie/pb.rb +3 -2
- data/lib/br_documents/ie/pe.rb +10 -10
- data/lib/br_documents/ie/pi.rb +2 -1
- data/lib/br_documents/ie/pr.rb +3 -2
- data/lib/br_documents/ie/rj.rb +3 -2
- data/lib/br_documents/ie/rn.rb +19 -16
- data/lib/br_documents/ie/ro.rb +17 -14
- data/lib/br_documents/ie/rr.rb +4 -3
- data/lib/br_documents/ie/rs.rb +3 -2
- data/lib/br_documents/ie/sc.rb +3 -2
- data/lib/br_documents/ie/se.rb +3 -2
- data/lib/br_documents/ie/sp.rb +17 -14
- data/lib/br_documents/ie/to.rb +6 -5
- data/lib/br_documents/ie_validator.rb +16 -15
- data/lib/br_documents/suframa/suframa.rb +60 -0
- data/lib/br_documents/suframa_validator.rb +8 -0
- data/lib/br_documents/version.rb +1 -1
- data/spec/cnpj_cpf/cnpj_spec.rb +21 -21
- data/spec/cnpj_cpf/cpf_spec.rb +21 -21
- data/spec/cnpj_validator_spec.rb +12 -12
- data/spec/cpf_validator_spec.rb +12 -12
- data/spec/gtin/gtin_spec.rb +49 -0
- data/spec/gtin_validator_spec.rb +47 -0
- data/spec/ie/ac_spec.rb +16 -16
- data/spec/ie/al_spec.rb +14 -14
- data/spec/ie/am_spec.rb +16 -16
- data/spec/ie/ap_spec.rb +14 -14
- data/spec/ie/ba_spec.rb +28 -28
- data/spec/ie/ce_spec.rb +9 -9
- data/spec/ie/df_spec.rb +16 -16
- data/spec/ie/es_spec.rb +9 -9
- data/spec/ie/factory_spec.rb +88 -89
- data/spec/ie/go_spec.rb +16 -16
- data/spec/ie/ma_spec.rb +9 -9
- data/spec/ie/mg_spec.rb +16 -16
- data/spec/ie/ms_spec.rb +9 -9
- data/spec/ie/mt_spec.rb +17 -17
- data/spec/ie/pa_spec.rb +16 -16
- data/spec/ie/pb_spec.rb +9 -9
- data/spec/ie/pe_spec.rb +27 -27
- data/spec/ie/pi_spec.rb +9 -9
- data/spec/ie/pr_spec.rb +14 -14
- data/spec/ie/rj_spec.rb +16 -16
- data/spec/ie/rn_spec.rb +27 -27
- data/spec/ie/ro_spec.rb +27 -27
- data/spec/ie/rr_spec.rb +16 -16
- data/spec/ie/rs_spec.rb +16 -16
- data/spec/ie/sc_spec.rb +16 -16
- data/spec/ie/se_spec.rb +9 -9
- data/spec/ie/shared_examples_for_pattern1.rb +11 -11
- data/spec/ie/shared_examples_for_to_remove_all_masks.rb +7 -8
- data/spec/ie/sp_spec.rb +19 -19
- data/spec/ie/to_spec.rb +35 -35
- data/spec/ie_validator_spec.rb +43 -31
- data/spec/spec_helper.rb +9 -6
- data/spec/suframa/suframa_spec.rb +109 -0
- data/spec/suframa_validator_spec.rb +36 -0
- data/spec/support/utilities.rb +2 -2
- metadata +94 -25
- data/.travis.yml +0 -6
- data/circle.yml +0 -3
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SuframaValidator do
|
4
|
+
let(:mock) { double('mode') }
|
5
|
+
|
6
|
+
before do
|
7
|
+
allow(mock).to receive(:errors).and_return([])
|
8
|
+
allow(mock.errors).to receive(:messages).and_return({})
|
9
|
+
allow(mock.errors).to receive(:add) do |attribute, error|
|
10
|
+
mock.errors.messages[attribute] = [error]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
subject { SuframaValidator.new(attributes: 'suframa') }
|
15
|
+
|
16
|
+
context 'when SUFRAMA is valid' do
|
17
|
+
it "doesn't add errors in model" do
|
18
|
+
subject.validate_each(mock, 'suframa', '600215105')
|
19
|
+
expect(mock.errors.messages).to be_empty
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when SUFRAMA is blank' do
|
24
|
+
it "doesn't add errors in model" do
|
25
|
+
subject.validate_each(mock, 'suframa', '')
|
26
|
+
expect(mock.errors.messages).to be_empty
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when SUFRAMA is invalid' do
|
31
|
+
it 'adds errors in model' do
|
32
|
+
subject.validate_each(mock, 'suframa', '01233254121')
|
33
|
+
expect(mock.errors.messages).to_not be_empty
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/support/utilities.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
def t(string, options={})
|
1
|
+
def t(string, options = {})
|
2
2
|
I18n.t(string, options)
|
3
|
-
end
|
3
|
+
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.0
|
4
|
+
version: 0.2.0
|
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:
|
11
|
+
date: 2021-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -53,75 +53,131 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: byebug
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 11.1.3
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 11.1.3
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: codeclimate-test-reporter
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 1.0.7
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 1.0.7
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 13.0.3
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 13.0.3
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 3.10.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 3.10.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: rubocop
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 1.15.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.15.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop-performance
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.11.3
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.11.3
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rubocop-rails
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 2.10.1
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 2.10.1
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop-rspec
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 2.3.0
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 2.3.0
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: simplecov
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 0.21.2
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
123
179
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
180
|
+
version: 0.21.2
|
125
181
|
description: Validates brazilian documents like CPF, CNPJ and IE.
|
126
182
|
email:
|
127
183
|
- asseinfo@asseinfo.com.br
|
@@ -129,14 +185,15 @@ executables: []
|
|
129
185
|
extensions: []
|
130
186
|
extra_rdoc_files: []
|
131
187
|
files:
|
188
|
+
- ".github/workflows/config.yml"
|
132
189
|
- ".gitignore"
|
133
190
|
- ".rspec"
|
134
|
-
- ".
|
191
|
+
- ".rubocop.yml"
|
135
192
|
- Gemfile
|
193
|
+
- Gemfile.lock
|
136
194
|
- README.md
|
137
195
|
- Rakefile
|
138
196
|
- br_documents.gemspec
|
139
|
-
- circle.yml
|
140
197
|
- config/locales/pt-BR.yml
|
141
198
|
- lib/br_documents.rb
|
142
199
|
- lib/br_documents/cnpj_cpf/cnpj.rb
|
@@ -144,7 +201,10 @@ files:
|
|
144
201
|
- lib/br_documents/cnpj_cpf/document.rb
|
145
202
|
- lib/br_documents/cnpj_validator.rb
|
146
203
|
- lib/br_documents/commons/mod11.rb
|
204
|
+
- lib/br_documents/commons/mod14.rb
|
147
205
|
- lib/br_documents/cpf_validator.rb
|
206
|
+
- lib/br_documents/gtin/gtin.rb
|
207
|
+
- lib/br_documents/gtin_validator.rb
|
148
208
|
- lib/br_documents/ie/ac.rb
|
149
209
|
- lib/br_documents/ie/al.rb
|
150
210
|
- lib/br_documents/ie/am.rb
|
@@ -177,11 +237,15 @@ files:
|
|
177
237
|
- lib/br_documents/ie/sp.rb
|
178
238
|
- lib/br_documents/ie/to.rb
|
179
239
|
- lib/br_documents/ie_validator.rb
|
240
|
+
- lib/br_documents/suframa/suframa.rb
|
241
|
+
- lib/br_documents/suframa_validator.rb
|
180
242
|
- lib/br_documents/version.rb
|
181
243
|
- spec/cnpj_cpf/cnpj_spec.rb
|
182
244
|
- spec/cnpj_cpf/cpf_spec.rb
|
183
245
|
- spec/cnpj_validator_spec.rb
|
184
246
|
- spec/cpf_validator_spec.rb
|
247
|
+
- spec/gtin/gtin_spec.rb
|
248
|
+
- spec/gtin_validator_spec.rb
|
185
249
|
- spec/ie/ac_spec.rb
|
186
250
|
- spec/ie/al_spec.rb
|
187
251
|
- spec/ie/am_spec.rb
|
@@ -214,6 +278,8 @@ files:
|
|
214
278
|
- spec/ie/to_spec.rb
|
215
279
|
- spec/ie_validator_spec.rb
|
216
280
|
- spec/spec_helper.rb
|
281
|
+
- spec/suframa/suframa_spec.rb
|
282
|
+
- spec/suframa_validator_spec.rb
|
217
283
|
- spec/support/utilities.rb
|
218
284
|
homepage: http://github.com/asseinfo/br_documents
|
219
285
|
licenses:
|
@@ -234,8 +300,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
234
300
|
- !ruby/object:Gem::Version
|
235
301
|
version: '0'
|
236
302
|
requirements: []
|
237
|
-
|
238
|
-
rubygems_version: 2.6.13
|
303
|
+
rubygems_version: 3.1.6
|
239
304
|
signing_key:
|
240
305
|
specification_version: 4
|
241
306
|
summary: Validates brazilian documents like CPF, CNPJ and IE. It can be used with
|
@@ -245,6 +310,8 @@ test_files:
|
|
245
310
|
- spec/cnpj_cpf/cpf_spec.rb
|
246
311
|
- spec/cnpj_validator_spec.rb
|
247
312
|
- spec/cpf_validator_spec.rb
|
313
|
+
- spec/gtin/gtin_spec.rb
|
314
|
+
- spec/gtin_validator_spec.rb
|
248
315
|
- spec/ie/ac_spec.rb
|
249
316
|
- spec/ie/al_spec.rb
|
250
317
|
- spec/ie/am_spec.rb
|
@@ -277,4 +344,6 @@ test_files:
|
|
277
344
|
- spec/ie/to_spec.rb
|
278
345
|
- spec/ie_validator_spec.rb
|
279
346
|
- spec/spec_helper.rb
|
347
|
+
- spec/suframa/suframa_spec.rb
|
348
|
+
- spec/suframa_validator_spec.rb
|
280
349
|
- spec/support/utilities.rb
|
data/.travis.yml
DELETED
data/circle.yml
DELETED