Class: WorktreeManager::ConfigManager
- Inherits:
-
Object
- Object
- WorktreeManager::ConfigManager
- Defined in:
- lib/worktree_manager/config_manager.rb
Constant Summary collapse
- DEFAULT_CONFIG_FILES =
[ '.worktree.yml', '.git/.worktree.yml' ].freeze
- DEFAULT_WORKTREES_DIR =
'../'
- DEFAULT_MAIN_BRANCH_NAME =
'main'
Instance Method Summary collapse
- #hooks ⇒ Object
-
#initialize(repository_path = '.') ⇒ ConfigManager
constructor
A new instance of ConfigManager.
- #main_branch_name ⇒ Object
- #resolve_worktree_path(name_or_path) ⇒ Object
- #worktrees_dir ⇒ Object
Constructor Details
#initialize(repository_path = '.') ⇒ ConfigManager
Returns a new instance of ConfigManager.
13 14 15 16 |
# File 'lib/worktree_manager/config_manager.rb', line 13 def initialize(repository_path = '.') @repository_path = File.(repository_path) @config = load_config end |
Instance Method Details
#hooks ⇒ Object
22 23 24 |
# File 'lib/worktree_manager/config_manager.rb', line 22 def hooks @config['hooks'] || {} end |
#main_branch_name ⇒ Object
26 27 28 |
# File 'lib/worktree_manager/config_manager.rb', line 26 def main_branch_name @config['main_branch_name'] || DEFAULT_MAIN_BRANCH_NAME end |
#resolve_worktree_path(name_or_path) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/worktree_manager/config_manager.rb', line 30 def resolve_worktree_path(name_or_path) # If it's an absolute path, return as is return name_or_path if name_or_path.start_with?('/') # If it contains a path separator, treat it as a relative path return File.(name_or_path, @repository_path) if name_or_path.include?('/') # Otherwise, use worktrees_dir as the base base_dir = File.(worktrees_dir, @repository_path) File.join(base_dir, name_or_path) end |
#worktrees_dir ⇒ Object
18 19 20 |
# File 'lib/worktree_manager/config_manager.rb', line 18 def worktrees_dir @config['worktrees_dir'] || DEFAULT_WORKTREES_DIR end |