Class: Dev::Jira::Issue

Inherits:
Object show all
Defined in:
lib/firespring_dev_commands/jira/issue.rb

Overview

Contains information and methods representing a Jira issue

Constant Summary collapse

NON_STORY_TYPES =

Issue subtypes which do not map to a story type

['review', 'sub-task', 'code review sub-task', 'pre-deploy sub-task', 'deploy sub-task', 'devops sub-task'].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Issue

Returns a new instance of Issue.



10
11
12
13
14
15
16
17
18
# File 'lib/firespring_dev_commands/jira/issue.rb', line 10

def initialize(data)
  @data = data
  @project = Jira::Project.new(data)
  @id = data.key
  @title = data.summary
  @points = calculate_points(data)
  @assignee = Jira::User.lookup(data.assignee&.accountId)
  @resolved_date = data.resolutiondate
end

Instance Attribute Details

#assigneeObject

Returns the value of attribute assignee.



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

def assignee
  @assignee
end

#dataObject

Returns the value of attribute data.



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

def data
  @data
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#pointsObject

Returns the value of attribute points.



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

def points
  @points
end

#projectObject

Returns the value of attribute project.



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

def project
  @project
end

#resolved_dateObject

Returns the value of attribute resolved_date.



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

def resolved_date
  @resolved_date
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

Instance Method Details

#calculate_points(data) ⇒ Object

Returns the value of the jira points field or 0 if the field is not found



21
22
23
24
25
# File 'lib/firespring_dev_commands/jira/issue.rb', line 21

def calculate_points(data)
  return data.send(Dev::Jira.config.points_field_name).to_i if Dev::Jira.config.points_field_name && data.respond_to?(Dev::Jira.config.points_field_name)

  0
end

#to_sObject

Converts the jira issue object to a string representation



28
29
30
# File 'lib/firespring_dev_commands/jira/issue.rb', line 28

def to_s
  "[#{id}] #{title} (#{points} pts) (resolved #{resolved_date}"
end