Fix incompatibility with faraday 0.6.2
[arvados.git] / lib / google / api_client.rb
index 367b1e040cd1fe0b8dff843854680ba26622f7e3..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|
@@ -490,7 +496,7 @@ module Google
       else
         check_cached_certs = lambda do
           valid = false
-          for key, cert in @certificates
+          for _key, cert in @certificates
             begin
               self.authorization.decoded_id_token(cert.public_key)
               valid = true