class Convoy::Setup::Configuration::Reader

Attributes

path[R]

Public Class Methods

new(path) click to toggle source
# File lib/convoy/setup/configuration/reader.rb, line 9
def initialize(path)
    @path = path
end

Public Instance Methods

read() click to toggle source
# File lib/convoy/setup/configuration/reader.rb, line 13
def read
    data = {}
    data = load_config_at_path if path
    Instance.new(path, data)
end

Private Instance Methods

load_config_at_path() click to toggle source
# File lib/convoy/setup/configuration/reader.rb, line 21
def load_config_at_path
    data = {}
    begin
        json = File.read(path)
        hash = ::JSON.parse(json)
        data = Convoy::Utils.symbolize_keys(hash)
    rescue => e
        error_logger.warn { "Found config at #{path}, but failed to load it, perhaps your JSON syntax is invalid. Attempting to continue without..." }
        error_logger.debug(e)
    end
    data
end