boa_vista 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2998d9ef1d03081cdec0608f4869611b8eb15402
4
- data.tar.gz: 5e0eadc595b9575caade884ce04003a1a1a56f21
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZGNlNTRkMjYwYWEwN2ZlNGNiZDFmZjdlYTQ1ZWVjMWE5MjdkNmM4OQ==
5
+ data.tar.gz: !binary |-
6
+ NWM3NzQ3ZGVlYjhiYWQ2MTM0NGZhOTgwMDliMDA0MGRiYTVmYTQ2Ng==
5
7
  SHA512:
6
- metadata.gz: 820c8f79894b54d612e44cceee00406ada9ec76172f369805a0b9f1f81f771b3ebf3722f214747033b346a1f09eb3821a66d39e9ea5bcbe732d222243370cb3a
7
- data.tar.gz: 0003cdea065857897f523388a3391c8a4e80de6993fbebd892543444e62f233d1eaef22dedc5e07b372eddaa308ff9bab4da2509f8061988858c3c47004a4267
8
+ metadata.gz: !binary |-
9
+ NWM1ZmMxY2JlNDE5NThhYzM0ODVjZWEzY2QwOWY3NjE3ZDUwZDRiYTcyZDNh
10
+ NmUwZTIyMjE0NGY0ZjY4OGRkMDNjNWVmNWIwN2RiYTBkMDI4MTczZWMyYTgy
11
+ OTdjZWM3YWQxYTE4NzA2NDAxZWU2OGJlY2RjY2I2NmJmYjhmYzQ=
12
+ data.tar.gz: !binary |-
13
+ M2M4OGQ5YzliMGI3ODg5OTEyNzhjNGUxZWU5NjgwNWQ4MjkzNzgwNzc1ZWJl
14
+ ZWVlZDI5YzhlMmIzOTYxOGZkMzgwZjY5M2Q5ZTdiYzNiYjA5OThmMzllNWEw
15
+ NmFmM2I2ZGZmODUwZDJhNzFjZWVlMWQzMzhlOGIzMjM1ZDFiNGQ=
@@ -13,7 +13,7 @@ module BoaVista
13
13
  begin
14
14
  response = nil
15
15
  execute_with_timeout do
16
- response = Net::HTTP.get_response(uri(create_request)).body
16
+ response = BoaVista::Http.new(uri(create_request)).call.body
17
17
  end
18
18
  @response.new(parsed_response(response)).read
19
19
  rescue Timeout::Error
@@ -22,17 +22,16 @@ module BoaVista
22
22
  end
23
23
 
24
24
  private
25
-
26
- def parsed_response(response)
27
- BoaVista::Response::Parser.new(response).call
28
- end
29
-
30
25
  def execute_with_timeout
31
26
  Timeout::timeout(BoaVista.configuration.timeout.to_i) do
32
27
  yield if block_given?
33
28
  end
34
29
  end
35
30
 
31
+ def parsed_response(response)
32
+ BoaVista::Response::Parser.new(response).call
33
+ end
34
+
36
35
  def create_request
37
36
  @request.new(@attributes).create
38
37
  end
@@ -1,5 +1,9 @@
1
1
  module BoaVista
2
2
  class Configuration
3
- attr_accessor :code, :password, :url, :timeout
3
+ attr_accessor :code, :password, :url, :timeout, :proxy_host, :proxy_port, :proxy_user, :proxy_pass
4
+
5
+ def has_proxy?
6
+ self.proxy_host != nil
7
+ end
4
8
  end
5
9
  end
