td-client 0.8.23 → 0.8.24

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,4 +1,9 @@
1
1
 
2
+ == 2012-08-30 version 0.8.24
3
+
4
+ * TreasureData::Client.new supports :http_proxy option
5
+
6
+
2
7
  == 2012-08-30 version 0.8.23
3
8
 
4
9
  * Supports HTTP_PROXY environment variable
@@ -20,6 +20,10 @@ class API
20
20
  require 'json'
21
21
  require 'time'
22
22
  require 'uri'
23
+ require 'net/http'
24
+ require 'net/https'
25
+ require 'time'
26
+
23
27
  @apikey = apikey
24
28
 
25
29
  endpoint = opts[:endpoint] || ENV['TD_API_SERVER'] || 'api.treasure-data.com'
@@ -50,6 +54,18 @@ class API
50
54
  end
51
55
  @base_path = ''
52
56
  end
57
+
58
+ @http_proxy = opts[:http_proxy] || ENV['HTTP_PROXY']
59
+ if @http_proxy = ENV['HTTP_PROXY']
60
+ if @http_proxy =~ /\Ahttp:\/\/(.*)\z/
61
+ @http_proxy = $~[1]
62
+ end
63
+ proxy_host, proxy_port = @http_proxy.split(':',2)
64
+ proxy_port = (proxy_port ? proxy_port.to_i : 80)
65
+ @http_class = Net::HTTP::Proxy(proxy_host, proxy_port)
66
+ else
67
+ @http_class = Net::HTTP
68
+ end
53
69
  end
54
70
 
55
71
  # TODO error check & raise appropriate errors
@@ -1191,22 +1207,7 @@ class API
1191
1207
  end
1192
1208
 
1193
1209
  def new_http
1194
- require 'net/http'
1195
- require 'net/https'
1196
- require 'time'
1197
-
1198
- if proxy = ENV['HTTP_PROXY']
1199
- if proxy =~ /\Ahttp:\/\/(.*)\z/
1200
- proxy = $~[1]
1201
- end
1202
- proxy_host, proxy_port = proxy.split(':',2)
1203
- proxy_port = (proxy_port ? proxy_port.to_i : 80)
1204
- http_class = Net::HTTP::Proxy(proxy_host, proxy_port)
1205
- else
1206
- http_class = Net::HTTP
1207
- end
1208
-
1209
- http = http_class.new(@host, @port)
1210
+ http = @http_class.new(@host, @port)
1210
1211
  if @ssl
1211
1212
  http.use_ssl = true
1212
1213
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
@@ -1,5 +1,5 @@
1
1
  module TreasureData
2
2
 
3
- VERSION = '0.8.23'
3
+ VERSION = '0.8.24'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: td-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.23
4
+ version: 0.8.24
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: