tray-checkout 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +7 -0
- data/lib/tray/checkout/config.rb +5 -0
- data/lib/tray/checkout/version.rb +1 -1
- data/lib/tray/checkout/web_service.rb +15 -9
- data/spec/tray/checkout_spec.rb +13 -0
- metadata +3 -3
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].
|
data/lib/tray/checkout/config.rb
CHANGED
@@ -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
|
@@ -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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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)
|
data/spec/tray/checkout_spec.rb
CHANGED
@@ -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.
|
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-
|
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:
|
188
|
+
hash: -3269883588982628234
|
189
189
|
requirements: []
|
190
190
|
rubyforge_project:
|
191
191
|
rubygems_version: 1.8.25
|