Class: ExternalIssue

Inherits:
Object
  • Object
show all
Includes:
Referable
Defined in:
app/models/external_issue.rb

Direct Known Subclasses

JiraIssue

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(issue_identifier, project) ⇒ ExternalIssue

Returns a new instance of ExternalIssue


4
5
6
# File 'app/models/external_issue.rb', line 4

def initialize(issue_identifier, project)
  @issue_identifier, @project = issue_identifier, project
end

Class Method Details

.reference_patternObject

Pattern used to extract `JIRA-123` issue references from text


33
34
35
# File 'app/models/external_issue.rb', line 33

def self.reference_pattern
  @reference_pattern ||= %r{(?<issue>\b([A-Z][A-Z0-9_]+-)\d+)}
end

Instance Method Details

#==(other) ⇒ Object


24
25
26
# File 'app/models/external_issue.rb', line 24

def ==(other)
  other.is_a?(self.class) && (to_s == other.to_s)
end

#idObject


12
13
14
# File 'app/models/external_issue.rb', line 12

def id
  @issue_identifier.to_s
end

#iidObject


16
17
18
# File 'app/models/external_issue.rb', line 16

def iid
  @issue_identifier.to_s
end

#projectObject


28
29
30
# File 'app/models/external_issue.rb', line 28

def project
  @project
end

41
42
43
44
45
# File 'app/models/external_issue.rb', line 41

def reference_link_text(from_project = nil)
  return "##{id}" if /^\d+$/.match(id)

  id
end

#titleObject


20
21
22
# File 'app/models/external_issue.rb', line 20

def title
  "External Issue #{self}"
end

#to_reference(_from_project = nil) ⇒ Object


37
38
39
# File 'app/models/external_issue.rb', line 37

def to_reference(_from_project = nil)
  id
end

#to_sObject


8
9
10
# File 'app/models/external_issue.rb', line 8

def to_s
  @issue_identifier.to_s
end