Class: Tracker::Trac::Project
- Includes:
- DigitIssues
- Defined in:
- lib/tracker/trac/project.rb
Constant Summary collapse
- OVERVIEW =
"\#{@uri}/log/\#{@svn.path}/\#{path}"
- HTML =
"\#{@uri}/file/\#{@svn.path}/\#{path}?rev=\#{revision}"
- RAW =
"#{HTML}&format=txt"
- DIFF =
"\#{@uri}/changeset/\#{revision}"
- URI_SPECS =
{:overview => OVERVIEW, :raw => RAW, :html => HTML, :diff => DIFF}
Instance Attribute Summary collapse
-
#svn ⇒ Object
readonly
Returns the value of attribute svn.
-
#uri(path = nil, options = {:type => :overview}) ⇒ Object
readonly
This method can mean two things, since this class both implements the ScmWeb and Tracker API If called with no arguments, returns the uri of the project page, otherwise the uri of a file in the scm.
Instance Method Summary collapse
-
#initialize(uri = nil, svn = nil) ⇒ Project
constructor
A new instance of Project.
- #issue(issue_identifier) ⇒ Object
- #markup(text) ⇒ Object
Methods included from DigitIssues
#identifier_examples, #identifier_regexp
Methods inherited from Base
Constructor Details
#initialize(uri = nil, svn = nil) ⇒ Project
Returns a new instance of Project.
7 8 9 |
# File 'lib/tracker/trac/project.rb', line 7 def initialize(uri=nil, svn=nil) @uri, @svn = uri, svn end |
Instance Attribute Details
#svn ⇒ Object (readonly)
Returns the value of attribute svn.
6 7 8 |
# File 'lib/tracker/trac/project.rb', line 6 def svn @svn end |
#uri(path = nil, options = {:type => :overview}) ⇒ Object (readonly)
This method can mean two things, since this class both implements the ScmWeb and Tracker API If called with no arguments, returns the uri of the project page, otherwise the uri of a file in the scm
39 40 41 |
# File 'lib/tracker/trac/project.rb', line 39 def uri @uri end |
Instance Method Details
#issue(issue_identifier) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/tracker/trac/project.rb', line 11 def issue(issue_identifier) issue_uri = "#{@uri}/ticket/#{issue_identifier}" begin html = open(issue_uri) { |data| data.read } summary = html[/Ticket ##{issue_identifier}\s*<\/h1>\s*<h2>([^<]*)<\/h2>/n, 1] Issue.new(issue_uri, summary) rescue OpenURI::HTTPError nil end end |
#markup(text) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/tracker/trac/project.rb', line 22 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 |