Sha256: 0b5f449b893fda7a5aebfb81b68c3194d7afde79bcb8b7a1c25d9a7683b0e92f

Contents?: true

Size: 557 Bytes

Versions: 4

Compression:

Stored size: 557 Bytes

Contents

require 'yaml'
require 'json'
require 'ostruct'

module Njord
  module ConfigurationReader
    CONFIG_FILE = ".njord.yml"

    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.new("No .njord.yml config file exists. Please create one.") if config.nil?
      end
    rescue
      raise ArgumentError.new("Something is wrong with the .njord.yml - please check the README for a valid example.") if config.nil?
    end
  end
end
  

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
njord-0.1.3 lib/njord/configuration_reader.rb
njord-0.1.2 lib/njord/configuration_reader.rb
njord-0.1.1 lib/njord/configuration_reader.rb
njord-0.1.0 lib/njord/configuration_reader.rb