@@ -0,0 +1,36 @@
1
+ require 'timeout'
2
+ require 'net/http'
3
+
4
+ module BoaVista
5
+ class Http
6
+ def initialize(uri, has_proxy = BoaVista.configuration.has_proxy?)
7
+ @uri = uri
8
+ @has_proxy = has_proxy
9
+ end
10
+
11
+ def call
12
+ @has_proxy ? execute_request_using_proxy : execute_request
13
+ end
14
+
15
+ def execute_request_using_proxy
16
+ request = Net::HTTP::Get.new(@uri.path)
17
+
18
+ proxy.start(@uri.path, @uri.port) do |http|
19
+ http.request(request)
20
+ end
21
+ end
22
+
23
+ def execute_request
24
+ Net::HTTP.get_response(@uri)
25
+ end
26
+
27
+ def proxy
28
+ @proxy ||= Net::HTTP::Proxy(BoaVista.configuration.proxy_host,
29
+ BoaVista.configuration.proxy_port,
30
+ BoaVista.configuration.proxy_user,
31
+ BoaVista.configuration.proxy_pass)
32
+ end
33
+ end
34
+ end
35
+
36
+
@@ -1,3 +1,6 @@
1
+ require 'cgi'
2
+ require 'nokogiri'
3
+
1
4
  module BoaVista
2
5
  class Response
3
6
  class Parser
@@ -1,3 +1,3 @@
1
1
  module BoaVista
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  end
data/lib/boa_vista.rb CHANGED
@@ -1,9 +1,6 @@
1
- require 'net/http'
2
- require 'cgi'
3
- require 'nokogiri'
4
-
5
1
  require 'boa_vista/configuration'
6
2
  require 'boa_vista/client'
3
+ require 'boa_vista/http'
7
4
 
8
5
  require 'boa_vista/field'
9
6
  require 'boa_vista/field/reader'
@@ -1,3 +1,3 @@
1
1
  RSpec.describe BoaVista::VERSION do
2
- specify { expect(BoaVista::VERSION).to eq '0.0.7' }
2
+ specify { expect(BoaVista::VERSION).to eq '0.0.8' }
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.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Souza
@@ -9,90 +9,90 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-17 00:00:00.000000000 Z
12
+ date: 2016-03-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
18
+ - - ! '>='
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ">="
25
+ - - ! '>='
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: codeclimate-test-reporter
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - ! '>='
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - ! '>='
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: webmock
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - ! '>='
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ">="
53
+ - - ! '>='
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rspec
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ">="
60
+ - - ! '>='
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ">="
67
+ - - ! '>='
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec-its
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ">="
74
+ - - ! '>='
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - ">="
81
+ - - ! '>='
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rake
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - ">="
88
+ - - ! '>='
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - ">="
95
+ - - ! '>='
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  description: Client for Boa Vista
@@ -112,6 +112,7 @@ files:
112
112
  - lib/boa_vista/field/reader.rb
113
113
  - lib/boa_vista/field/writer.rb
114
114
  - lib/boa_vista/fixtures.rb
115
+ - lib/boa_vista/http.rb
115
116
  - lib/boa_vista/line.rb
116
117
  - lib/boa_vista/request.rb
117
118
  - lib/boa_vista/request/default.rb
@@ -189,17 +190,17 @@ require_paths:
189
190
  - lib
190
191
  required_ruby_version: !ruby/object:Gem::Requirement
191
192
  requirements:
192
- - - ">="
193
+ - - ! '>='
193
194
  - !ruby/object:Gem::Version
194
195
  version: '0'
195
196
  required_rubygems_version: !ruby/object:Gem::Requirement
196
197
  requirements:
197
- - - ">="
198
+ - - ! '>='
198
199
  - !ruby/object:Gem::Version
199
200
  version: '0'
200
201
  requirements: []
201
202
  rubyforge_project:
202
- rubygems_version: 2.4.6
203
+ rubygems_version: 2.4.8
203
204
  signing_key:
204
205
  specification_version: 4
205
206
  summary: Client for Boa Vista
@@ -249,4 +250,3 @@ test_files:
249
250
  - spec/lib/boa_vista/response_spec.rb
250
251
  - spec/lib/boa_vista/version_spec.rb
251
252
  - spec/spec_helper.rb
252
- has_rdoc: