meta_project 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,5 +1,17 @@
1
1
  = MetaProject Changelog
2
2
 
3
+ == Version 0.4.5
4
+
5
+ This version improves the MetaProject::ScmWeb::Pathname support, allowing online contents in scm web interfaces to be navigated and read in a similar fashion to the standard library's Pathname class.
6
+
7
+ * Better support for Pathname. children, directory? and open now supported.
8
+ * Fixed some bugs for JIRA support.
9
+ * Improved Pathname settings for Codehaus, SourceForge, Trac and RubyForge.
10
+ * Pathname now takes a revision argument in the constructor.
11
+ * Moved ScmWeb to ScmWeb::Browser.
12
+ * Added a subset of the Ruby stlib Pathname API to ScmWeb.
13
+ * Added a String extension for dealing with trailing slashes in URLs.
14
+
3
15
  == Version 0.4.4
4
16
 
5
17
  This release introduces a new Domain Specific Language (DSL) for SCM commit messages similar to Trac's post-commit hook for updating tickets.
data/Rakefile CHANGED
@@ -24,7 +24,7 @@ require 'rake/rdoctask'
24
24
  #
25
25
  # REMEMBER TO KEEP PKG_VERSION IN SYNC WITH THE CHANGES FILE!
26
26
  PKG_NAME = "meta_project"
27
- PKG_VERSION = "0.4.4"
27
+ PKG_VERSION = "0.4.5"
28
28
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
29
29
  PKG_FILES = FileList[
30
30
  '[A-Z]*',
@@ -0,0 +1,5 @@
1
+ class String
2
+ def strip_trailing_slash
3
+ self[-1..-1] == "/" ? self[0..-2] : self
4
+ end
5
+ end
@@ -3,22 +3,25 @@ module MetaProject
3
3
  module Codehaus
4
4
  class CodehausProjectSvn < Base
5
5
 
6
- def initialize(project_id, svn_path, jira_id)
7
- @name = project_id
8
- @scm = RSCM::Subversion.new("svn://svn.#{project_id}.codehaus.org/#{project_id}/scm/#{svn_path}", svn_path)
6
+ def initialize(unix_name, svn_path, jira_id)
7
+ @unix_name = unix_name
8
+ @scm = RSCM::Subversion.new("svn://svn.#{unix_name}.codehaus.org/#{unix_name}/scm/#{svn_path}", svn_path)
9
9
  @tracker = ::MetaProject::Tracker::Jira::JiraTracker.new("http://jira.codehaus.org", jira_id)
10
10
 
11
- overview = "http://svn.#{project_id}.codehaus.org/#{svn_path}/"
11
+ overview = "http://svn.#{unix_name}.codehaus.org/#{svn_path}/"
12
12
  history = "#{overview}\#{path}"
13
13
  raw = "#{history}?rev=\#{revision}"
14
14
  html = "#{raw}&view=markup"
15
15
  # http://svn.picocontainer.codehaus.org/java/picocontainer/trunk/container/project.xml?r1=2220&r2=2234&p1=java/picocontainer/trunk/container/project.xml&p2=java/picocontainer/trunk/container/project.xml
16
16
  diff = "#{history}?r1=\#{previous_revision}&r2=\#{revision}&p1=#{svn_path}/\#{path}&p2=#{svn_path}/\#{path}"
17
- @scm_web = ScmWeb.new(overview, history, raw, html, diff)
17
+ child_dirs_pattern = /<a name="([^"]+)" href="([^"]+)">[\r\n\s]+<img src="\/icons\/small\/dir.gif"/
18
+ child_files_pattern = /<a href="[^"]+\/([^\?]+)\?rev=([\d]+)&view=auto">/
19
+
20
+ @scm_web = ScmWeb::Browser.new(overview, history, raw, html, diff, child_dirs_pattern, child_files_pattern)
18
21
  end
19
22
 
20
23
  def home_page
21
- "http://#{@project_id}.codehaus.org/"
24
+ "http://#{@unix_name}.codehaus.org/"
22
25
  end
23
26
 
24
27
  end
@@ -5,15 +5,40 @@ module MetaProject
5
5
 
6
6
  def initialize(trac_base_url, svn_root_url, svn_path)
7
7
  @trac_base_url = trac_base_url
8
+ @svn_path = svn_path
8
9
  @scm = RSCM::Subversion.new("#{svn_root_url}#{svn_path}", svn_path)
9
- @tracker = ::MetaProject::Tracker::Trac::TracTracker.new(trac_base_url)
10
+ @tracker = ::MetaProject::Tracker::Trac::TracTracker.new(@trac_base_url)
11
+ end
12
+
13
+ def scm_web
14
+ unless @scm_web
15
+ overview = "#{@trac_base_url}/browser/#{@svn_path}/"
16
+ diff = "#{@trac_base_url}/changeset/\#{revision}"
17
+
18
+ front_page = open(@trac_base_url).read
19
+ if(front_page =~ /<strong>Trac ([\d\.]+)\w*<\/strong>/)
20
+
21
+ version = $1
22
+ version = "#{version}.0" if version =~ /[\d]+\.[\d]+\.$/
23
+ version = version.gsub(/\./, "").to_i
24
+
25
+ if(version >= 90)
26
+ history = "#{@trac_base_url}/browser/#{@svn_path}/\#{path}"
27
+ html = "#{@trac_base_url}/browser/#{@svn_path}/\#{path}?rev=\#{revision}"
28
+ raw = "#{@trac_base_url}/browser/#{@svn_path}/\#{path}?rev=\#{revision}&format=txt"
29
+ else
30
+ history = "#{@trac_base_url}/log/#{@svn_path}/\#{path}"
31
+ html = "#{@trac_base_url}/file/#{@svn_path}/\#{path}?rev=\#{revision}"
32
+ raw = "#{@trac_base_url}/file/#{@svn_path}/\#{path}?rev=\#{revision}&format=txt"
33
+ end
34
+ child_dirs_pattern = /title="Browse Directory" href="[^"]+">([^<]+)<\/a>/
35
+ child_files_pattern = /title="View File" href="[^"]+">([^<]+)<\/a>/
36
+
37
+ @scm_web = ScmWeb::Browser.new(overview, history, raw, html, diff, child_dirs_pattern, child_files_pattern)
38
+ end
39
+ end
10
40
 
