class Diplomat::Client

Public Class Methods

config(*args) click to toggle source

@note This is sugar, see (get)

# File lib/diplomat/client.rb, line 34
def self.config *args
  Diplomat::Client.new.config *args
end

Public Instance Methods

config(directory) click to toggle source

parse configuration @param directory [String] location of consult client configuration files @return [OpenStruct] all data associated with the service

# File lib/diplomat/client.rb, line 14
def config directory

  services = []
  Dir.glob("#{directory}/*.json") do |json_file|
    # do work on files ending in .rb in the desired directory
    file = File.read(json_file)
    data_hash = JSON.parse(file)
    data_hash.each do |key, array|
      if key.casecmp("service") == 0
        services.push(array)
      else
        @@config[key] = array
      end
    end
  end
  @@config["services"] = services
  return @@config
end