class Checklister::ConfigurationFile
Attributes
services[R]
Public Class Methods
new(path)
click to toggle source
# File lib/checklister/configuration_file.rb, line 7 def initialize(path) @path = path @file = load_file @services = load_services end
Public Instance Methods
add_service(service)
click to toggle source
# File lib/checklister/configuration_file.rb, line 17 def add_service(service) symbolized_service = Checklister::Sanitizer.symbolize(service) remove_service symbolized_service[:endpoint] @services << symbolized_service end
exist?()
click to toggle source
# File lib/checklister/configuration_file.rb, line 13 def exist? File.exist?(@path) end
persist()
click to toggle source
# File lib/checklister/configuration_file.rb, line 27 def persist File.open(@path, "w") do |f| namespaced_services = { services: @services } f.write namespaced_services.to_yaml end reload! end
reload!()
click to toggle source
# File lib/checklister/configuration_file.rb, line 35 def reload! @file = load_file @services = load_services end
remove_service(endpoint)
click to toggle source
# File lib/checklister/configuration_file.rb, line 23 def remove_service(endpoint) @services.delete_if { |h| h[:endpoint].to_s == endpoint.to_s } end
Private Instance Methods
load_file()
click to toggle source
# File lib/checklister/configuration_file.rb, line 42 def load_file if exist? Checklister::Sanitizer.symbolize YAML::load_file(@path) else {} end end
load_services()
click to toggle source
# File lib/checklister/configuration_file.rb, line 50 def load_services if @file && @file[:services] @file[:services] else [] end end