Module: MAuth::ConfigFile

Defined in:
lib/mauth/client.rb

Constant Summary collapse

GITHUB_URL =
'https://github.com/mdsol/mauth-client-ruby'

Class Method Summary collapse

Class Method Details

.load(path) ⇒ Object



254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/mauth/client.rb', line 254

def self.load(path)
  unless File.exist?(path)
    raise "File #{path} not found. Please visit #{GITHUB_URL} for details."
  end

  @config[path] ||= yaml_safe_load_file(path)
  unless @config[path]
    raise "File #{path} does not contain proper YAML information. Visit #{GITHUB_URL} for details."
  end

  @config[path]
end

.yaml_safe_load_file(path) ⇒ Object



267
268
269
270
# File 'lib/mauth/client.rb', line 267

def self.yaml_safe_load_file(path)
  yml_data = File.read(path)
  YAML.safe_load(yml_data, aliases: true)
end