boa_vista 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/boa_vista/request/layout/cnpj.rb +3 -3
- data/lib/boa_vista/request/layout/cpf.rb +1 -1
- data/lib/boa_vista/request/layout.rb +13 -12
- data/lib/boa_vista/request.rb +17 -5
- data/lib/boa_vista/response/layout/layout_249.rb +9 -9
- data/lib/boa_vista/response/layout/layout_353.rb +21 -21
- data/lib/boa_vista/version.rb +1 -1
- data/spec/fixtures/layout_249.txt +1 -1
- data/spec/fixtures/request_cpf.txt +1 -0
- data/spec/lib/boa_vista/request/layout/cnpj_spec.rb +3 -3
- data/spec/lib/boa_vista/request/layout/cpf_spec.rb +3 -3
- data/spec/lib/boa_vista/request/layout_spec.rb +12 -12
- data/spec/lib/boa_vista/request_spec.rb +37 -26
- data/spec/lib/boa_vista/response/layout/layout_249_spec.rb +1 -1
- data/spec/lib/boa_vista/version_spec.rb +1 -1
- metadata +4 -16
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MDEwM2FlZTY0ODFmMWI1NTA2ODQyNWYxMzNkNzg5ZmYzYWYzNmZkMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTE2NDQ4MDA3YTMyOWQ3MmY5NDA4YTNlN2Y4NWI5ODFhNTQwNWViZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTRhOWI5MGNhNDRhMzU3Y2Q3MTFhOGY3NzQ3YWYyOWJhMmMxMjg5MWI1NmNm
|
10
|
+
MmFmNDE0NDg5Yjc5ZWQ3NmZkNTE0YzJmZjFiYTNkMzRiMmU5NDdiMTllYzc0
|
11
|
+
MTJhMjM4ZWUwZGY3YzNjNjhmNjQ5YTVjNDI3YWQ2MWU5MzVjOTY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmVkYWIzMTQyY2VhNDJlMGZhNzY0OTI3MDBhNWE0NGQ4Y2YzZGFhNzZkMGNk
|
14
|
+
ZDQ5YTgyMTE4NDYxOTY5NTA5ZjQ5MTExN2YzNGVhOTUyNmE1NjIxZGFlZmI0
|
15
|
+
M2EzMjI0NWM3NjMyMWIzYzZkYjk5ZTVkMTQ4YzNjMmQyNDdlZDY=
|
@@ -4,9 +4,9 @@ module BoaVista
|
|
4
4
|
module_function
|
5
5
|
|
6
6
|
def attributes
|
7
|
-
BoaVista::Request::Layout.attributes.merge(company_name: { range:
|
8
|
-
facilitator_code: { range:
|
9
|
-
end_text_indicator: { range:
|
7
|
+
BoaVista::Request::Layout.attributes.merge(company_name: { range: 83..132 },
|
8
|
+
facilitator_code: { range: 133..140 },
|
9
|
+
end_text_indicator: { range: 141..141 })
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -5,19 +5,20 @@ module BoaVista
|
|
5
5
|
|
6
6
|
def attributes
|
7
7
|
{
|
8
|
-
transaction: { range:
|
9
|
-
version: { range: 9
|
10
|
-
reserved_requester: { range:
|
11
|
-
reserved_boa_vista: { range:
|
12
|
-
code: { range:
|
13
|
-
password: { range:
|
14
|
-
query: { range:
|
15
|
-
query_version: { range: 65
|
16
|
-
response_type: { range:
|
17
|
-
response_transmission_type: { range:
|
18
|
-
document_type: { range:
|
19
|
-
document_number: { range:
|
8
|
+
transaction: { range: 0..7 },
|
9
|
+
version: { range: 8..9 },
|
10
|
+
reserved_requester: { range: 10..19 },
|
11
|
+
reserved_boa_vista: { range: 20..39 },
|
12
|
+
code: { range: 40..47 },
|
13
|
+
password: { range: 48..55 },
|
14
|
+
query: { range: 56..63 },
|
15
|
+
query_version: { range: 64..65 },
|
16
|
+
response_type: { range: 66..66 },
|
17
|
+
response_transmission_type: { range: 67..67 },
|
18
|
+
document_type: { range: 68..68 },
|
19
|
+
document_number: { range: 69..82 }
|
20
20
|
}
|
21
|
+
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
data/lib/boa_vista/request.rb
CHANGED
@@ -10,20 +10,32 @@ module BoaVista
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def create
|
13
|
-
write_line_with(layout)
|
13
|
+
write_line_with(self.class.layout(@values[:document_type]))
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
def self.read(line)
|
17
|
+
document_type = line.slice(68..68)
|
18
|
+
BoaVista::Line.prepare_for_read(line, layout(document_type)).read
|
19
|
+
end
|
17
20
|
|
18
|
-
def layout
|
19
|
-
case
|
21
|
+
def self.layout(document_type)
|
22
|
+
case document_type.to_i
|
20
23
|
when DOCUMENT_TYPE[:cpf] then BoaVista::Request::Layout::Cpf
|
21
24
|
when DOCUMENT_TYPE[:cnpj] then BoaVista::Request::Layout::Cnpj
|
22
25
|
else
|
23
|
-
fail BoaVista::Errors::InvalidDocumentType.new("Invalid document type: #{
|
26
|
+
fail BoaVista::Errors::InvalidDocumentType.new("Invalid document type: #{document_type}")
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
30
|
+
def self.document_name(document_type)
|
31
|
+
DOCUMENT_TYPE.each do |k, v|
|
32
|
+
return k if document_type.to_i == v
|
33
|
+
end
|
34
|
+
return false
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
27
39
|
def write_line_with(layout)
|
28
40
|
BoaVista::Line.prepare_for_write(@values, layout).write
|
29
41
|
end
|
@@ -7,15 +7,15 @@ module BoaVista
|
|
7
7
|
|
8
8
|
def attributes
|
9
9
|
default_attributes.merge(query_online: { range: 77..77 },
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
name: { range: 78..137 },
|
11
|
+
document: { range: 138..148 },
|
12
|
+
birthday_date: { range: 149..156 },
|
13
|
+
mothers_name: { range: 157..206 },
|
14
|
+
voter_registration: { range: 207..219 },
|
15
|
+
condition: { range: 220..220 },
|
16
|
+
query_date: { range: 221..228 },
|
17
|
+
query_time: { range: 229..234 },
|
18
|
+
protocol: { range: 235..254 })
|
19
19
|
end
|
20
20
|
|
21
21
|
def condition_options
|
@@ -7,27 +7,27 @@ module BoaVista
|
|
7
7
|
|
8
8
|
def attributes
|
9
9
|
default_attributes.merge(record: { range: 77..77 },
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
10
|
+
document_number: { range: 78..91 },
|
11
|
+
nire: { range: 92..102 },
|
12
|
+
company_name: { range: 103..217 },
|
13
|
+
condition: { range: 218..218 },
|
14
|
+
foundation_date: { range: 219..226 },
|
15
|
+
registration: { range: 227..240 },
|
16
|
+
registration_status: { range: 241..241 },
|
17
|
+
address: { range: 242..311 },
|
18
|
+
district: { range: 312..331 },
|
19
|
+
postal_code: { range: 332..339 },
|
20
|
+
city: { range: 340..379 },
|
21
|
+
uf: { range: 380..381 },
|
22
|
+
phone_1: { range: 382..401 },
|
23
|
+
phone_2: { range: 402..416 },
|
24
|
+
fax: { range: 417..431 },
|
25
|
+
ibge_code: { range: 432..439 },
|
26
|
+
legal_nature_code: { range: 440..447 },
|
27
|
+
legal_nature_description: { range: 448..502 },
|
28
|
+
segment: { range: 503..581 },
|
29
|
+
hive_activity_code: { range: 582..589 },
|
30
|
+
hive_activity_description: { range: 590..644 })
|
31
31
|
end
|
32
32
|
|
33
33
|
def condition_options
|
data/lib/boa_vista/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
TTTTTTTTVVRRRRRRRRRRBBBBBBBBBBBBBBBBBBBBCCCCCCCCQQQQQQQQQVYCNNNNNNNTTTTZZZ249QNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN3073086661025121982MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMVVVVVVVVVVVVVCDDDDDDDDTTTTTTPPPPPPPPPPPPPPPPPPPP
|
@@ -0,0 +1 @@
|
|
1
|
+
CSR60 01 00000045HOM033 SINTON 012C100012345678900X
|
@@ -20,12 +20,12 @@ RSpec.describe BoaVista::Request::Layout::Cnpj do
|
|
20
20
|
|
21
21
|
context 'cnpj attributes' do
|
22
22
|
it { is_expected.to have_key(:company_name) }
|
23
|
-
its([:company_name, :range]) { is_expected.to eq(
|
23
|
+
its([:company_name, :range]) { is_expected.to eq(83..132) }
|
24
24
|
|
25
25
|
it { is_expected.to have_key(:facilitator_code) }
|
26
|
-
its([:facilitator_code, :range]) { is_expected.to eq(
|
26
|
+
its([:facilitator_code, :range]) { is_expected.to eq(133..140) }
|
27
27
|
|
28
28
|
it { is_expected.to have_key(:end_text_indicator) }
|
29
|
-
its([:end_text_indicator, :range]) { is_expected.to eq(
|
29
|
+
its([:end_text_indicator, :range]) { is_expected.to eq(141..141) }
|
30
30
|
end
|
31
31
|
end
|
@@ -21,8 +21,8 @@ RSpec.describe BoaVista::Request::Layout::Cpf do
|
|
21
21
|
it 'includes the end_text_indicator with the right range' do
|
22
22
|
expect(subject).to have_key(:end_text_indicator)
|
23
23
|
|
24
|
-
expect(subject[:end_text_indicator][:range]).to cover(
|
25
|
-
expect(subject[:end_text_indicator][:range]).to_not cover(
|
26
|
-
expect(subject[:end_text_indicator][:range]).to_not cover(
|
24
|
+
expect(subject[:end_text_indicator][:range]).to cover(83)
|
25
|
+
expect(subject[:end_text_indicator][:range]).to_not cover(82)
|
26
|
+
expect(subject[:end_text_indicator][:range]).to_not cover(84)
|
27
27
|
end
|
28
28
|
end
|
@@ -2,17 +2,17 @@ RSpec.describe BoaVista::Request::Layout do
|
|
2
2
|
describe 'attributes_mapping_methods' do
|
3
3
|
subject { described_class.attributes }
|
4
4
|
|
5
|
-
its([:transaction, :range]) { is_expected.to eq(
|
6
|
-
its([:version, :range]) { is_expected.to eq(9
|
7
|
-
its([:reserved_requester, :range]) { is_expected.to eq(
|
8
|
-
its([:reserved_boa_vista, :range]) { is_expected.to eq(
|
9
|
-
its([:code, :range]) { is_expected.to eq(
|
10
|
-
its([:password, :range]) { is_expected.to eq(
|
11
|
-
its([:query, :range]) { is_expected.to eq(
|
12
|
-
its([:query_version, :range]) { is_expected.to eq(65
|
13
|
-
its([:response_type, :range]) { is_expected.to eq(
|
14
|
-
its([:response_transmission_type, :range]) { is_expected.to eq(
|
15
|
-
its([:document_type, :range]) { is_expected.to eq(
|
16
|
-
its([:document_number, :range]) { is_expected.to eq(
|
5
|
+
its([:transaction, :range]) { is_expected.to eq(0..7) }
|
6
|
+
its([:version, :range]) { is_expected.to eq(8..9) }
|
7
|
+
its([:reserved_requester, :range]) { is_expected.to eq(10..19) }
|
8
|
+
its([:reserved_boa_vista, :range]) { is_expected.to eq(20..39) }
|
9
|
+
its([:code, :range]) { is_expected.to eq(40..47) }
|
10
|
+
its([:password, :range]) { is_expected.to eq(48..55) }
|
11
|
+
its([:query, :range]) { is_expected.to eq(56..63) }
|
12
|
+
its([:query_version, :range]) { is_expected.to eq(64..65) }
|
13
|
+
its([:response_type, :range]) { is_expected.to eq(66..66) }
|
14
|
+
its([:response_transmission_type, :range]) { is_expected.to eq(67..67) }
|
15
|
+
its([:document_type, :range]) { is_expected.to eq(68..68) }
|
16
|
+
its([:document_number, :range]) { is_expected.to eq(69..82) }
|
17
17
|
end
|
18
18
|
end
|
@@ -2,42 +2,53 @@ RSpec.describe BoaVista::Request do
|
|
2
2
|
|
3
3
|
let(:instance) { described_class.new(values) }
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
describe '#create' do
|
6
|
+
|
7
|
+
subject { instance.create }
|
8
|
+
|
9
|
+
context 'when document is cpf' do
|
10
|
+
let(:values) do
|
11
|
+
{
|
12
|
+
document_type: '1',
|
13
|
+
document_number: '00031030944410'
|
14
|
+
}.merge(BoaVista::Request::Default::CPF)
|
15
|
+
end
|
14
16
|
|
15
|
-
|
17
|
+
let(:document_type) { values[:document_type] }
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
+
it 'writes document number in the right position' do
|
20
|
+
expect(subject.slice(69..82)).to eq('00031030944410')
|
21
|
+
end
|
19
22
|
end
|
20
|
-
end
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
context 'when document is cnpj' do
|
25
|
+
let(:values) do
|
26
|
+
{
|
27
|
+
document_type: '2',
|
28
|
+
document_number: '12345678901234'
|
29
|
+
}.merge(BoaVista::Request::Default::CNPJ)
|
30
|
+
end
|
31
|
+
|
32
|
+
let(:document_type) { values[:document_type] }
|
33
|
+
|
34
|
+
it 'writes document number in the right position' do
|
35
|
+
expect(subject.slice(69..82)).to eq('12345678901234')
|
36
|
+
end
|
28
37
|
end
|
29
38
|
|
30
|
-
|
39
|
+
context 'when invalid document type' do
|
40
|
+
let(:values) { Hash.new }
|
41
|
+
let(:document_type) { '3' }
|
31
42
|
|
32
|
-
|
33
|
-
expect(subject.slice(69..82)).to eq('12345678901234')
|
43
|
+
it { expect { subject }.to raise_error(BoaVista::Errors::InvalidDocumentType) }
|
34
44
|
end
|
35
45
|
end
|
36
46
|
|
37
|
-
|
38
|
-
let(:
|
39
|
-
|
47
|
+
describe '.read' do
|
48
|
+
let(:line) { File.read('./spec/fixtures/request_cpf.txt') }
|
49
|
+
subject { described_class.read(line) }
|
40
50
|
|
41
|
-
|
51
|
+
its(:document_number) { is_expected.to eq('00012345678900') }
|
52
|
+
its(:document_type) { is_expected.to eq('1') }
|
42
53
|
end
|
43
54
|
end
|
@@ -8,7 +8,7 @@ RSpec.describe BoaVista::Response::Layout::Layout249 do
|
|
8
8
|
|
9
9
|
its(:transaction) { is_expected.to eq('T' * 8) }
|
10
10
|
its(:query_online) { is_expected.to eq('Q' * 1) }
|
11
|
-
its(:name) { is_expected.to eq('N' *
|
11
|
+
its(:name) { is_expected.to eq('N' * 60) }
|
12
12
|
its(:document) { is_expected.to eq('30730866610') }
|
13
13
|
its(:birthday_date) { is_expected.to eq('25121982') }
|
14
14
|
its(:mothers_name) { is_expected.to eq('M' * 50) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boa_vista
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Souza
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-03-
|
12
|
+
date: 2016-03-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -67,20 +67,6 @@ dependencies:
|
|
67
67
|
- - ! '>='
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: pry
|
72
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - ! '>='
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '0'
|
77
|
-
type: :development
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - ! '>='
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: '0'
|
84
70
|
- !ruby/object:Gem::Dependency
|
85
71
|
name: rspec-its
|
86
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,6 +148,7 @@ files:
|
|
162
148
|
- spec/fixtures/layout_999.txt
|
163
149
|
- spec/fixtures/layout_cpf.txt
|
164
150
|
- spec/fixtures/layout_invalid_353.txt
|
151
|
+
- spec/fixtures/request_cpf.txt
|
165
152
|
- spec/fixtures/response_with_html.txt
|
166
153
|
- spec/fixtures/unknown_layout.txt
|
167
154
|
- spec/lib/boa_vista/client_spec.rb
|
@@ -230,6 +217,7 @@ test_files:
|
|
230
217
|
- spec/fixtures/layout_999.txt
|
231
218
|
- spec/fixtures/layout_cpf.txt
|
232
219
|
- spec/fixtures/layout_invalid_353.txt
|
220
|
+
- spec/fixtures/request_cpf.txt
|
233
221
|
- spec/fixtures/response_with_html.txt
|
234
222
|
- spec/fixtures/unknown_layout.txt
|
235
223
|
- spec/lib/boa_vista/client_spec.rb
|