meta_project 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,34 @@
1
+ module MetaProject
2
+ module Tracker
3
+ module Jira
4
+ # This module should be included by trackers that follow a digit-based issue scheme
5
+ module JiraIssues
6
+
7
+ # Patois issue pattern
8
+ def issue_pattern
9
+ /([A-Za-z]+-[\d]+)/
10
+ end
11
+ module_function :issue_pattern
12
+
13
+ # Patois command pattern
14
+ def command_pattern
15
+ /([A-Za-z]*).?([A-Za-z]+-[\d]+(?:(?:[, &]*|\s?and\s?)[A-Za-z]+-[\d]+)*)/
16
+ end
17
+ module_function :command_pattern
18
+
19
+ def identifier_examples
20
+ ["DC-420", "pico-12"]
21
+ end
22
+
23
+ def markup(text)
24
+ text.gsub(issue_pattern) do |match|
25
+ issue_identifier = $1
26
+ issue = issue(issue_identifier)
27
+ issue.url ? "<a href=\"#{issue.url}\">#{issue_identifier}: #{issue.summary}</a>" : issue_identifier
28
+ end
29
+ end
30
+
31
+ end
32
+ end
33
+ end
34
+ end
@@ -3,7 +3,15 @@ require 'xmlrpc/client'
3
3
  module MetaProject
4
4
  module Tracker
5
5
  module Jira
6
+
7
+ # Interface to JIRA. Uses the XML-RPC API defined at:
8
+ #
9
+ # http://confluence.atlassian.com/pages/viewpage.action?pageId=9623
10
+ # http://confluence.atlassian.com/pages/viewpage.action?pageId=1035
11
+ # http://www.atlassian.com/software/jira/docs/api/rpc-jira-plugin/latest/index.html?com/atlassian/jira/rpc/xmlrpc/XmlRpcService.html
6
12
  class JiraTracker < Base
13
+
14
+ include JiraIssues
7
15
  JIRA_API = "jira1"
8
16
 
9
17
  attr_accessor :jira_base_url, :jira_project_id
@@ -17,52 +25,55 @@ module MetaProject
17
25
  #
18
26
  # JIRA_CODEHAUS_ORG_JIRA_USER
19
27
  # JIRA_CODEHAUS_ORG_JIRA_PASSWORD
28
+ # TODO: pass in to ctor instead. do this somewhere else!
20
29
  def initialize(jira_base_url=nil, jira_project_id=nil)
21
30
  @jira_base_url, @jira_project_id = jira_base_url, jira_project_id
22
31
  end
23
32
 
24
- def identifier_regexp
25
- /([A-Z]+-[\d]+)/
26
- end
27
-
28
- def identifier_examples
29
- ["DC-420", "PICO-12"]
30
- end
31
-
32
33
  def overview
33
34
  "#{@jira_base_url}/browse/#{@jira_project_id}"
34
35
  end
35
36
 
36
- def issue(issue_identifier)
37
- begin
38
- session = login
39
- issue = session.getIssue(issue_identifier)
40
- Issue.new("#{@jira_base_url}/browse/#{issue_identifier}", issue["summary"])
41
- rescue XMLRPC::FaultException => e
42
- # Probably bad issue number or failed login
43
- STDERR.puts("Couldn't get issue #{issue_identifier}: #{e.message}")
44
- nil
45
- rescue LoginException => e
46
- # Missing env vars
47
- STDERR.puts("Couldn't log in to JIRA at #{@rooturl}: #{e.message}")
48
- nil
37
+ def create(issue)
38
+ issue_struct = {
39
+ "project" => @jira_project_id,
40
+ "summary" => issue.summary,
41
+ "description" => issue.detail,
42
+ "type" => 2, # magic number!
43
+ "priority" => 1
44
+ }
45
+ login do |session|
46
+ issue_struct = session.createIssue(issue_struct)
47
+ issue.attributes[:identifier] = issue_struct["key"]
49
48
  end
50
49
  end
