Class: Dkc::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/dkc/config.rb

Instance Method Summary collapse

Instance Method Details

#getValue(key) ⇒ Object



30
31
32
# File 'lib/dkc/config.rb', line 30

def getValue(key)
  @configuration[key]
end

#loadObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/dkc/config.rb', line 9

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