Class: Dotsync::BaseConfig

Inherits:
Object
  • Object
show all
Includes:
PathUtils
Defined in:
lib/dotsync/config/base_config.rb

Overview

BaseConfig serves as an abstract class to define the structure and validation rules for configuration files in the Dotsync system.

Direct Known Subclasses

PullActionConfig, PushActionConfig

Constant Summary

Constants included from PathUtils

PathUtils::ENV_VARS_COLOR

Instance Method Summary collapse

Methods included from PathUtils

#colorize_env_vars, #expand_env_vars, #extract_env_vars, #path_is_parent_or_same?, #relative_to_absolute, #sanitize_path, #translate_tmp_path

Constructor Details

#initialize(path = Dotsync.config_path) ⇒ BaseConfig

Initialize the BaseConfig with the provided path. Loads the TOML configuration file and validates it. Uses ConfigCache for improved performance.

Parameters:

  • path (String) (defaults to: Dotsync.config_path)

    The file path to the configuration file.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/dotsync/config/base_config.rb', line 14

def initialize(path = Dotsync.config_path)
  absolute_path = File.expand_path(path)

  unless File.exist?(absolute_path)
    raise Dotsync::ConfigError,
      "Config file not found: #{absolute_path}\n\n" \
      "To create a default configuration file, run:\n" \
      "  dotsync setup"
  end

  @config = load_config(absolute_path)
  validate!
end

Instance Method Details

#to_hObject



28
29
30
# File 'lib/dotsync/config/base_config.rb', line 28

def to_h
  @config
end