Class: Ace::Git::Worktree::Molecules::ConfigLoader
- Inherits:
-
Object
- Object
- Ace::Git::Worktree::Molecules::ConfigLoader
- Defined in:
- lib/ace/git/worktree/molecules/config_loader.rb
Overview
Configuration loader molecule
Loads and merges worktree configuration using ace-config cascade system. Handles configuration validation and provides access to merged configuration.
Instance Method Summary collapse
-
#config_exists? ⇒ Boolean
Check if configuration exists.
-
#config_files ⇒ Array<String>
Get list of configuration files that would be checked.
-
#initialize(project_root = Dir.pwd) ⇒ ConfigLoader
constructor
Initialize a new ConfigLoader.
-
#load ⇒ WorktreeConfig
Load and merge worktree configuration.
-
#load_without_validation ⇒ WorktreeConfig
Load configuration without validation (for testing).
-
#reset_cache! ⇒ Object
Reset configuration cache.
Constructor Details
#initialize(project_root = Dir.pwd) ⇒ ConfigLoader
Initialize a new ConfigLoader
26 27 28 |
# File 'lib/ace/git/worktree/molecules/config_loader.rb', line 26 def initialize(project_root = Dir.pwd) @project_root = project_root end |
Instance Method Details
#config_exists? ⇒ Boolean
Check if configuration exists
63 64 65 66 |
# File 'lib/ace/git/worktree/molecules/config_loader.rb', line 63 def config_exists? # Check for configuration files in expected locations config_files.each.any? { |file| File.exist?(file) } end |
#config_files ⇒ Array<String>
Get list of configuration files that would be checked
71 72 73 74 75 76 77 |
# File 'lib/ace/git/worktree/molecules/config_loader.rb', line 71 def config_files [ File.join(@project_root, ".ace", "git", "worktree.yml"), File.join(@project_root, ".ace-defaults", "git", "worktree.yml"), File.("~/.ace/git/worktree.yml") ] end |
#load ⇒ WorktreeConfig
Load and merge worktree configuration
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ace/git/worktree/molecules/config_loader.rb', line 39 def load # Load configuration using ace-config cascade config_hash = load_config # Create configuration object config = Models::WorktreeConfig.new(config_hash, @project_root) # Validate configuration validate_config(config) config end |
#load_without_validation ⇒ WorktreeConfig
Load configuration without validation (for testing)
55 56 57 58 |
# File 'lib/ace/git/worktree/molecules/config_loader.rb', line 55 def load_without_validation config_hash = load_config Models::WorktreeConfig.new(config_hash, @project_root) end |
#reset_cache! ⇒ Object
Reset configuration cache
80 81 82 |
# File 'lib/ace/git/worktree/molecules/config_loader.rb', line 80 def reset_cache! @config_hash = nil end |