Class: Config

Inherits:
Object
  • Object
show all
Defined in:
lib/meshx-plugin-sdk.rb

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



314
315
316
317
# File 'lib/meshx-plugin-sdk.rb', line 314

def initialize()
  @config_path = Helper.get_env("X_CONFIG", "/etc/plugin/config.json")
  @config = load()
end

Instance Method Details

#get(name) ⇒ Object



325
326
327
328
329
330
331
332
# File 'lib/meshx-plugin-sdk.rb', line 325

def get(name)
  rtn = @config[name]
  if rtn == ""
    puts("plugin configuration is not valid, missing: #{name}")
    exit(2)
  end
  return rtn
end

#loadObject



319
320
321
322
323
# File 'lib/meshx-plugin-sdk.rb', line 319

def load()
  file = File.read(@config_path)
  config = JSON.parse(file)
  return config
end