Prevent errors loading deprecated installed_app file if launchy is not present (#745)

This commit is contained in:
Daniel Azuma 2018-12-05 10:51:45 -08:00 committed by GitHub
parent f6e204d1ac
commit ce9de93a55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 2 deletions

View File

@ -13,7 +13,16 @@
# limitations under the License. # limitations under the License.
require 'webrick' require 'webrick'
require 'launchy'
launchy_available =
begin
require 'launchy'
true
rescue LoadError
warn "Attempted to require google/api_client/auth/installed_app.rb when" \
" launchy is not available. The InstalledAppFlow class is disabled."
false
end
module Google module Google
class APIClient class APIClient
@ -21,6 +30,12 @@ module Google
# Small helper for the sample apps for performing OAuth 2.0 flows from the command # Small helper for the sample apps for performing OAuth 2.0 flows from the command
# line or in any other installed app environment. # line or in any other installed app environment.
# #
# This class is used in some sample apps and tests but is not really part
# of the client libraries, and probably does not belong here. As such, it
# is deprecated. If you do choose to use it, note that you must include the
# `launchy` gem in your bundle, as it is required by this class but not
# listed in the google-api-client gem's requirements.
#
# @example # @example
# #
# flow = Google::APIClient::InstalledAppFlow.new( # flow = Google::APIClient::InstalledAppFlow.new(
@ -125,4 +140,4 @@ module Google
end end
end end
end end if launchy_available