class NetuitiveRubyApi::ConfigManager
Attributes
data[R]
event_cache_enabled[R]
event_cache_interval[R]
event_cache_size[R]
netuitivedAddr[R]
netuitivedPort[R]
sample_cache_enabled[R]
sample_cache_interval[R]
sample_cache_size[R]
Public Class Methods
boolean_property(name, var)
click to toggle source
# File lib/netuitive_ruby_api/config_manager.rb, line 21 def boolean_property(name, var) prop = ENV[var].nil? ? nil : ENV[var].dup if prop.nil? || (prop == '') prop = data[name] else prop.strip! prop = prop.casecmp('true').zero? end prop end
float_property(name, var)
click to toggle source
# File lib/netuitive_ruby_api/config_manager.rb, line 32 def float_property(name, var) property(name, var).to_f end
int_property(name, var)
click to toggle source
# File lib/netuitive_ruby_api/config_manager.rb, line 36 def int_property(name, var) property(name, var).to_i end
load_config()
click to toggle source
# File lib/netuitive_ruby_api/config_manager.rb, line 52 def load_config gem_root = File.expand_path('../../..', __FILE__) @data = YAML.load_file "#{gem_root}/config/agent.yml" end
property(name, var, default = nil)
click to toggle source
# File lib/netuitive_ruby_api/config_manager.rb, line 14 def property(name, var, default = nil) prop = ENV[var] prop = data[name] if prop.nil? || (prop == '') return prop unless prop.nil? || (prop == '') default end
read_config()
click to toggle source
# File lib/netuitive_ruby_api/config_manager.rb, line 57 def read_config @sample_cache_enabled = boolean_property('sampleCacheEnabled', 'NETUITIVE_RUBY_SAMPLE_CACHE_ENABLED') @sample_cache_size = int_property('sampleCacheSize', 'NETUITIVE_RUBY_SAMPLE_CACHE_SIZE') @sample_cache_interval = int_property('sampleCacheInterval', 'NETUITIVE_RUBY_SAMPLE_CACHE_INTERVAL') @event_cache_enabled = boolean_property('eventCacheEnabled', 'NETUITIVE_RUBY_EVENT_CACHE_ENABLED') @event_cache_size = int_property('eventCacheSize', 'NETUITIVE_RUBY_SAMPLE_CACHE_SIZE') @event_cache_interval = int_property('eventCacheInterval', 'NETUITIVE_RUBY_SAMPLE_CACHE_INTERVAL') @netuitivedAddr = property('netuitivedAddr', 'NETUITIVE_RUBY_NETUITIVED_ADDR') @netuitivedPort = property('netuitivedPort', 'NETUITIVE_RUBY_NETUITIVED_PORT') debugLevelString = property('debugLevel', 'NETUITIVE_RUBY_DEBUG_LEVEL') NetuitiveRubyApi::NetuitiveLogger.log.level = if debugLevelString == 'error' Logger::ERROR elsif debugLevelString == 'info' Logger::INFO elsif debugLevelString == 'debug' Logger::DEBUG else Logger::ERROR end NetuitiveRubyApi::NetuitiveLogger.log.info "netuitived port: #{@netuitivedPort}" NetuitiveRubyApi::NetuitiveLogger.log.info "netuitived addr: #{@netuitivedAddr}" NetuitiveRubyApi::NetuitiveLogger.log.debug "read config file. Results: netuitivedAddr: #{@netuitivedAddr} netuitivedPort: #{@netuitivedPort} debugLevel: #{debugLevelString} sample_cache_enabled: #{@sample_cache_enabled} sample_cache_size: #{@sample_cache_size} sample_cache_interval: #{@sample_cache_interval} event_cache_enabled: #{@event_cache_enabled} event_cache_size: #{@event_cache_size} event_cache_interval: #{@event_cache_interval}" end
string_list_property(name, var)
click to toggle source
# File lib/netuitive_ruby_api/config_manager.rb, line 40 def string_list_property(name, var) list = [] prop = ENV[var].nil? ? nil : ENV[var].dup if prop.nil? || (prop == '') list = data[name] if !data[name].nil? && data[name].is_a?(Array) else list = prop.split(',') end list.each(&:strip!) unless list.empty? list end