Module: Njord::ConfigurationReader

Defined in:
lib/njord/configuration_reader.rb

Constant Summary collapse

CONFIG_FILE =
".njord.yml".freeze

Class Method Summary collapse

Class Method Details

.read_from_fileObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/njord/configuration_reader.rb', line 9

def self.read_from_file
  if File.exist?(CONFIG_FILE)
    JSON.parse(YAML.load_file(CONFIG_FILE).to_json, object_class: OpenStruct)
  else
    raise(ArgumentError, "No .njord.yml config file exists. \
      Please create one.")
  end
rescue
  raise(ArgumentError, "Something is wrong with the .njord.yml - \
    please check the README for a valid example.")
end