Class: Gitgut::Jira::Ticket

Inherits:
Object
  • Object
show all
Defined in:
lib/gitgut/jira.rb

Overview

A JIRA ticket

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ Ticket

Returns a new instance of Ticket.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/gitgut/jira.rb', line 10

def initialize(payload)
  @key = payload['key']
  # TODO: use Mash?
  if payload['fields']['assignee']
    @assignee = payload['fields']['assignee']['name']
    @assignee_display_name = payload['fields']['assignee']['displayName']
  end

  if payload['fields']['status']
    @status = payload['fields']['status']['name']
  end
end

Instance Attribute Details

#assigneeObject (readonly)

Returns the value of attribute assignee.



8
9
10
# File 'lib/gitgut/jira.rb', line 8

def assignee
  @assignee
end

#keyObject (readonly)

Returns the value of attribute key.



8
9
10
# File 'lib/gitgut/jira.rb', line 8

def key
  @key
end

#statusObject (readonly)

Returns the value of attribute status.



8
9
10
# File 'lib/gitgut/jira.rb', line 8

def status
  @status
end

Instance Method Details

#assigned_to_me?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/gitgut/jira.rb', line 23

def assigned_to_me?
  assignee == Settings.jira.username
end

#assignee_initialsObject



27
28
29
30
31
# File 'lib/gitgut/jira.rb', line 27

def assignee_initials
  return '' unless assignee
  words = @assignee_display_name.split(/ +/)
  "#{words.first} #{words.last[0]}."
end

#closed?Boolean

Returns:

  • (Boolean)


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

def closed?
  status == 'Closed'
end

#colorObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/gitgut/jira.rb', line 53

def color
  return :light_blue if assigned_to_me?
  case status
  when 'In Functional Review', 'In Review'
    :white
  when 'In Development', 'Open'
    :light_blue
  when 'Ready for Release', 'Released'
    :green
  when 'Closed'
    :light_black
  else
    :white
  end
end

#done?Boolean

Returns:

  • (Boolean)


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

def done?
  ready_for_release? || released? || closed?
end

#in_review?Boolean

Returns:

  • (Boolean)


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

def in_review?
  status == 'In Review'
end

#ready_for_release?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/gitgut/jira.rb', line 33

def ready_for_release?
  status == 'Ready for Release'
end

#released?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/gitgut/jira.rb', line 49

def released?
  status == 'Released'
end