Merge pull request #56 from vsubramani/master

Fix for ADC not working on some windows machines
This commit is contained in:
Tim Emiola 2016-01-04 08:25:38 -08:00
commit 642a70f8fa
2 changed files with 5 additions and 9 deletions

View File

@ -30,5 +30,6 @@ Gem::Specification.new do |s|
s.add_dependency 'jwt', '~> 1.4'
s.add_dependency 'memoist', '~> 0.12'
s.add_dependency 'multi_json', '~> 1.11'
s.add_dependency 'os', '~> 0.9'
s.add_dependency 'signet', '~> 0.7'
end

View File

@ -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