Class: Kward::GitWorktreeBinding
- Inherits:
-
Object
- Object
- Kward::GitWorktreeBinding
- Defined in:
- lib/kward/git_worktree_manager.rb
Overview
Durable association between a session tab and a linked Git worktree.
Constant Summary collapse
- FIELDS =
%i[repository_root origin_root path branch base_revision active owned].freeze
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
-
#base_revision ⇒ Object
Returns the value of attribute base_revision.
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#origin_root ⇒ Object
Returns the value of attribute origin_root.
-
#owned ⇒ Object
Returns the value of attribute owned.
-
#path ⇒ Object
Returns the value of attribute path.
-
#repository_root ⇒ Object
Returns the value of attribute repository_root.
Class Method Summary collapse
Instance Method Summary collapse
- #active? ⇒ Boolean
- #descriptor ⇒ Object
-
#initialize(repository_root:, origin_root:, path:, branch:, base_revision:, active: true, owned: true) ⇒ GitWorktreeBinding
constructor
A new instance of GitWorktreeBinding.
Constructor Details
#initialize(repository_root:, origin_root:, path:, branch:, base_revision:, active: true, owned: true) ⇒ GitWorktreeBinding
Returns a new instance of GitWorktreeBinding.
15 16 17 18 19 20 21 22 23 |
# File 'lib/kward/git_worktree_manager.rb', line 15 def initialize(repository_root:, origin_root:, path:, branch:, base_revision:, active: true, owned: true) @repository_root = repository_root.to_s @origin_root = origin_root.to_s @path = path.to_s @branch = branch.to_s @base_revision = base_revision.to_s @active = active != false @owned = owned != false end |
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
13 14 15 |
# File 'lib/kward/git_worktree_manager.rb', line 13 def active @active end |
#base_revision ⇒ Object
Returns the value of attribute base_revision.
13 14 15 |
# File 'lib/kward/git_worktree_manager.rb', line 13 def base_revision @base_revision end |
#branch ⇒ Object
Returns the value of attribute branch.
13 14 15 |
# File 'lib/kward/git_worktree_manager.rb', line 13 def branch @branch end |
#origin_root ⇒ Object
Returns the value of attribute origin_root.
13 14 15 |
# File 'lib/kward/git_worktree_manager.rb', line 13 def origin_root @origin_root end |
#owned ⇒ Object
Returns the value of attribute owned.
13 14 15 |
# File 'lib/kward/git_worktree_manager.rb', line 13 def owned @owned end |
#path ⇒ Object
Returns the value of attribute path.
13 14 15 |
# File 'lib/kward/git_worktree_manager.rb', line 13 def path @path end |
#repository_root ⇒ Object
Returns the value of attribute repository_root.
13 14 15 |
# File 'lib/kward/git_worktree_manager.rb', line 13 def repository_root @repository_root end |
Class Method Details
.from_descriptor(value) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/kward/git_worktree_manager.rb', line 41 def self.from_descriptor(value) data = value.respond_to?(:transform_keys) ? value.transform_keys(&:to_s) : {} required = %w[repository_root origin_root path branch base_revision] return nil unless required.all? { |key| !data[key].to_s.empty? } new( repository_root: data["repository_root"], origin_root: data["origin_root"], path: data["path"], branch: data["branch"], base_revision: data["base_revision"], active: data.fetch("active", true), owned: data.fetch("owned", true) ) end |
Instance Method Details
#active? ⇒ Boolean
25 26 27 |
# File 'lib/kward/git_worktree_manager.rb', line 25 def active? active == true end |
#descriptor ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/kward/git_worktree_manager.rb', line 29 def descriptor { "repository_root" => repository_root, "origin_root" => origin_root, "path" => path, "branch" => branch, "base_revision" => base_revision, "active" => active?, "owned" => owned != false } end |