Class: Worktree::Project
- Inherits:
-
Object
- Object
- Worktree::Project
- Defined in:
- lib/worktree/project.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key) ⇒ Project
constructor
A new instance of Project.
- #root ⇒ Object
Constructor Details
#initialize(key) ⇒ Project
Returns a new instance of Project.
17 18 19 |
# File 'lib/worktree/project.rb', line 17 def initialize(key) @key = key end |
Class Method Details
.project_key_for(branch) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/worktree/project.rb', line 5 def self.project_key_for(branch) project_keys = Worktree::Config.config['projects'].keys return nil if project_keys.empty? re = Regexp.new("^(#{project_keys.join('|')})\-") (branch.match(re) || [])[1] end |
.resolve(branch) ⇒ Object
13 14 15 |
# File 'lib/worktree/project.rb', line 13 def self.resolve(branch) new(project_key_for(branch)) end |
Instance Method Details
#root ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/worktree/project.rb', line 21 def root if @key Worktree::Config.config.dig('projects', @key, 'root').chomp('/') else Dir.pwd end end |