lib/google/cloud/translate/api.rb in google-cloud-translate-1.1.0 vs lib/google/cloud/translate/api.rb in google-cloud-translate-1.2.0
- old
+ new
@@ -1,21 +1,20 @@
-# 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
# limitations under the License.
-require "google/cloud/env"
require "google/cloud/translate/service"
require "google/cloud/translate/translation"
require "google/cloud/translate/detection"
require "google/cloud/translate/language"
@@ -76,22 +75,13 @@
# translate.project_id #=> "my-todo-project"
#
def project_id
service.project
end
- alias_method :project, :project_id
+ alias project project_id
##
- # @private Default project.
- def self.default_project_id
- ENV["TRANSLATE_PROJECT"] ||
- ENV["GOOGLE_CLOUD_PROJECT"] ||
- ENV["GCLOUD_PROJECT"] ||
- Google::Cloud.env.project_id
- end
-
- ##
# Returns text translations from one language to another.
#
# @see https://cloud.google.com/translation/docs/translating-text#Translate
# Translating Text
#
@@ -182,10 +172,10 @@
# translation.text #=> "<strong>Salve</strong> mundi!"
#
def translate *text, to: nil, from: nil, format: nil, model: nil,
cid: nil
return nil if text.empty?
- fail ArgumentError, "to is required" if to.nil?
+ raise ArgumentError, "to is required" if to.nil?
to = to.to_s
from = from.to_s if from
format = format.to_s if format
text = Array(text).flatten
gapi = service.translate text, to: to, from: from,