Class: Tracker::Jira::Project

Inherits:
Base
  • Object
show all
Defined in:
lib/tracker/jira/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

classes

Constructor Details

#initialize(host = nil, identifier = nil) ⇒ Project

Returns a new instance of Project.



6
7
8
# File 'lib/tracker/jira/project.rb', line 6

def initialize(host=nil, identifier=nil)
  @host, @identifier = host, identifier
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



4
5
6
# File 'lib/tracker/jira/project.rb', line 4

def host
  @host
end

#identifierObject

Returns the value of attribute identifier.



4
5
6
# File 'lib/tracker/jira/project.rb', line 4

def identifier
  @identifier
end

Instance Method Details

#identifier_examplesObject



14
15
16
# File 'lib/tracker/jira/project.rb', line 14

def identifier_examples
  ["DC-420", "PICO-12"]
end

#identifier_regexpObject



10
11
12
# File 'lib/tracker/jira/project.rb', line 10

def identifier_regexp
  /([A-Z]+-[\d]+)/
end

#issue(issue_identifier) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/tracker/jira/project.rb', line 22

def issue(issue_identifier)
  session = @host.
  begin
    issue = session.getIssue(issue_identifier)
    Issue.new("#{@host.uri}/browse/#{issue_identifier}", issue["summary"])
  rescue XMLRPC::FaultException
    # Probably bad issue number
    nil
  end
end

#markup(text) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/tracker/jira/project.rb', line 33

def markup(text)
  text.gsub(identifier_regexp) do |match|
    issue_identifier = $1
    issue = issue(issue_identifier)
    issue ? "<a href=\"#{issue.uri}\">#{issue.summary}</a>" : issue_identifier
  end
end

#uriObject



18
19
20
# File 'lib/tracker/jira/project.rb', line 18

def uri
  "#{@host.uri}/browse/#{@identifier}"
end