class Utils::ConfigFile
def classify(&block)
def classify(&block) if block @classify = Classify.new(&block) end @classify ||= Classify.new end
def configure_from_paths(paths = self.class.config_file_paths)
def configure_from_paths(paths = self.class.config_file_paths) for config_file_path in paths parse_config_file config_file_path end end
def discover(&block)
def discover(&block) if block @discover = Discover.new(&block) end @discover ||= Discover.new end
def edit(&block)
def edit(&block) if block @edit = Edit.new(&block) end @edit ||= Edit.new end
def initialize
def initialize end
def parse(source)
def parse(source) interpret_with_binding source, binding self end
def parse_config_file(config_file_path)
def parse_config_file(config_file_path) config_file_path = File.expand_path(config_file_path) File.open(config_file_path) do |cf| parse cf.read end self rescue SystemCallError => e $DEBUG and warn "Couldn't read config file "\ "#{config_file_path.inspect}: #{e.class} #{e}" return nil end
def probe(&block)
def probe(&block) if block @probe = Probe.new(&block) end @probe ||= Probe.new end
def scope(&block)
def scope(&block) if block @scope = Scope.new(&block) end @scope ||= Scope.new end
def search(&block)
def search(&block) if block @search = Search.new(&block) end @search ||= Search.new end
def ssh_tunnel(&block)
def ssh_tunnel(&block) if block @ssh_tunnel = SshTunnel.new(&block) end @ssh_tunnel ||= SshTunnel.new end
def strip_spaces(&block)
def strip_spaces(&block) if block @strip_spaces = StripSpaces.new(&block) end @strip_spaces ||= StripSpaces.new end
def to_ruby
def to_ruby result = "# vim: set ft=ruby:\n" for bc in %w[search discover strip_spaces probe ssh_tunnel edit classify] result << "\n" << __send__(bc).to_ruby end result end