Class: Sxn::Config::ConfigDiscovery
- Inherits:
-
Object
- Object
- Sxn::Config::ConfigDiscovery
- Defined in:
- lib/sxn/config/config_discovery.rb
Overview
Handles hierarchical configuration discovery and loading
Configuration precedence (highest to lowest):
-
Command-line flags
-
Environment variables (SXN_*)
-
Local project config (.sxn/config.yml)
-
Workspace config (.sxn-workspace/config.yml)
-
Global user config (~/.sxn/config.yml)
-
System defaults
Constant Summary collapse
- CONFIG_FILE_NAME =
"config.yml"- LOCAL_CONFIG_DIR =
".sxn"- WORKSPACE_CONFIG_DIR =
".sxn-workspace"- GLOBAL_CONFIG_DIR =
File.("~/.sxn")
- ENV_PREFIX =
"SXN_"
Instance Attribute Summary collapse
-
#start_directory ⇒ Object
readonly
Returns the value of attribute start_directory.
Instance Method Summary collapse
-
#discover_config(cli_options = {}) ⇒ Hash
Discover and load configuration from all sources.
-
#find_config_files ⇒ Array<String>
Find all configuration files in the hierarchy.
-
#initialize(start_directory = Dir.pwd) ⇒ ConfigDiscovery
constructor
A new instance of ConfigDiscovery.
Constructor Details
#initialize(start_directory = Dir.pwd) ⇒ ConfigDiscovery
Returns a new instance of ConfigDiscovery.
26 27 28 |
# File 'lib/sxn/config/config_discovery.rb', line 26 def initialize(start_directory = Dir.pwd) @start_directory = Pathname.new(start_directory). end |
Instance Attribute Details
#start_directory ⇒ Object (readonly)
Returns the value of attribute start_directory.
24 25 26 |
# File 'lib/sxn/config/config_discovery.rb', line 24 def start_directory @start_directory end |
Instance Method Details
#discover_config(cli_options = {}) ⇒ Hash
Discover and load configuration from all sources
33 34 35 36 |
# File 'lib/sxn/config/config_discovery.rb', line 33 def discover_config( = {}) config_sources = load_all_configs merge_configs(config_sources, ) end |
#find_config_files ⇒ Array<String>
Find all configuration files in the hierarchy
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/sxn/config/config_discovery.rb', line 40 def find_config_files config_files = [] # Local project config (.sxn/config.yml) local_config = find_local_config config_files << local_config if local_config # Workspace config (.sxn-workspace/config.yml) workspace_config = find_workspace_config config_files << workspace_config if workspace_config # Global user config (~/.sxn/config.yml) global_config = find_global_config config_files << global_config if global_config config_files end |