51
-
52
- def markup(text)
53
- text.gsub(identifier_regexp) do |match|
54
- issue_identifier = $1
55
- issue = issue(issue_identifier)
56
- issue ? "<a href=\"#{issue.uri}\">#{issue_identifier}: #{issue.summary}</a>" : issue_identifier
50
+
51
+ def materialize(issue)
52
+ login do |session|
53
+ issue_struct = session.getIssue(issue.identifier)
54
+
55
+ issue.attributes[:summary] = issue_struct["summary"]
56
+ issue.attributes[:detail] = issue_struct["description"]
57
+ issue.attributes[:url] = "#{@jira_base_url}/browse/#{issue.identifier}"
57
58
  end
58
59
  end
59
-
60
+
60
61
  private
61
62
 
62
63
  def login
63
64
  client = XMLRPC::Client.new2("#{@jira_base_url}/rpc/xmlrpc")
64
65
  token = client.call("#{JIRA_API}.login", user, password)
65
- Session.new(client, token)
66
+ begin
67
+ yield Session.new(client, token)
68
+ rescue XMLRPC::FaultException => e
69
+ # Probably bad issue number or failed login
70
+ STDERR.puts("WARNING: Exception from JIRA: #{e.faultCode}, #{e.faultString}")
71
+ nil
72
+ rescue LoginException => e
73
+ # Missing env vars
74
+ STDERR.puts("WARNING: Couldn't log in to JIRA at #{@rooturl}: #{e.message}")
75
+ nil
76
+ end
66
77
  end
67
78
 
68
79
  def user
@@ -97,8 +108,8 @@ module MetaProject
97
108
  @client, @token = client, token
98
109
  end
99
110
 
100
- def method_missing(sym, args, &block)
101
- token_args = [@token] << args
111
+ def method_missing(sym, *args, &block)
112
+ token_args = [@token] + args
102
113
  xmlrpc_method = "#{JIRA_API}.#{sym.to_s}"
103
114
  @client.call(xmlrpc_method, *token_args)
104
115
  end
@@ -1 +1,2 @@
1
+ require 'meta_project/tracker/jira/jira_issues'
1
2
  require 'meta_project/tracker/jira/jira_tracker'
@@ -13,8 +13,22 @@ module MetaProject
13
13
  def overview
14
14
  "#{@trac_base_url}/report"
15
15
  end
