boa_vista 0.0.10 → 0.0.11
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/client.rb +3 -2
- data/lib/boa_vista/configuration.rb +1 -1
- data/lib/boa_vista/errors.rb +1 -0
- data/lib/boa_vista/http.rb +6 -21
- data/lib/boa_vista/version.rb +1 -1
- data/spec/lib/boa_vista/client_spec.rb +7 -1
- data/spec/lib/boa_vista/version_spec.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjA4OTMwMzkxMDcwNzdmNjE5MTAxOWYxYWMyODgyM2ExMGJkOGNmMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWY2NjM3MDlmZTdhOWU4OGIxNzJiODAxYmE1MGRlYTI3YTU4ZTQ5YQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjA0NTY2ZTNlZTJmN2Q0NzQ1YzY2ZTI1MTE3Mjc0MDg4ODgzOTEwMTYzMmU3
|
10
|
+
MGJmOTU4ZjhiY2U2NDRiOTk4ZWJmYTYzY2NiYjk1MzU4Zjc4Zjc4ZWE0MDZh
|
11
|
+
MzU2ZjQxNDg5NGE3YWIyMzNhMjFjNDNkNTlmN2JmNjIyZjhkMWQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDVmOTY4MjVlZWE0ZGE2ZmY5MTY5MmQ4ZTNkOTk1ODUzNDkxNjQ1MGJjYTgx
|
14
|
+
ODAxOThhYjEwNmYzODVjZGU1NGI5Njc1MjVhNjhmZGFiYjc5YzIwZmFiZGJh
|
15
|
+
M2VjYTY1NWVjMTJlMzM5N2E5YWYwYzFjMjc3YjZlNDk2NzI0NWQ=
|
data/lib/boa_vista/client.rb
CHANGED
@@ -14,10 +14,11 @@ module BoaVista
|
|
14
14
|
begin
|
15
15
|
response = nil
|
16
16
|
execute_with_timeout do
|
17
|
-
response = BoaVista::Http.new(uri(create_request)).call
|
17
|
+
response = BoaVista::Http.new(uri(create_request)).call
|
18
|
+
fail Errors::ResponseStatusInvalid.new("Response status is: #{response.status}") if response.status != 200
|
18
19
|
BoaVista.log(:debug, "Response of request: #{response}")
|
19
20
|
end
|
20
|
-
@response.new(parsed_response(response)).read
|
21
|
+
@response.new(parsed_response(response.body)).read
|
21
22
|
rescue Timeout::Error
|
22
23
|
BoaVista.log(:debug, "Request is Timeout")
|
23
24
|
fail Errors::Timeout.new('timed out')
|
data/lib/boa_vista/errors.rb
CHANGED
data/lib/boa_vista/http.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'net/http'
|
1
|
+
require 'faraday'
|
3
2
|
|
4
3
|
module BoaVista
|
5
4
|
class Http
|
@@ -15,30 +14,16 @@ module BoaVista
|
|
15
14
|
private
|
16
15
|
|
17
16
|
def execute_request_using_proxy
|
18
|
-
BoaVista.log(:debug, "Executing
|
19
|
-
request
|
20
|
-
|
21
|
-
proxy.start(@uri.path, @uri.port) do |http|
|
22
|
-
http.request(request)
|
23
|
-
end
|
17
|
+
BoaVista.log(:debug, "Executing with proxy: #{BoaVista.configuration.proxy_url}")
|
18
|
+
BoaVista.log(:debug, "Executing request for uri: #{@uri}")
|
19
|
+
::Faraday.new(proxy: BoaVista.configuration.proxy_url, url: @uri).get
|
24
20
|
end
|
25
21
|
|
26
22
|
def execute_request
|
27
23
|
BoaVista.log(:debug, "Executing request for uri: #{@uri}")
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
def proxy
|
32
|
-
@proxy ||= Net::HTTP::Proxy(proxy_uri.host,
|
33
|
-
proxy_uri.port,
|
34
|
-
BoaVista.configuration.proxy_user,
|
35
|
-
BoaVista.configuration.proxy_pass)
|
36
|
-
end
|
37
|
-
|
38
|
-
def proxy_uri
|
39
|
-
@proxy_uri ||= URI(BoaVista.configuration.proxy_url)
|
24
|
+
::Faraday.new(url: @uri).get
|
40
25
|
end
|
41
|
-
|
26
|
+
end
|
42
27
|
end
|
43
28
|
|
44
29
|
|
data/lib/boa_vista/version.rb
CHANGED
@@ -35,8 +35,14 @@ RSpec.describe BoaVista::Client do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
context 'when timeout error' do
|
38
|
+
let(:faraday_connection) { instance_double(Faraday::Connection) }
|
39
|
+
|
40
|
+
before do
|
41
|
+
allow(Faraday).to receive(:new).and_return(faraday_connection)
|
42
|
+
allow(faraday_connection).to receive(:get) { raise(Timeout::Error) }
|
43
|
+
end
|
44
|
+
|
38
45
|
it 'raise BoaVista::Errors::Timeout' do
|
39
|
-
allow(Net::HTTP).to receive(:get_response).with(anything) { raise(Timeout::Error) }
|
40
46
|
expect { subject }.to raise_error(BoaVista::Errors::Timeout)
|
41
47
|
end
|
42
48
|
end
|
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.11
|
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-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -25,6 +25,20 @@ dependencies:
|
|
25
25
|
- - ! '>='
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: faraday
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: codeclimate-test-reporter
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|