From ce9de93a55197dc0f6797e681e183f7cd896b52c Mon Sep 17 00:00:00 2001 From: Daniel Azuma Date: Wed, 5 Dec 2018 10:51:45 -0800 Subject: [PATCH] Prevent errors loading deprecated installed_app file if launchy is not present (#745) --- lib/google/api_client/auth/installed_app.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/google/api_client/auth/installed_app.rb b/lib/google/api_client/auth/installed_app.rb index 2980ed6e0..f7370f5b8 100644 --- a/lib/google/api_client/auth/installed_app.rb +++ b/lib/google/api_client/auth/installed_app.rb @@ -13,7 +13,16 @@ # limitations under the License. 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 class APIClient @@ -21,6 +30,12 @@ module Google # Small helper for the sample apps for performing OAuth 2.0 flows from the command # 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 # # flow = Google::APIClient::InstalledAppFlow.new( @@ -125,4 +140,4 @@ module Google end end -end +end if launchy_available