Class: Apadmi::Grout::Issue

Inherits:
Struct
  • Object
show all
Defined in:
lib/apadmi/grout/models/issue.rb

Overview

A generic issue type wrapping up the underlying JIRA & ADO object

Constant Summary collapse

UNCLASSIFIED_ISSUE_TYPE =

Issue type string used for fallback issues created from commit messages when the ticket was not found in the board.

"Unclassified"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#issue_typeString

Returns the value of attribute issue_type

Returns:

  • (String)

    the current value of issue_type



13
14
15
# File 'lib/apadmi/grout/models/issue.rb', line 13

def issue_type
  @issue_type
end

#keyString

Returns the value of attribute key

Returns:

  • (String)

    the current value of key



13
14
15
# File 'lib/apadmi/grout/models/issue.rb', line 13

def key
  @key
end

#raw_objectJIRA::Resource::Issue, ...

Returns the value of attribute raw_object

Returns:

  • (JIRA::Resource::Issue, Hash, nil)

    the current value of raw_object



13
14
15
# File 'lib/apadmi/grout/models/issue.rb', line 13

def raw_object
  @raw_object
end

#statusString

Returns the value of attribute status

Returns:

  • (String)

    the current value of status



13
14
15
# File 'lib/apadmi/grout/models/issue.rb', line 13

def status
  @status
end

#summaryString

Returns the value of attribute summary

Returns:

  • (String)

    the current value of summary



13
14
15
# File 'lib/apadmi/grout/models/issue.rb', line 13

def summary
  @summary
end

#urlString

Returns the value of attribute url

Returns:

  • (String)

    the current value of url



13
14
15
# File 'lib/apadmi/grout/models/issue.rb', line 13

def url
  @url
end

Class Method Details

.from_ado_hash(hash) ⇒ Apadmi::Grout::Issue



23
24
25
26
27
28
29
30
31
32
# File 'lib/apadmi/grout/models/issue.rb', line 23

def self.from_ado_hash(hash)
  Issue.new(
    hash["id"].to_s,
    hash["fields"]["System.Title"],
    hash["fields"]["System.State"],
    hash["fields"]["System.WorkItemType"],
    hash["url"],
    hash
  )
end

.from_ado_hashes(hashes) ⇒ Array<Apadmi::Grout::Issue>

Returns:



35
36
37
# File 'lib/apadmi/grout/models/issue.rb', line 35

def self.from_ado_hashes(hashes)
  hashes.map { |h| Issue.from_ado_hash(h) }
end

.from_jira_issue(issue, base_url) ⇒ Apadmi::Grout::Issue

Parameters:

  • issue (JIRA::Resource::Issue)

Returns:



41
42
43
44
45
46
47
48
49
50
# File 'lib/apadmi/grout/models/issue.rb', line 41

def self.from_jira_issue(issue, base_url)
  Issue.new(
    issue.key,
    issue.summary,
    issue.status.name,
    issue.issuetype.name,
    "#{base_url}/browse/#{issue.key}",
    issue
  )
end

.from_jira_issues(issues, base_url) ⇒ Array<Apadmi::Grout::Issue>

Returns:



53
54
55
# File 'lib/apadmi/grout/models/issue.rb', line 53

def self.from_jira_issues(issues, base_url)
  issues.map { |i| Issue.from_jira_issue(i, base_url) }
end

.unclassified(key, summary) ⇒ Apadmi::Grout::Issue

Creates a fallback issue from a commit message when the ticket ID could not be found in the board.

Parameters:

  • key (String)

    the ticket ID as extracted from the commit (e.g. "GROUT-999")

  • summary (String)

    the first line of the commit message

Returns:



18
19
20
# File 'lib/apadmi/grout/models/issue.rb', line 18

def self.unclassified(key, summary)
  Issue.new(key, summary, "Unknown", Issue::UNCLASSIFIED_ISSUE_TYPE, "", nil)
end