Class: Tracker::Jira::JiraProject
- Defined in:
- lib/tracker/jira/project.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
Instance Method Summary collapse
- #identifier_examples ⇒ Object
- #identifier_regexp ⇒ Object
-
#initialize(host = nil, identifier = nil) ⇒ JiraProject
constructor
A new instance of JiraProject.
- #issue(issue_identifier) ⇒ Object
- #markup(text) ⇒ Object
- #uri ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(host = nil, identifier = nil) ⇒ JiraProject
Returns a new instance of JiraProject.
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
#host ⇒ Object
Returns the value of attribute host.
4 5 6 |
# File 'lib/tracker/jira/project.rb', line 4 def host @host end |
#identifier ⇒ Object
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_examples ⇒ Object
14 15 16 |
# File 'lib/tracker/jira/project.rb', line 14 def identifier_examples ["DC-420", "PICO-12"] end |
#identifier_regexp ⇒ Object
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.login 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 |
#uri ⇒ Object
18 19 20 |
# File 'lib/tracker/jira/project.rb', line 18 def uri "#{@host.uri}/browse/#{@identifier}" end |