nap 0.5 → 0.5.1

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.
Files changed (2) hide show
  1. data/lib/rest/request.rb +12 -7
  2. metadata +4 -3
@@ -73,21 +73,26 @@ module REST
73
73
  [url.path, url.query].compact.join('?')
74
74
  end
75
75
 
76
- def http_proxy
77
- ENV['HTTP_PROXY'] || ENV['http_proxy']
76
+ def proxy_env
77
+ {
78
+ 'http' => ENV['HTTP_PROXY'] || ENV['http_proxy'],
79
+ 'https' => ENV['HTTPS_PROXY'] || ENV['https_proxy']
80
+ }
78
81
  end
79
82
 
80
83
  def proxy_settings
81
- http_proxy ? URI.parse(http_proxy) : nil
84
+ proxy_env[url.scheme] ? URI.parse(proxy_env[url.scheme]) : nil
82
85
  end
83
86
 
84
- def proxy
85
- @proxy ||= Net::HTTP.Proxy(proxy_settings.host, proxy_settings.port, proxy_settings.user, proxy_settings.password)
87
+ def http_proxy
88
+ if settings = proxy_settings
89
+ Net::HTTP.Proxy(settings.host, settings.port, settings.user, settings.password)
90
+ end
86
91
  end
87
92
 
88
93
  def http_request
89
- if proxy_settings
90
- proxy.new(url.host, url.port)
94
+ if http_proxy
95
+ http_proxy.new(url.host, url.port)
91
96
  else
92
97
  Net::HTTP.new(url.host, url.port)
93
98
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nap
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- version: "0.5"
9
+ - 1
10
+ version: 0.5.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Manfred Stienstra
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2012-03-12 00:00:00 Z
18
+ date: 2012-03-14 00:00:00 Z
18
19
  dependencies:
19
20
  - !ruby/object:Gem::Dependency
20
21
  name: rake