correios_sigep 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +0 -1
- data/correios_sigep.gemspec +1 -0
- data/lib/correios_sigep/configuration.rb +1 -1
- data/lib/correios_sigep/logistic_reverse/base_client.rb +11 -1
- data/lib/correios_sigep/version.rb +1 -1
- data/spec/correios_sigep/configuration_spec.rb +31 -18
- data/spec/correios_sigep/logistic_reverse/base_client_spec.rb +24 -0
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGE2NDlkNWI5OWMzYjkxOGE5NGUwNTA3ZjEyNjViYjUwOWQ1OTJlYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDBkNjZkNjY0OWZhODE2NzRiM2Q3YjllZGE4ZmRjZTJlMWRhZWQ4Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGE0NTZiZjhlYWY0MGRjYmEyZDNjNzYwMDdhODE2ZWQ2NTAwNWJjZjVmZmIy
|
10
|
+
OWM3MDRlNzJiY2JlMTFhYmJjMjQ1YWZlNDIzOWM2ODA5M2ZjNzE0ZDMzNjI3
|
11
|
+
MjZjNDdlYmMyYmU4NGIxOTE2MWE4YTU1MmUwMGVmN2EyMDY3NzU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjkzZTEwNGFiNDI2NzNkYTRhNTgwNTJkY2NiNjI0NThiNzA5OTc1ZmNhMTU4
|
14
|
+
OThkMTI0ZjIwZTA0MTg4ZjllNTBiNDBmMmZmM2M5NGI2OWMwN2U5ZTQ1ZmE5
|
15
|
+
ZmE0ODE4M2Q3OTdiM2JlOTQxMmYxODE0NWNjNTE3MjNkNjlkZTg=
|
data/.travis.yml
CHANGED
data/correios_sigep.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
21
|
spec.add_dependency 'net-http-persistent', '~> 2.9.4'
|
22
|
+
spec.add_dependency 'rack', '~> 1.6', '>= 1.6.4'
|
22
23
|
spec.add_dependency 'savon', '~> 2.0'
|
23
24
|
|
24
25
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module CorreiosSigep
|
2
2
|
class Configuration
|
3
3
|
attr_accessor :administrative_code, :card, :contract, :password,
|
4
|
-
:service_code, :user, :wsdl_base_url, :proxy
|
4
|
+
:service_code, :user, :wsdl_base_url, :proxy, :timeout
|
5
5
|
|
6
6
|
def administrative_fields
|
7
7
|
@administrative_fields ||=
|
@@ -1,8 +1,18 @@
|
|
1
1
|
module CorreiosSigep
|
2
2
|
module LogisticReverse
|
3
3
|
class BaseClient
|
4
|
+
DEFAULT_TIMEOUT = 30
|
5
|
+
|
4
6
|
def initialize
|
5
|
-
|
7
|
+
timeout = CorreiosSigep.configuration.timeout || DEFAULT_TIMEOUT
|
8
|
+
|
9
|
+
options = {
|
10
|
+
adapter: :net_http_persistent,
|
11
|
+
proxy: CorreiosSigep.configuration.proxy,
|
12
|
+
wsdl: wsdl,
|
13
|
+
open_timeout: timeout,
|
14
|
+
read_timeout: timeout
|
15
|
+
}
|
6
16
|
options.delete(:proxy) unless options[:proxy]
|
7
17
|
|
8
18
|
options.merge!({ headers: { 'SOAPAction' => '' }}) if ENV['GEM_ENV'] == 'test'
|
@@ -3,52 +3,52 @@ module CorreiosSigep
|
|
3
3
|
subject { described_class.new }
|
4
4
|
|
5
5
|
describe '#administrative_code' do
|
6
|
-
it '
|
7
|
-
expect(subject.administrative_code).
|
6
|
+
it 'returns nil when unset' do
|
7
|
+
expect(subject.administrative_code).to be_nil
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
describe '#administrative_code=' do
|
12
|
-
it '
|
12
|
+
it 'sets the administrative code in configuration' do
|
13
13
|
subject.administrative_code = '12345'
|
14
14
|
expect(subject.administrative_code).to eq '12345'
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
describe '#card' do
|
19
|
-
it '
|
20
|
-
expect(subject.card).
|
19
|
+
it 'returns nil when unset' do
|
20
|
+
expect(subject.card).to be_nil
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
describe '#card=' do
|
25
|
-
it '
|
25
|
+
it 'sets the card in configuration' do
|
26
26
|
subject.card = 'card'
|
27
27
|
expect(subject.card).to eq 'card'
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
describe '#contract' do
|
32
|
-
it '
|
33
|
-
expect(subject.contract).
|
32
|
+
it 'returns nil when unset' do
|
33
|
+
expect(subject.contract).to be_nil
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
describe '#contract=' do
|
38
|
-
it '
|
38
|
+
it 'sets the contract in configuration' do
|
39
39
|
subject.contract = 'contract'
|
40
40
|
expect(subject.contract).to eq 'contract'
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
describe '#password' do
|
45
|
-
it '
|
46
|
-
expect(subject.password).
|
45
|
+
it 'returns nil when unset' do
|
46
|
+
expect(subject.password).to be_nil
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
describe '#password=' do
|
51
|
-
it '
|
51
|
+
it 'sets the password in configuration' do
|
52
52
|
subject.password = 'password'
|
53
53
|
expect(subject.password).to eq 'password'
|
54
54
|
end
|
@@ -56,29 +56,42 @@ module CorreiosSigep
|
|
56
56
|
|
57
57
|
|
58
58
|
describe '#service_code' do
|
59
|
-
it '
|
60
|
-
expect(subject.service_code).
|
59
|
+
it 'returns nil when unset' do
|
60
|
+
expect(subject.service_code).to be_nil
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
describe '#service_code=' do
|
65
|
-
it '
|
65
|
+
it 'sets the password in configuration' do
|
66
66
|
subject.service_code = 'service_code'
|
67
67
|
expect(subject.service_code).to eq 'service_code'
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
71
|
describe '#user' do
|
72
|
-
it '
|
73
|
-
expect(subject.user).
|
72
|
+
it 'returns nil when unset' do
|
73
|
+
expect(subject.user).to be_nil
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
describe '#user=' do
|
78
|
-
it '
|
78
|
+
it 'sets the user in configuration' do
|
79
79
|
subject.user = 'user'
|
80
80
|
expect(subject.user).to eq 'user'
|
81
81
|
end
|
82
82
|
end
|
83
|
+
|
84
|
+
describe '#timeout' do
|
85
|
+
it 'returns nil when unset' do
|
86
|
+
expect(subject.timeout).to be_nil
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '#timeout=' do
|
91
|
+
it 'sets the timeout in configuration' do
|
92
|
+
subject.timeout = 15
|
93
|
+
expect(subject.timeout).to eq 15
|
94
|
+
end
|
95
|
+
end
|
83
96
|
end
|
84
97
|
end
|
@@ -13,6 +13,8 @@ module CorreiosSigep
|
|
13
13
|
adapter: :net_http_persistent,
|
14
14
|
proxy: CorreiosSigep.configuration.proxy,
|
15
15
|
wsdl: described_class.new.wsdl,
|
16
|
+
open_timeout: CorreiosSigep::LogisticReverse::BaseClient::DEFAULT_TIMEOUT,
|
17
|
+
read_timeout: CorreiosSigep::LogisticReverse::BaseClient::DEFAULT_TIMEOUT,
|
16
18
|
headers: { 'SOAPAction' => '' }
|
17
19
|
}
|
18
20
|
end
|
@@ -29,6 +31,8 @@ module CorreiosSigep
|
|
29
31
|
{
|
30
32
|
adapter: :net_http_persistent,
|
31
33
|
wsdl: described_class.new.wsdl,
|
34
|
+
open_timeout: CorreiosSigep::LogisticReverse::BaseClient::DEFAULT_TIMEOUT,
|
35
|
+
read_timeout: CorreiosSigep::LogisticReverse::BaseClient::DEFAULT_TIMEOUT,
|
32
36
|
headers: { 'SOAPAction' => '' }
|
33
37
|
}
|
34
38
|
end
|
@@ -58,6 +62,26 @@ module CorreiosSigep
|
|
58
62
|
end
|
59
63
|
|
60
64
|
end
|
65
|
+
|
66
|
+
context 'setting a timeout' do
|
67
|
+
subject { described_class.new }
|
68
|
+
|
69
|
+
before { CorreiosSigep.configuration.timeout = 15 }
|
70
|
+
let(:params) do
|
71
|
+
{
|
72
|
+
adapter: :net_http_persistent,
|
73
|
+
wsdl: described_class.new.wsdl,
|
74
|
+
open_timeout: CorreiosSigep.configuration.timeout,
|
75
|
+
read_timeout: CorreiosSigep.configuration.timeout,
|
76
|
+
headers: { 'SOAPAction' => '' }
|
77
|
+
}
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'initializes @client with informed timeout' do
|
81
|
+
expect(Savon).to receive(:client).with(params) { true }
|
82
|
+
subject
|
83
|
+
end
|
84
|
+
end
|
61
85
|
end
|
62
86
|
end
|
63
87
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: correios_sigep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Ribeiro
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-08-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-http-persistent
|
@@ -25,6 +25,26 @@ dependencies:
|
|
25
25
|
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 2.9.4
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rack
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.6'
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.6.4
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '1.6'
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.6.4
|
28
48
|
- !ruby/object:Gem::Dependency
|
29
49
|
name: savon
|
30
50
|
requirement: !ruby/object:Gem::Requirement
|