Sha256: 0c45af4c441295c5f2ef04df95c7618e1c3251764452be8a370837de14108ae8

Contents?: true

Size: 635 Bytes

Versions: 5

Compression:

Stored size: 635 Bytes

Contents

require 'json'
require "singleton"
require "dkc/constants"

module Dkc
  class Config
    include Singleton

    def load
      begin
        config_file = File.read(CONFIG_FILE_NAME)
        parsed_data = JSON.parse(config_file)

        if parsed_data.class != Hash
          raise StandardError.new("ERROR: JSON Failed to parse in #{CONFIG_FILE_NAME}")
        end

        @configuration = parsed_data

      rescue Errno::ENOENT
        return false
      rescue StandardError => e
        puts e.message
        return false
      end

      return true
    end

    def getValue(key)
      @configuration[key]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dkc-0.1.4 lib/dkc/config.rb
dkc-0.1.3 lib/dkc/config.rb
dkc-0.1.2 lib/dkc/config.rb
dkc-0.1.1 lib/dkc/config.rb
dkc-0.1.0 lib/dkc/config.rb