Class: TrelloFlow::Branch
- Inherits:
-
Object
- Object
- TrelloFlow::Branch
- Defined in:
- lib/trello_flow/branch.rb
Class Method Summary collapse
Instance Method Summary collapse
- #checkout ⇒ Object
- #finish_current_card ⇒ Object
-
#initialize(name) ⇒ Branch
constructor
A new instance of Branch.
- #open_pull_request ⇒ Object
- #open_trello(user) ⇒ Object
- #push ⇒ Object
- #target ⇒ Object
Constructor Details
#initialize(name) ⇒ Branch
Returns a new instance of Branch.
6 7 8 |
# File 'lib/trello_flow/branch.rb', line 6 def initialize(name) @name = name end |
Class Method Details
.current ⇒ Object
10 11 12 |
# File 'lib/trello_flow/branch.rb', line 10 def self.current new Cli.read("git rev-parse --abbrev-ref HEAD") end |
.from_card(card) ⇒ Object
14 15 16 |
# File 'lib/trello_flow/branch.rb', line 14 def self.from_card(card) new("#{current.target}.#{card.to_param}.#{card.id}") end |
Instance Method Details
#checkout ⇒ Object
18 19 20 |
# File 'lib/trello_flow/branch.rb', line 18 def checkout Cli.run "git checkout #{name} >/dev/null 2>&1 || git checkout -b #{name}" end |
#finish_current_card ⇒ Object
30 31 32 |
# File 'lib/trello_flow/branch.rb', line 30 def finish_current_card current_card.finish end |
#open_pull_request ⇒ Object
26 27 28 |
# File 'lib/trello_flow/branch.rb', line 26 def open_pull_request PullRequest.new(current_card, from: name, target: target).open end |
#open_trello(user) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/trello_flow/branch.rb', line 34 def open_trello(user) if current_card Cli.open_url current_card.url else Cli.open_url "https://trello.com/#{user.username}/cards" end end |
#push ⇒ Object
22 23 24 |
# File 'lib/trello_flow/branch.rb', line 22 def push Cli.run "git push origin #{name} -u" end |
#target ⇒ Object
42 43 44 |
# File 'lib/trello_flow/branch.rb', line 42 def target name.split('.').first end |