class Utils::ConfigFile

provide centralized configuration management.
configuration blocks and integrates with various utility components to
configuration settings from multiple sources. It supports DSL-style
This class provides functionality for loading, parsing, and managing
Configuration file manager for Utils library.

def classify(&block)

Returns:
  • (Classify) - a Classify object configured either by the block or with defaults

Parameters:
  • block (Proc) -- optional block to configure the Classify object
def classify(&block)
  if block
    @classify = Classify.new(&block)
  end
  @classify ||= Classify.new
end

def code_comment(&block)

Returns:
  • (Utils::ConfigFile::CodeComment) - a CodeComment configuration instance

Parameters:
  • block (Proc) -- optional block to configure the CodeComment object
def code_comment(&block)
  if block
    @code_comment = CodeComment.new(&block)
  end
  @code_comment ||= CodeComment.new
end

def code_indexer(&block)

Returns:
  • (Utils::ConfigFile::CodeIndexer) - a CodeIndexer configuration instance

Parameters:
  • block (Proc) -- optional block to configure the CodeIndexer object
def code_indexer(&block)
  if block
    @code_indexer = CodeIndexer.new(&block)
  end
  @code_indexer ||= CodeIndexer.new
end

def configure_from_paths(paths = self.class.config_file_paths)

Parameters:
  • paths (Array) -- an array of file paths pointing to configuration files
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)

Returns:
  • (Utils::Discover) - a Discover object configured either with the

Parameters:
  • block (Proc) -- optional block to configure the Discover object
def discover(&block)
  if block
    @discover = Discover.new(&block)
  end
  @discover ||= Discover.new
end

def edit(&block)

Returns:
  • (Edit) - an Edit object configured either by the block or with default settings

Parameters:
  • block (Proc) -- optional block to configure the Edit object
def edit(&block)
  if block
    @edit = Edit.new(&block)
  end
  @edit ||= Edit.new
end

def initialize

initialization tasks for the instance variables and internal state.
This method is called when creating a new object and performs any necessary

The initialize method sets up a new instance of the class.
def initialize
end

def parse(source)

Returns:
  • (Object) - returns self after processing the source code

Parameters:
  • source (String) -- the source code to be interpreted and executed
def parse(source)
  interpret_with_binding source, binding
  self
end

def parse_config_file(config_file_path)

Other tags:
    Note: - The method will output a warning message to standard error if it fails

Raises:
  • (SystemCallError) - if there is an issue reading the configuration file

Returns:
  • (Utils::ConfigFile) - returns self after parsing the configuration file

Parameters:
  • config_file_path (String) -- the path to the configuration file to be parsed
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)

Returns:
  • (Utils::Probe) - a Probe instance configured either by the block

Parameters:
  • block (Proc) -- optional block to configure the Probe instance
def probe(&block)
  if block
    @probe = Probe.new(&block)
  end
  @probe ||= Probe.new
end

def search(&block)

Returns:
  • (Utils::Search) - a Search object configured either by the provided

Parameters:
  • block (Proc) -- optional block to configure the Search object
def search(&block)
  if block
    @search = Search.new(&block)
  end
  @search ||= Search.new
end

def ssh_tunnel(&block)

Returns:
  • (Utils::ConfigFile::SshTunnel) - an SSH tunnel configuration instance

Parameters:
  • block (Proc) -- optional block to configure the SSH tunnel object
def ssh_tunnel(&block)
  if block
    @ssh_tunnel = SshTunnel.new(&block)
  end
  @ssh_tunnel ||= SshTunnel.new
end

def strip_spaces(&block)

Returns:
  • (Utils::StripSpaces) - a configured StripSpaces processor instance

Parameters:
  • block (Proc) -- optional block to customize the strip spaces behavior
def strip_spaces(&block)
  if block
    @strip_spaces = StripSpaces.new(&block)
  end
  @strip_spaces ||= StripSpaces.new
end

def sync_dir(&block)

Returns:
  • (SyncDir) - the SyncDir instance associated with this object
def sync_dir(&block)
  if block
    @sync_dir = SyncDir.new(&block)
  end
  @sync_dir ||= SyncDir.new
end

def to_ruby

Returns:
  • (String) - a Ruby formatted string containing configuration
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