Class: Tracker::Trac::Project

Inherits:
Base
  • Object
show all
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

Instance Method Summary collapse

Methods included from DigitIssues

#identifier_examples, #identifier_regexp

Methods inherited from Base

classes

Constructor Details

#initialize(uri = nil, svn_path = nil) ⇒ Project

Returns a new instance of Project.



7
8
9
# File 'lib/tracker/trac/project.rb', line 7

def initialize(uri=nil, svn_path=nil)
  @uri, @svn_path = uri, svn_path
end

Instance Attribute Details

#svn_pathObject

Returns the value of attribute svn_path.



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

def svn_path
  @svn_path
end

#uri(path = nil, options = {:type => "overview"}) ⇒ Object

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