restforce 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of restforce might be problematic. Click here for more details.

@@ -15,7 +15,8 @@ module Restforce
15
15
  include Restforce::Client::API
16
16
 
17
17
  OPTIONS = [:username, :password, :security_token, :client_id, :client_secret, :host, :compress,
18
- :api_version, :oauth_token, :refresh_token, :instance_url, :cache, :authentication_retries]
18
+ :api_version, :oauth_token, :refresh_token, :instance_url, :cache, :authentication_retries,
19
+ :timeout]
19
20
 
20
21
  # Public: Creates a new client instance
21
22
  #
@@ -47,6 +48,7 @@ module Restforce
47
48
  # before raising an exception (default: 3).
48
49
  #
49
50
  # :compress - Set to true to have Salesforce compress the response (default: false).
51
+ # :timeout - Faraday connection request read/open timeout. (default: nil).
50
52
  #
51
53
  # Examples
52
54
  #
@@ -73,5 +75,9 @@ module Restforce
73
75
  @options = Hash[OPTIONS.map { |option| [option, Restforce.configuration.send(option)] }]
74
76
  @options.merge! opts
75
77
  end
78
+
79
+ def inspect
80
+ "#<#{self.class} @options=#{@options.inspect}>"
81
+ end
76
82
  end
77
83
  end
@@ -19,7 +19,7 @@ module Restforce
19
19
 
20
20
  # Internal: Internal faraday connection where all requests go through
21
21
  def connection
22
- @connection ||= Faraday.new(@options[:instance_url]) do |builder|
22
+ @connection ||= Faraday.new(@options[:instance_url], connection_options) do |builder|
23
23
  # Parses JSON into Hashie::Mash structures.
24
24
  builder.use Restforce::Middleware::Mashify, self, @options
25
25
  # Handles multipart file uploads for blobs.
@@ -45,10 +45,21 @@ module Restforce
45
45
  # Compress/Decompress the request/response
46
46
  builder.use Restforce::Middleware::Gzip, self, @options
47
47
 
48
- builder.adapter Faraday.default_adapter
48
+ builder.adapter adapter
49
49
  end
50
50
  end
51
51
 
52
+ def adapter
53
+ Restforce.configuration.adapter
54
+ end
55
+
56
+ # Internal: Faraday Connection options
57
+ def connection_options
58
+ { :request => {
59
+ :timeout => @options[:timeout],
60
+ :open_timeout => @options[:timeout] } }
61
+ end
62
+
52
63
  # Internal: Returns true if the middlware stack includes the
53
64
  # Restforce::Middleware::Mashify middleware.
54
65
  def mashify?
@@ -66,6 +66,12 @@ module Restforce
66
66
  # Set to true if you want responses from Salesforce to be gzip compressed.
67
67
  attr_accessor :compress
68
68
 
69
+ # Faraday request read/open timeout.
70
+ attr_accessor :timeout
71
+
72
+ # Faraday adapter to use. Defaults to Faraday.default_adapter.
73
+ attr_accessor :adapter
74
+
69
75
  def api_version
70
76
  @api_version ||= '26.0'
71
77
  end
@@ -98,6 +104,10 @@ module Restforce
98
104
  @authentication_retries ||= 3
99
105
  end
100
106
 
107
+ def adapter
108
+ @adapter ||= Faraday.default_adapter
109
+ end
110
+
101
111
  def logger
102
112
  @logger ||= ::Logger.new STDOUT
103
113
  end
@@ -1,3 +1,3 @@
1
1
  module Restforce
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  end
@@ -22,8 +22,9 @@ describe Restforce do
22
22
  its(:api_version) { should eq '26.0' }
23
23
  its(:host) { should eq 'login.salesforce.com' }
24
24
  its(:authentication_retries) { should eq 3 }
25
+ its(:adapter) { should eq Faraday.default_adapter }
25
26
  [:username, :password, :security_token, :client_id, :client_secret,
26
- :oauth_token, :refresh_token, :instance_url, :compress].each do |attr|
27
+ :oauth_token, :refresh_token, :instance_url, :compress, :timeout].each do |attr|
27
28
  its(attr) { should be_nil }
28
29
  end
29
30
  end
@@ -54,7 +55,7 @@ describe Restforce do
54
55
  end
55
56
 
56
57
  describe '#configure' do
57
- [:username, :password, :security_token, :client_id, :client_secret, :compress,
58
+ [:username, :password, :security_token, :client_id, :client_secret, :compress, :timeout,
58
59
  :oauth_token, :refresh_token, :instance_url, :api_version, :host, :authentication_retries].each do |attr|
59
60
  it "allows #{attr} to be set" do
60
61
  Restforce.configure do |config|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
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-01-07 00:00:00.000000000 Z
12
+ date: 2013-01-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday