Class: Config
- Inherits:
-
Object
- Object
- Config
- Defined in:
- lib/meshx-plugin-sdk.rb
Instance Method Summary collapse
- #get(name) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
317 318 319 320 |
# File 'lib/meshx-plugin-sdk.rb', line 317 def initialize() @config_path = Helper.get_env("X_CONFIG", "/etc/plugin/config.json") @config = load() end |
Instance Method Details
#get(name) ⇒ Object
328 329 330 331 332 333 334 335 |
# File 'lib/meshx-plugin-sdk.rb', line 328 def get(name) rtn = @config[name] if rtn == "" puts("plugin configuration is not valid, missing: #{name}") exit(2) end return rtn end |
#load ⇒ Object
322 323 324 325 326 |
# File 'lib/meshx-plugin-sdk.rb', line 322 def load() file = File.read(@config_path) config = JSON.parse(file) return config end |