Class: Jira::Command::Describe

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ticket) ⇒ Describe

Returns a new instance of Describe.



16
17
18
# File 'lib/jira/commands/describe.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/describe.rb', line 14

def ticket
  @ticket
end

Instance Method Details

#assigneeObject



38
39
40
# File 'lib/jira/commands/describe.rb', line 38

def assignee
  (fields['assignee'] || {})['name'] || 'Unassigned'
end

#errorsObject



34
35
36
# File 'lib/jira/commands/describe.rb', line 34

def errors
  @errors ||= (json['errorMessages'] || []).join('. ')
end

#fieldsObject



50
51
52
# File 'lib/jira/commands/describe.rb', line 50

def fields
  json['fields'] || {}
end

#headerObject



26
27
28
# File 'lib/jira/commands/describe.rb', line 26

def header
  [ 'Ticket', 'Assignee', 'Status', 'Summary' ]
end

#jsonObject



54
55
56
# File 'lib/jira/commands/describe.rb', line 54

def json
  @json ||= api.get "issue/#{ticket}"
end

#rowObject



30
31
32
# File 'lib/jira/commands/describe.rb', line 30

def row
  [ ticket, assignee, status, summary ]
end

#runObject



20
21
22
23
24
# File 'lib/jira/commands/describe.rb', line 20

def run
  return if json.empty?
  return unless errors.empty?
  render_table(header, [row])
end

#statusObject



42
43
44
# File 'lib/jira/commands/describe.rb', line 42

def status
  (fields['status'] || {})['name'] || 'Unknown'
end

#summaryObject



46
47
48
# File 'lib/jira/commands/describe.rb', line 46

def summary
  truncate(json['fields']['summary'], 45)
end