lib/google/cloud/translate/service.rb in google-cloud-translate-1.1.0 vs lib/google/cloud/translate/service.rb in google-cloud-translate-1.2.0
- old
+ new
@@ -1,12 +1,12 @@
-# Copyright 2016 Google Inc. All rights reserved.
+# Copyright 2016 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
-# http://www.apache.org/licenses/LICENSE-2.0
+# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
@@ -23,12 +23,12 @@
module Translate
##
# @private
# Represents the Translation API REST service, exposing the API calls.
class Service #:nodoc:
- API_VERSION = "v2"
- API_URL = "https://translation.googleapis.com"
+ API_VERSION = "v2".freeze
+ API_URL = "https://translation.googleapis.com".freeze
# @private
attr_accessor :project, :credentials, :retries, :timeout, :key
##
@@ -69,11 +69,11 @@
post "language/translate/v2/languages", body
end
def inspect
- "#{self.class}"
+ self.class.to_s
end
protected
def post path, body = nil
@@ -90,11 +90,11 @@
end
end
return JSON.parse(response.body)["data"] if response.success?
- fail Google::Cloud::Error.gapi_error_class_for(response.status)
+ raise Google::Cloud::Error.gapi_error_class_for(response.status)
rescue Faraday::ConnectionFailed
raise Google::Cloud::ResourceExhaustedError
end
##
@@ -151,10 +151,10 @@
end
# Set the default values
self.retries = 3
self.http_codes = [500, 503]
- self.reasons = %w(rateLimitExceeded userRateLimitExceeded)
+ self.reasons = %w[rateLimitExceeded userRateLimitExceeded]
self.backoff = ->(retries) { sleep retries.to_i }
def initialize options = {} #:nodoc:
@max_retries = (options[:retries] || Backoff.retries).to_i
@http_codes = (options[:http_codes] || Backoff.http_codes).to_a