11
- overview = "#{trac_base_url}/browser/#{svn_path}/"
12
- history = "#{trac_base_url}/log/#{svn_path}/\#{path}"
13
- html = "#{trac_base_url}/file/#{svn_path}/\#{path}?rev=\#{revision}"
14
- raw = "#{html}&format=txt"
15
- diff = "#{trac_base_url}/changeset/\#{revision}"
16
- @scm_web = ScmWeb.new(overview, history, raw, html, diff)
41
+ @scm_web
17
42
  end
18
43
 
19
44
  def home_page
@@ -31,7 +31,10 @@ module MetaProject
31
31
  html = "#{view_cvs}#{path_cvs_root_rev}&content-type=text/vnd.viewcvs-markup"
32
32
  diff = "#{view_cvs}#{mod}/\#{path}.diff#{cvsroot}&r1=\#{previous_revision}&r2=\#{revision}"
33
33
 
34
- ScmWeb.new(overview, history, raw, html, diff)
34
+ child_dirs_pattern = /href="([^\?]*\/)\?cvsroot=#{unix_name}">/
35
+ child_files_pattern = /href="([^\?^\/]*)\?cvsroot=#{unix_name}">/
36
+
37
+ ScmWeb::Browser.new(overview, history, raw, html, diff, child_dirs_pattern, child_files_pattern)
35
38
  end
36
39
 
37
40
  # Regexp used to find projects' home page
@@ -31,7 +31,11 @@ module MetaProject
31
31
  html = "#{history}?#{rev}&view=markup"
32
32
  diff = "#{history}?r1=\#{previous_revision}&r2=\#{revision}"
33
33
 
34
- ScmWeb.new(overview, history, raw, html, diff)
34
+
35
+ child_dirs_pattern = /<img src="\/icons\/small\/dir.gif"\s+alt="\(dir\)"\s+border=0\s+width=16\s+height=16>[\r\n\s]*([^\/]+)\/<\/a>/
36
+ child_files_pattern = /href="[^\?]+\/([^\?]+)\?rev=([^&]+)&view=log">/
37
+
38
+ ScmWeb::Browser.new(overview, history, raw, html, diff, child_dirs_pattern, child_files_pattern)
35
39
  end
36
40
 
37
41
  # Regexp used to find projects' home page
