class Jira::Command::Rename

Attributes

options[RW]
ticket[RW]

Public Class Methods

new(ticket, options) click to toggle source
# File lib/jira/commands/rename.rb, line 17
def initialize(ticket, options)
  self.ticket = ticket
  self.options = options
end

Public Instance Methods

on_failure() click to toggle source
# File lib/jira/commands/rename.rb, line 43
def on_failure
  ->{ puts "No change made to ticket #{ticket}." }
end
on_success() click to toggle source
# File lib/jira/commands/rename.rb, line 39
def on_success
  ->{ puts "Successfully updated ticket #{ticket}'s summary." }
end
params() click to toggle source
# File lib/jira/commands/rename.rb, line 31
def params
  {
    fields: {
      summary: summary
    }
  }
end
run() click to toggle source
# File lib/jira/commands/rename.rb, line 22
def run
  return if ticket.empty?
  return if summary.empty?
  api.patch "issue/#{ticket}",
    params:  params,
    success: on_success,
    failure: on_failure
end
summary() click to toggle source
# File lib/jira/commands/rename.rb, line 47
def summary
  @summary ||= options['summary'] || io.ask("New summary for ticket #{ticket}:", default: '')
end