mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Allow string keys in credentials file [issue 179]
This commit is contained in:
parent
e8842bea8a
commit
2e2c6dd183
1 changed files with 11 additions and 1 deletions
|
@ -32,7 +32,7 @@ module Fog
|
||||||
def self.credentials
|
def self.credentials
|
||||||
@credentials ||= begin
|
@credentials ||= begin
|
||||||
if credentials_path && File.exists?(credentials_path)
|
if credentials_path && File.exists?(credentials_path)
|
||||||
credentials = YAML.load_file(credentials_path)
|
credentials = self.symbolize_credentials(YAML.load_file(credentials_path))
|
||||||
(credentials && credentials[credential]) or raise LoadError.new(missing_credentials)
|
(credentials && credentials[credential]) or raise LoadError.new(missing_credentials)
|
||||||
else
|
else
|
||||||
{}
|
{}
|
||||||
|
@ -40,6 +40,16 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.symbolize_credentials(args)
|
||||||
|
if args.is_a? Hash
|
||||||
|
Hash[ args.collect do |key, value|
|
||||||
|
[key.to_sym, self.symbolize_credentials(value)]
|
||||||
|
end ]
|
||||||
|
else
|
||||||
|
args
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# @return [String] The error message that will be raised, if credentials cannot be found
|
# @return [String] The error message that will be raised, if credentials cannot be found
|
||||||
|
|
Loading…
Add table
Reference in a new issue