rest 3.0.4 → 3.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba15d81f6c76785edf3428a260a198255381a560
4
- data.tar.gz: 6fc466049561186c8a9630dbb378829e720564d9
3
+ metadata.gz: 880fe5136cd250c97eb7862c93a4b296a4f9b9ad
4
+ data.tar.gz: 02dac2153fbc8a86bab768b732547604d19a2c21
5
5
  SHA512:
6
- metadata.gz: 62942db61c51d3778091b33cd10e948d731376778ae6d087c443544b64e96260c8c574dcbb57c9ce81d062c98f19be5d92c40db34f1f878994c72299bbde5ff8
7
- data.tar.gz: 356f07a9816be48f97650bf97ab5d7ab81366217ebb835ebffdfdbe1990128dffd96fb17a522de84d3e88855174407189a60e2419593c97018f4b8a5ca7273bb
6
+ metadata.gz: 8087772b56f2ceebcde26485b8b3a16a2e3cf4ff77ba4e1e6c6ac42a512690b53b056d59bc28c1de0c43529da19d5bad2609af15813851f02ed8b9ae347acfb7
7
+ data.tar.gz: 4ffccb545451c80d261cca8071c41c3f2d69e387fb30419106f7c300832fa82447be3213f6dbfffc39a87b25f3cf4884c4e0353771d016d2a15e8b192e1a291b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rest (3.0.3)
4
+ rest (3.0.5)
5
5
  net-http-persistent (>= 2.9.1)
6
6
  netrc
7
7
 
@@ -50,6 +50,7 @@ module Rest
50
50
  class Client
51
51
 
52
52
  attr_accessor :options, :logger, :gem
53
+ attr_reader :wrapper
53
54
  # options:
54
55
  # - :gem => specify gem explicitly
55
56
  #
@@ -70,7 +71,7 @@ module Rest
70
71
  @logger.debug "Using excon gem."
71
72
  elsif @gem == :typhoeus
72
73
  require File.expand_path('wrappers/typhoeus_wrapper', File.dirname(__FILE__))
73
- @wrapper = Rest::Wrappers::TyphoeusWrapper.new
74
+ @wrapper = Rest::Wrappers::TyphoeusWrapper.new(self)
74
75
  @logger.debug "Using typhoeus gem."
75
76
  elsif @gem == :net_http_persistent
76
77
  require File.expand_path('wrappers/net_http_persistent_wrapper', File.dirname(__FILE__))
@@ -79,13 +80,15 @@ module Rest
79
80
  elsif @gem == :rest_client
80
81
  require File.expand_path('wrappers/rest_client_wrapper', File.dirname(__FILE__))
81
82
  @wrapper = Rest::Wrappers::RestClientWrapper.new
82
- hint = (options[:gem] ? "" : "NOTICE: Please install 'typhoeus' gem or upgrade to Ruby 2.X for optimal performance.")
83
+ hint = (options[:gem] ? "" : "NOTICE: Please upgrade to Ruby 2.X for optimal performance.")
83
84
  puts hint
84
85
  @logger.debug "Using rest-client gem. #{hint}"
86
+ RestClient.proxy = options[:http_proxy] if options[:http_proxy]
85
87
  else # use internal client
86
88
  require File.expand_path('wrappers/internal_client_wrapper', File.dirname(__FILE__))
87
89
  @wrapper = Rest::Wrappers::InternalClientWrapper.new
88
90
  @logger.debug "Using rest internal client. #{hint}"
91
+ InternalClient.proxy = options[:http_proxy] if options[:http_proxy]
89
92
  end
90
93
  end
91
94
 
@@ -1,3 +1,3 @@
1
1
  module Rest
2
- VERSION = "3.0.4"
2
+ VERSION = "3.0.5"
3
3
  end
@@ -54,7 +54,8 @@ module Rest
54
54
 
55
55
  def initialize(client)
56
56
  @client = client
57
- @http = Net::HTTP::Persistent.new 'rest_gem'
57
+ @http = Net::HTTP::Persistent.new('rest_gem')
58
+ @http.proxy = URI(@client.options[:http_proxy]) if @client.options[:http_proxy]
58
59
  @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
59
60
  end
60
61
 
@@ -33,6 +33,10 @@ module Rest
33
33
 
34
34
  class TyphoeusWrapper < BaseWrapper
35
35
 
36
+ def initialize(client)
37
+ @client = client
38
+ end
39
+
36
40
  def default_typhoeus_options
37
41
  req_hash = {}
38
42
  # todo: should change this timeout to longer if it's for posting file
@@ -46,6 +50,7 @@ module Rest
46
50
 
47
51
  def get(url, req_hash={})
48
52
  req_hash = default_typhoeus_options.merge(req_hash)
53
+ req_hash[:proxy] = @client.options[:http_proxy] if @client.options[:http_proxy]
49
54
  # puts "REQ_HASH=" + req_hash.inspect
50
55
  response = Typhoeus::Request.get(url, req_hash)
51
56
  #p response
@@ -8,7 +8,6 @@ class TestTemp < TestBase
8
8
 
9
9
  end
10
10
 
11
-
12
11
  def test_post_file
13
12
  r = @rest.post_file("http://httpbin.org/post", :params=>{:q => "Rick Astley"})
14
13
  p r
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 3.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Reeder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-25 00:00:00.000000000 Z
11
+ date: 2015-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-http-persistent