Class: Jira::Command::Rename

Inherits:
Base
  • Object
show all
Defined in:
lib/jira/commands/rename.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ticket) ⇒ Rename

Returns a new instance of Rename.



16
17
18
# File 'lib/jira/commands/rename.rb', line 16

def initialize(ticket)
  self.ticket = ticket
end

Instance Attribute Details

#ticketObject

Returns the value of attribute ticket.



14
15
16
# File 'lib/jira/commands/rename.rb', line 14

def ticket
  @ticket
end

Instance Method Details

#on_failureObject



41
42
43
# File 'lib/jira/commands/rename.rb', line 41

def on_failure
  ->{ puts "No change made to ticket #{ticket}." }
end

#on_successObject



37
38
39
# File 'lib/jira/commands/rename.rb', line 37

def on_success
  ->{ puts "Successfully updated ticket #{ticket}'s summary." }
end

#paramsObject



29
30
31
32
33
34
35
# File 'lib/jira/commands/rename.rb', line 29

def params
  {
    fields: {
      summary: summary
    }
  }
end

#runObject



20
21
22
23
24
25
26
27
# File 'lib/jira/commands/rename.rb', line 20

def run
  return if ticket.empty?
  return if summary.empty?
  api.patch "issue/#{ticket}",
    params:  params,
    success: on_success,
    failure: on_failure
end

#summaryObject



45
46
47
# File 'lib/jira/commands/rename.rb', line 45

def summary
  @summary ||= io.ask("New summary for ticket #{ticket}:", default: '')
end