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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTY3NWZiM2IxM2I5MzJlYjNhMGE3NTM4NWVjMGZlNTdjZjQ0OTAzYQ==
4
+ ZjA4OTMwMzkxMDcwNzdmNjE5MTAxOWYxYWMyODgyM2ExMGJkOGNmMg==
5
5
  data.tar.gz: !binary |-
6
- N2E1M2ViZDIzNmMwYTQ5ZDVjNDEzNWVhMGQ1NWEyOTRhZTE3ZDIyNg==
6
+ YWY2NjM3MDlmZTdhOWU4OGIxNzJiODAxYmE1MGRlYTI3YTU4ZTQ5YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MmRlMjAzNmZmOTUwZmZkMmIzNzIyYWRjMzFjMjNjOTUzYzgxYWRlYTc1ZDFh
10
- OWY2NjkwYjhmNjg3YmZjNjBjZjgyNGQ5NjRhY2JiZTkyNTgwNzFiMDA4YzY1
11
- MWJiYzUxYWEzMDgxNDUzOGNlN2UwY2JhOWIzZGQxOTQyMWQ1Mjc=
9
+ NjA0NTY2ZTNlZTJmN2Q0NzQ1YzY2ZTI1MTE3Mjc0MDg4ODgzOTEwMTYzMmU3
10
+ MGJmOTU4ZjhiY2U2NDRiOTk4ZWJmYTYzY2NiYjk1MzU4Zjc4Zjc4ZWE0MDZh
11
+ MzU2ZjQxNDg5NGE3YWIyMzNhMjFjNDNkNTlmN2JmNjIyZjhkMWQ=
12
12
  data.tar.gz: !binary |-
13
- YzM3MDg0NWNhZWQxZTk3Nzg5ZGVhZmEzOWEzYjdhY2Q5YTRiNjk5YjQ2ZDA0
14
- NzAwZDZkMTg3OTYxYmU5Y2Q4NGY3ZThlMTIyMDk0MDYzMDAwY2Q1ZDUzNjI2
15
- NGVkOWIyYmNmMjUxZmM3ZjUzNGJhNDFkN2FiZGRhNjc0YjkxYTA=
13
+ MDVmOTY4MjVlZWE0ZGE2ZmY5MTY5MmQ4ZTNkOTk1ODUzNDkxNjQ1MGJjYTgx
14
+ ODAxOThhYjEwNmYzODVjZGU1NGI5Njc1MjVhNjhmZGFiYjc5YzIwZmFiZGJh
15
+ M2VjYTY1NWVjMTJlMzM5N2E5YWYwYzFjMjc3YjZlNDk2NzI0NWQ=
@@ -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.body
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')
@@ -1,6 +1,6 @@
1
1
  module BoaVista
2
2
  class Configuration
3
- attr_accessor :code, :password, :url, :timeout, :proxy_url, :proxy_user, :proxy_pass
3
+ attr_accessor :code, :password, :url, :timeout, :proxy_url
4
4
 
5
5
  def has_proxy?
6
6
  !self.proxy_url.nil?
@@ -4,5 +4,6 @@ module BoaVista
4
4
  class InvalidLayout < StandardError; end
5
5
  class FileNotExists < StandardError; end
6
6
  class InvalidDocumentType < StandardError; end
7
+ class ResponseStatusInvalid < StandardError; end
7
8
  end
8
9
  end
@@ -1,5 +1,4 @@
1
- require 'timeout'
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 request with proxy #{proxy_uri.host}")
19
- request = Net::HTTP::Get.new(@uri.path)
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
- Net::HTTP.get_response(@uri)
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
- end
26
+ end
42
27
  end
43
28
 
44
29
 
@@ -1,3 +1,3 @@
1
1
  module BoaVista
2
- VERSION = '0.0.10'
2
+ VERSION = '0.0.11'
3
3
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  RSpec.describe BoaVista::VERSION do
2
- specify { expect(BoaVista::VERSION).to eq '0.0.10' }
2
+ specify { expect(BoaVista::VERSION).to eq '0.0.11' }
3
3
  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.10
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-21 00:00:00.000000000 Z
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