class BigSister::Configuration
Constants
- MONITOR_TYPES
- REPORTER_TYPES
Attributes
monitors[R]
reporters[R]
Public Class Methods
new(data)
click to toggle source
# File lib/bigsister/configuration.rb, line 13 def initialize(data) @monitors = [] @reporters = [] @config_errors = [] load_monitoring(data) load_reporting(data) end
Public Instance Methods
valid?()
click to toggle source
# File lib/bigsister/configuration.rb, line 22 def valid? @config_errors.empty? end
Private Instance Methods
config_error(message)
click to toggle source
# File lib/bigsister/configuration.rb, line 74 def config_error(message) @config_errors.push(message) end
load_monitor(type, location, i)
click to toggle source
# File lib/bigsister/configuration.rb, line 43 def load_monitor(type, location, i) if type == "local" BigSister::LocalMonitor.new(location, i) elsif type == "springcm" BigSister::SpringcmMonitor.new(location, i) end end
load_monitoring(data)
click to toggle source
# File lib/bigsister/configuration.rb, line 28 def load_monitoring(data) @monitoring = data.fetch("monitor", []) @monitoring.each_with_index { |location, i| # Validate monitoring type type = location.fetch("type", nil) if type.nil? config_error("No monitoring type specified for location #{i}") elsif !MONITOR_TYPES.include?(type) config_error("Invalid monitoring type specified for location #{i}") else @monitors.push(load_monitor(type, location, i)) end } end
load_reporter(type, reporter, i)
click to toggle source
# File lib/bigsister/configuration.rb, line 66 def load_reporter(type, reporter, i) if type == "csv" BigSister::CsvReporter.new(reporter, i) elsif type == "zoho-analytics" BigSister::ZohoAnalyticsReporter.new(reporter, i) end end
load_reporting(data)
click to toggle source
# File lib/bigsister/configuration.rb, line 51 def load_reporting(data) @reporting = data.fetch("report", []) @reporting.each_with_index { |reporter, i| # Validate reporting type type = reporter.fetch("type", nil) if type.nil? config_error("No report type specified for reporter #{i}") elsif !REPORTER_TYPES.include?(type) config_error("Invalid report type specifeid for reporter #{i}") end @reporters.push(load_reporter(type, reporter, i)) @reporters = @reporters.reject(&:nil?) } end