tray-checkout 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -204,6 +204,13 @@ You can configure this timeout using <b>Tray::Checkout</b> module.
204
204
  config.request_timeout = 3 # It configures timeout to 3 seconds
205
205
  end
206
206
 
207
+ === HTTP Proxy
208
+ If you need to use an HTTP proxy to make Tray Checkout API, configure the HTTP proxy URL on <b>Tray::Checkout</b> module.
209
+
210
+ Tray::Checkout.configure do |config|
211
+ config.proxy_url = "http://10.20.30.40:8888"
212
+ end
213
+
207
214
  === Log
208
215
 
209
216
  For default, each request to Tray Checkout API is logged to STDOUT, with <b>:info</b> log level, using the gem {LogMe}[http://github.com/prodis/log-me].
@@ -8,6 +8,7 @@ module Tray
8
8
  attr_accessor :token_account
9
9
  attr_writer :environment
10
10
  attr_writer :request_timeout
11
+ attr_writer :proxy_url
11
12
 
12
13
  def environment
13
14
  @environment ||= DEFAULT_ENVIRONMENT
@@ -24,6 +25,10 @@ module Tray
24
25
  def request_timeout
25
26
  (@request_timeout ||= DEFAULT_REQUEST_TIMEOUT).to_i
26
27
  end
28
+
29
+ def proxy_url
30
+ @proxy_url ||= ""
31
+ end
27
32
  end
28
33
  end
29
34
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: UTF-8
2
2
  module Tray
3
3
  module Checkout
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2"
5
5
  end
6
6
  end
7
7
 
@@ -16,21 +16,27 @@ module Tray
16
16
  response = http.request(request)
17
17
  log_response(response)
18
18
 
19
+ http.finish if http.started?
20
+
19
21
  response.body
20
22
  end
21
23
 
22
24
  private
23
25
 
24
26
  def build_http(uri)
25
- http = Net::HTTP.new(uri.host, uri.port)
26
- http.open_timeout = Tray::Checkout.request_timeout
27
-
28
- if uri.ssl?
29
- http.use_ssl = true
30
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
31
- end
32
-
33
- http
27
+ proxy_uri = URI.parse(Tray::Checkout.proxy_url)
28
+
29
+ Net::HTTP.start(
30
+ uri.host,
31
+ uri.port,
32
+ proxy_uri.host,
33
+ proxy_uri.port,
34
+ nil,
35
+ nil,
36
+ use_ssl: uri.ssl?,
37
+ verify_mode: OpenSSL::SSL::VERIFY_NONE,
38
+ open_timeout: Tray::Checkout.request_timeout
39
+ )
34
40
  end
35
41
 
36
42
  def build_request(uri, params)
@@ -59,4 +59,17 @@ describe Tray::Checkout do
59
59
  end
60
60
  end
61
61
  end
62
+
63
+ describe "#proxy_url" do
64
+ it "default is empty" do
65
+ Tray::Checkout.proxy_url.should == ""
66
+ end
67
+
68
+ context "when set proxy URL" do
69
+ it "returns proxy URL" do
70
+ Tray::Checkout.configure { |config| config.proxy_url = "http://10.20.30.40:8888" }
71
+ Tray::Checkout.proxy_url.should == "http://10.20.30.40:8888"
72
+ end
73
+ end
74
+ end
62
75
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tray-checkout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-08 00:00:00.000000000 Z
12
+ date: 2013-11-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  version: '0'
186
186
  segments:
187
187
  - 0
188
- hash: 2545084159827698806
188
+ hash: -3269883588982628234
189
189
  requirements: []
190
190
  rubyforge_project:
191
191
  rubygems_version: 1.8.25