Fix incompatibility with faraday 0.6.2
[arvados.git] / lib / google / api_client.rb
index ef3c2b1d34c1e34a622e1ff687b349f6ce681cfc..b2fa0b3c447158d1565608b00682745f9a4deb5a 100644 (file)
@@ -111,7 +111,7 @@ module Google
 
       self.user_agent = options[:user_agent] || (
         "#{application_string} " +
-        "google-api-ruby-client/#{Google::APIClient::VERSION::STRING} #{ENV::OS_VERSION} (gzip)"
+        "google-api-ruby-client/#{Google::APIClient::VERSION::STRING} #{ENV::OS_VERSION}".strip + " (gzip)"
       ).strip
       # The writer method understands a few Symbols and will generate useful
       # default authentication mechanisms.
@@ -135,7 +135,13 @@ module Google
         faraday.options.params_encoder = Faraday::FlatParamsEncoder
         faraday.ssl.ca_file = ca_file
         faraday.ssl.verify = true
-        faraday.proxy proxy
+        if faraday.respond_to?(:proxy=)
+          # faraday >= 0.6.2
+          faraday.proxy = proxy
+        else
+          # older versions of faraday
+          faraday.proxy proxy
+        end
         faraday.adapter Faraday.default_adapter
         if options[:faraday_option].is_a?(Hash)
           options[:faraday_option].each_pair do |option, value|