16
-
17
- def issue(issue_identifier)
16
+
17
+ def materialize(issue)
18
+ begin
19
+ url = "#{@trac_base_url}/ticket/#{issue.identifier}"
20
+ html = open(url).read
21
+ summary = html[/Ticket ##{issue.identifier}\s*<\/h1>\s*<h2>([^<]*)<\/h2>/n, 1]
22
+ issue.attributes[:summary] = summary
23
+ issue.attributes[:url] = url
24
+ rescue OpenURI::HTTPError => e
25
+ STDERR.puts e.message
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def XXissue(issue_identifier)
18
32
  issue_uri = "#{@trac_base_url}/ticket/#{issue_identifier}"
19
33
  begin
20
34
  html = open(issue_uri) { |data| data.read }
@@ -7,7 +7,7 @@ module MetaProject
7
7
  /\/tracker\/\?atid=(\d+)&group_id=\d*&func=browse/
8
8
  end
9
9
 
10
- def issue_regexp(identifier)
10
+ def issue_summary_regexp(identifier)
11
11
  /<a href=\"\/tracker\/index.php\?func=detail&aid=#{identifier}&group_id=\d+&atid=\d+\">([^<]*)<\/a>/
12
12
  end
13
13
 
@@ -7,7 +7,7 @@ module MetaProject
7
7
  /\/tracker\/\?atid=(\d+)&amp;group_id=\d*&amp;func=browse/
8
8
  end
9
9
 
10
- def issue_regexp(identifier)
10
+ def issue_summary_regexp(identifier)
11
11
  /<a href=\"\/tracker\/index.php\?func=detail&amp;aid=#{identifier}&amp;group_id=\d+&amp;atid=\d+\">([^<]*)<\/a>/
12
12
  end
13
13
 
@@ -24,17 +24,11 @@ module MetaProject
24
24
  end
25
25
  nil
26
26
  end
27
-
28
- def markup(text)
29
- text.gsub(identifier_regexp) do |match|
30
- issue_identifier = $1
31
- issue = issue(issue_identifier)
32
- issue ? "<a href=\"#{issue.uri}\">\##{issue_identifier}: #{issue.summary}</a>" : "\##{issue_identifier}"
33
- end
27
+
28
+ def materialize(issue)
34
29
  end
35
30
 
36
31
  class SubTracker
37
- attr_reader :uri
38
32
 
39
33
  def initialize(tracker, atid)
40
34
  @tracker = tracker
@@ -44,12 +38,13 @@ module MetaProject
44
38
  end
45
39
 
46
40
  def issue(identifier)
47
- html = open(uri) { |data| data.read }
41
+ html = open(@uri) { |data| data.read }
48
42
 
49
- regexp = @tracker.issue_regexp(identifier)
50
- if(html =~ regexp)
51
- issue_uri = @tracker.project.group_id_uri("tracker/index.php", "&atid=#{@atid}&func=detail&aid=#{identifier}")
52
- return Issue.new(issue_uri, $1.strip)
43
+ issue_summary_regexp = @tracker.issue_summary_regexp(identifier)
44
+ if(html =~ issue_summary_regexp)
45
+ issue_url = @tracker.project.group_id_uri("tracker/index.php", "&atid=#{@atid}&func=detail&aid=#{identifier}")
46
+ issue_summary = $1.strip
47
+ return Issue.new(@tracker, :summary => issue_summary, :url => issue_url)
53
48
  end
54
49
  nil
55
50
  end
data/lib/meta_project.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'meta_project/project_analyzer'
2
+ require 'meta_project/patois'
2
3
  require 'meta_project/project'
3
4
  require 'meta_project/tracker'
4
5
  require 'meta_project/scm_web'
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.3
7
- date: 2005-08-24 00:00:00 -04:00
6
+ version: 0.4.4
7
+ date: 2005-08-30 00:00:00 -04:00
8
8
  summary: Ruby based make-like utility.
9
9
  require_paths:
10
10
  - lib
@@ -36,11 +36,13 @@ files:
36
36
  - README
37
37
  - TODO
38
38
  - lib/meta_project.rb
39
+ - lib/meta_project/patois.rb
39
40
  - lib/meta_project/project.rb
40
41
  - lib/meta_project/project_analyzer.rb
41
42
  - lib/meta_project/scm_web.rb
42
43
  - lib/meta_project/tracker.rb
43
44
  - lib/meta_project/version_parser.rb
45
+ - lib/meta_project/patois/parser.rb
44
46
  - lib/meta_project/project/base.rb
45
47
  - lib/meta_project/project/codehaus.rb
46
48
  - lib/meta_project/project/trac.rb
@@ -52,12 +54,15 @@ files:
52
54
  - lib/meta_project/project/xforge/source_forge.rb
53
55
  - lib/meta_project/project/xforge/xfile.rb
54
56
  - lib/meta_project/project/xforge/xforge_base.rb
57
+ - lib/meta_project/release/freshmeat.rb
58
+ - lib/meta_project/release/raa.rb
55
59
  - lib/meta_project/tracker/base.rb
56
60
  - lib/meta_project/tracker/digit_issues.rb
57
61
  - lib/meta_project/tracker/issue.rb
58
62
  - lib/meta_project/tracker/jira.rb
59
63
  - lib/meta_project/tracker/trac.rb
60
64
  - lib/meta_project/tracker/xforge.rb
65
+ - lib/meta_project/tracker/jira/jira_issues.rb
61
66
  - lib/meta_project/tracker/jira/jira_tracker.rb
62
67
  - lib/meta_project/tracker/trac/trac_tracker.rb
63
68
  - lib/meta_project/tracker/xforge/ruby_forge_tracker.rb