Class: GitChain::Runner
- Inherits:
-
Object
- Object
- GitChain::Runner
- Defined in:
- lib/git_chain/runner.rb
Instance Attribute Summary collapse
-
#chain ⇒ Object
readonly
Returns the value of attribute chain.
-
#git ⇒ Object
readonly
Returns the value of attribute git.
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
- #add(parent:, old_base: nil) ⇒ Object
- #call(command, *args) ⇒ Object
-
#initialize(path:) ⇒ Runner
constructor
A new instance of Runner.
- #list ⇒ Object
- #rebase(sub_command: nil) ⇒ Object
- #show(branch: nil) ⇒ Object
Constructor Details
Instance Attribute Details
#chain ⇒ Object (readonly)
Returns the value of attribute chain.
3 4 5 |
# File 'lib/git_chain/runner.rb', line 3 def chain @chain end |
#git ⇒ Object (readonly)
Returns the value of attribute git.
3 4 5 |
# File 'lib/git_chain/runner.rb', line 3 def git @git end |
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
3 4 5 |
# File 'lib/git_chain/runner.rb', line 3 def storage @storage end |
Instance Method Details
#add(parent:, old_base: nil) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/git_chain/runner.rb', line 37 def add(parent:, old_base: nil) chain.mark_branch_as_dependent( child: git.current_branch, parent: parent, old_base: old_base ) end |
#call(command, *args) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/git_chain/runner.rb', line 10 def call(command, *args) case command when 'show' show(branch: args[0]) when 'list' list() when 'add' add(parent: args[0], old_base: args[1]) when 'rebase' rebase(sub_command: args.first) else raise "Unknown Command: #{command}" end end |
#list ⇒ Object
33 34 35 |
# File 'lib/git_chain/runner.rb', line 33 def list storage.print end |
#rebase(sub_command: nil) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/git_chain/runner.rb', line 45 def rebase(sub_command: nil) if sub_command == 'all' chain.rebase_all(git.current_branch) else chain.rebase(git.current_branch) end end |
#show(branch: nil) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/git_chain/runner.rb', line 25 def show(branch: nil) if branch storage.print_branch(branch: branch) else storage.print_branch(branch: git.current_branch) end end |