From ec7e1182488869d425d36a105eedb5b4ebb9332d Mon Sep 17 00:00:00 2001 From: Vijay Subramani Date: Thu, 31 Dec 2015 15:48:39 -0800 Subject: [PATCH] Update credentials_loader.rb --- lib/googleauth/credentials_loader.rb | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/googleauth/credentials_loader.rb b/lib/googleauth/credentials_loader.rb index 0e5dfdf..f8b317e 100644 --- a/lib/googleauth/credentials_loader.rb +++ b/lib/googleauth/credentials_loader.rb @@ -28,6 +28,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. require 'memoist' +require 'os' require 'rbconfig' module Google @@ -55,12 +56,6 @@ module Google SYSTEM_DEFAULT_ERROR = 'Unable to read the system default credential file' - # determines if the current OS is windows - def windows? - RbConfig::CONFIG['host_os'] =~ /Windows|mswin/ - end - memoize :windows? - # make_creds proxies the construction of a credentials instance # # By default, it calls #new on the current class, but this behaviour can @@ -91,10 +86,10 @@ module Google # # @param scope [string|array|nil] the scope(s) to access def from_well_known_path(scope = nil) - home_var = windows? ? 'APPDATA' : 'HOME' + home_var = OS.windows? ? 'APPDATA' : 'HOME' base = WELL_KNOWN_PATH root = ENV[home_var].nil? ? '' : ENV[home_var] - base = File.join('.config', base) unless windows? + base = File.join('.config', base) unless OS.windows? path = File.join(root, base) return nil unless File.exist?(path) File.open(path) do |f| @@ -108,7 +103,7 @@ module Google # # @param scope [string|array|nil] the scope(s) to access def from_system_default_path(scope = nil) - if windows? + if OS.windows? return nil unless ENV['ProgramData'] prefix = File.join(ENV['ProgramData'], 'Google/Auth') else