@@ -0,0 +1,77 @@
1
+ module MetaProject
2
+ module ScmWeb
3
+
4
+ # A Browser instance is capable of generating URLs to various files and diffs
5
+ # in an online scm web interface.
6
+ #
7
+ class Browser
8
+
9
+ attr_accessor :overview_spec, :history_spec, :raw_spec, :html_spec, :diff_spec
10
+
11
+ # The variables to use in +uri_specs+ are:
12
+ #
13
+ # * path
14
+ # * revision
15
+ # * previous_revision
16
+ #
17
+ def initialize(overview_spec=nil, history_spec=nil, raw_spec=nil, html_spec=nil, diff_spec=nil, child_dirs_pattern=nil, child_files_pattern=nil)
18
+ @overview_spec, @history_spec, @raw_spec, @html_spec, @diff_spec, @child_dirs_pattern, @child_files_pattern = overview_spec, history_spec, raw_spec, html_spec, diff_spec, child_dirs_pattern, child_files_pattern
19
+ end
20
+
21
+ # TODO: deprecate this and use root.cleanpath instead
22
+ def overview
23
+ file_uri(nil, nil, @overview_spec)
24
+ end
25
+
26
+ def history(path)
27
+ file_uri(path, nil, @history_spec)
28
+ end
29
+
30
+ def raw(path, revision)
31
+ file_uri(path, revision, @raw_spec)
32
+ end
33
+
34
+ def html(path, revision)
35
+ file_uri(path, revision, @html_spec)
36
+ end
37
+
38
+ def diff(path, revision, previous_revision)
39
+ file_uri(path, revision, @diff_spec, previous_revision)
40
+ end
41
+
42
+ # The regexp used to determine child directories of a directory
43
+ def child_dirs_pattern
44
+ @child_dirs_pattern
45
+ end
46
+
47
+ # The regexp used to determine child files of a directory
48
+ def child_files_pattern
49
+ @child_files_pattern
50
+ end
51
+
52
+ # Returns a Pathname representing the root directory of this browser.
53
+ # NOTE: The root of the browser may be at a lower level than
54
+ # the toplevel of the online scm web interface; It depends
55
+ # on the configuration of this instance (overview).
56
+ def root
57
+ Pathname.new(self, "", nil, true)
58
+ end
59
+
60
+ private
61
+
62
+ # Returns the file URI for +path+. Valid options are:
63
+ #
64
+ # * :type => ["overview"|"html"|"diff"|"raw"]
65
+ # * :revision
66
+ # * :previous_revision
67
+ def file_uri(path="", revision=nil, spec=@overview_spec, previous_revision=nil)
68
+ begin
69
+ eval("\"#{spec}\"", binding)
70
+ rescue NameError
71
+ raise "Couldn't evaluate '#{spec}'"
72
+ end
73
+ end
74
+
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,70 @@
1
+ require 'open-uri'
2
+
3
+ module MetaProject
4
+ module ScmWeb
5
+ # A subset of the
6
+ # <a href="http://www.ruby-doc.org/stdlib/libdoc/pathname/rdoc/index.html">Pathname</a>
7
+ # API which is suitable for slurping SCM contents off the web.
8
+ #
9
+ class Pathname
10
+
11
+ def initialize(browser, path_from_root, revision_identifier, directory)
12
+ @browser, @path_from_root, @revision_identifier, @directory = browser, path_from_root, revision_identifier, directory
13
+ end
14
+
15
+ # The relative path from the root of the browser instance
16
+ def path_from_root
17
+ @path_from_root
18
+ end
19
+
20
+ # The revision of this file or nil if this is a directory
21
+ def revision_identifier
22
+ @revision_identifier
23
+ end
24
+
25
+ # Returns a Pathname at the +relative_path+ from this directory.
26
+ # Note: This only works if this instance is a +directory?+
27
+ def pathname(relative_path, revision_identifier, directory)
28
+ child_path_from_root = (@path_from_root == "") ? relative_path : "#{@path_from_root}#{relative_path}"
29
+ Pathname.new(@browser, child_path_from_root, revision_identifier, directory)
30
+ end
31
+
32
+ # Stlib Pathname methods
33
+
34
+ # Returns the full path on the web (to the history page)
35
+ def cleanpath
36
+ @browser.history(@path_from_root)
37
+ end
38
+
39
+ def children
40
+ result = []
41
+ html = Kernel.open(cleanpath).read
42
+
43
+ html.scan(@browser.child_dirs_pattern) do |child_path_rev_array|
44
+ relative_child_path = child_path_rev_array[0]
45
+ child_revision_identifier = child_path_rev_array[1] # nil for most browsers
46
+ #puts "DIR:#{relative_child_path}:#{child_revision_identifier}"
47
+ result << pathname(relative_child_path, child_revision_identifier, true)
48
+ end
49
+
50
+ html.scan(@browser.child_files_pattern) do |child_path_rev_array|
51
+ relative_child_path = child_path_rev_array[0]
52
+ child_revision_identifier = child_path_rev_array[1]
53
+ #puts "FILE:#{relative_child_path}:#{child_revision_identifier}"
54
+ result << pathname(relative_child_path, child_revision_identifier, false)
55
+ end
56
+ result
57
+ end
58
+
59
+ def open(&block)
60
+ url = @browser.raw(@path_from_root, revision_identifier)
61
+ # open-uri's open
62
+ Kernel.open(url, &block)
63
+ end
64
+
65
+ def directory?
66
+ @directory
67
+ end
68
+ end
69
+ end
70
+ end
@@ -1,55 +1,2 @@
1
- module MetaProject
2
-
3
- # An ScmWeb instance is capable of generating URLs to various files and diffs
4
- # in an online scm web interface.
5
- class ScmWeb
6
-
7
- attr_accessor :overview_spec, :history_spec, :raw_spec, :html_spec, :diff_spec
8
-
9
- # The variables to use in +uri_specs+ are:
10
- #
11
- # * path
12
- # * revision
13
- # * previous_revision
14
- #
15
- def initialize(overview_spec=nil, history_spec=nil, raw_spec=nil, html_spec=nil, diff_spec=nil)
16
- @overview_spec, @history_spec, @raw_spec, @html_spec, @diff_spec = overview_spec, history_spec, raw_spec, html_spec, diff_spec
17
- end
18
-
19
- def overview
20
- file_uri(nil, nil, @overview_spec)
21
- end
22
-
23
- def history(path)
24
- file_uri(path, nil, @history_spec)
25
- end
26
-
27
- def raw(path, revision)
28
- file_uri(path, revision, @raw_spec)
29
- end
30
-
31
- def html(path, revision)
32
- file_uri(path, revision, @html_spec)
33
- end
34
-
35
- def diff(path, revision, previous_revision)
36
- file_uri(path, revision, @diff_spec, previous_revision)
37
- end
38
-
39
- private
40
-
41
- # Returns the file URI for +path+. Valid options are:
42
- #
43
- # * :type => ["overview"|"html"|"diff"|"raw"]
44
- # * :revision
45
- # * :previous_revision
46
- def file_uri(path="", revision=nil, spec=@overview_spec, previous_revision=nil)
47
- begin
48
- eval("\"#{spec}\"", binding)
49
- rescue NameError
50
- raise "Couldn't evaluate '#{spec}'"
51
- end
52
- end
53
-
54
- end
55
- end
1
+ require 'meta_project/scm_web/browser'
2
+ require 'meta_project/scm_web/pathname'
@@ -22,7 +22,7 @@ module MetaProject
22
22
 
23
23
  def markup(text)
24
24
  text.gsub(issue_pattern) do |match|
25
- issue_identifier = $1
25
+ issue_identifier = $1.upcase
26
26
  issue = issue(issue_identifier)
27
27
  issue.url ? "<a href=\"#{issue.url}\">#{issue_identifier}: #{issue.summary}</a>" : issue_identifier
28
28
  end
@@ -50,10 +50,11 @@ module MetaProject
50
50
 
51
51
  def materialize(issue)
52
52
  login do |session|
53
+ issue.attributes[:identifier] = issue.attributes[:identifier].upcase
53
54
  issue_struct = session.getIssue(issue.identifier)
54
55
 
55
- issue.attributes[:summary] = issue_struct["summary"]
56
- issue.attributes[:detail] = issue_struct["description"]
56
+ issue.attributes[:summary] = issue_struct["summary"].strip
57
+ issue.attributes[:detail] = issue_struct["description"].strip
57
58
  issue.attributes[:url] = "#{@jira_base_url}/browse/#{issue.identifier}"
58
59
  end
59
60
  end
data/lib/meta_project.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'meta_project/core_ext/string'
1
2
  require 'meta_project/project_analyzer'
2
3
  require 'meta_project/patois'
3
4
  require 'meta_project/project'
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: meta_project
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.4.4
7
- date: 2005-08-30 00:00:00 -04:00
6
+ version: 0.4.5
7
+ date: 2005-09-01 00:00:00 -04:00
8
8
  summary: Ruby based make-like utility.
9
9
  require_paths:
10
10
  - lib
@@ -42,6 +42,7 @@ files:
42
42
  - lib/meta_project/scm_web.rb
43
43
  - lib/meta_project/tracker.rb
44
44
  - lib/meta_project/version_parser.rb
45
+ - lib/meta_project/core_ext/string.rb
45
46
  - lib/meta_project/patois/parser.rb
46
47
  - lib/meta_project/project/base.rb
47
48
  - lib/meta_project/project/codehaus.rb
@@ -56,6 +57,8 @@ files:
56
57
  - lib/meta_project/project/xforge/xforge_base.rb
57
58
  - lib/meta_project/release/freshmeat.rb
58
59
  - lib/meta_project/release/raa.rb
60
+ - lib/meta_project/scm_web/browser.rb
61
+ - lib/meta_project/scm_web/pathname.rb
59
62
  - lib/meta_project/tracker/base.rb
60
63
  - lib/meta_project/tracker/digit_issues.rb
61
64
  - lib/meta_project/tracker/issue.rb