You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2005/12/21 20:01:16 UTC
svn commit: r358346 - in /maven/sandbox/issue: rbot/dist/conf.yaml
rbot/dist/plugins/jira.rb rbot/jira.rb rissue/TODO.txt
rissue/bin/get_issue.rb rissue/lib/jiraruby.rb
Author: jvanzyl
Date: Wed Dec 21 11:01:07 2005
New Revision: 358346
URL: http://svn.apache.org/viewcvs?rev=358346&view=rev
Log:
o add debug mode to the jiraruby lib
o add some notes about testing
Removed:
maven/sandbox/issue/rbot/jira.rb
Modified:
maven/sandbox/issue/rbot/dist/conf.yaml
maven/sandbox/issue/rbot/dist/plugins/jira.rb
maven/sandbox/issue/rissue/TODO.txt
maven/sandbox/issue/rissue/bin/get_issue.rb
maven/sandbox/issue/rissue/lib/jiraruby.rb
Modified: maven/sandbox/issue/rbot/dist/conf.yaml
URL: http://svn.apache.org/viewcvs/maven/sandbox/issue/rbot/dist/conf.yaml?rev=358346&r1=358345&r2=358346&view=diff
==============================================================================
--- maven/sandbox/issue/rbot/dist/conf.yaml (original)
+++ maven/sandbox/issue/rbot/dist/conf.yaml Wed Dec 21 11:01:07 2005
@@ -3,5 +3,5 @@
irc.nick: faqbot
server.name: irc.codehaus.org
irc.join_channels:
-- "#foo"
+- "#moo"
datadir: /home/jvanzyl/js/org/apache/maven/sandbox/issue/rbot/dist/share/rbot
Modified: maven/sandbox/issue/rbot/dist/plugins/jira.rb
URL: http://svn.apache.org/viewcvs/maven/sandbox/issue/rbot/dist/plugins/jira.rb?rev=358346&r1=358345&r2=358346&view=diff
==============================================================================
--- maven/sandbox/issue/rbot/dist/plugins/jira.rb (original)
+++ maven/sandbox/issue/rbot/dist/plugins/jira.rb Wed Dec 21 11:01:07 2005
@@ -1,12 +1,10 @@
-require 'issue'
-require 'yaml'
+require 'rubygems'
+require_gem 'jiraruby'
# faq counter: totals, by each contributor. a report would be nice.
class JiraPlugin < Plugin
- @server = nil
-
def jira(m,params)
unless(params)
m.reply "incorrect usage. " + help(m.plugin)
@@ -34,10 +32,11 @@
unless(m.params)
m.reply "incorrect usage. " + help(m.plugin)
end
+ server = getServer()
who = params[:who]
summary = params[:phrase].join( " " )
- fields = getServer().createIssue2( 'MNGFAQ', summary, 'none', '1', who, 'minor' )
- getServer().closeIssue( fields )
+ issue,assignee = server.createIssue2( 'MNGFAQ', summary, 'none', '1', who, 'minor' )
+ server.closeIssue( issue,assignee )
end
# Need to know which person submitted the entry
@@ -45,34 +44,25 @@
unless(m.params)
m.reply "incorrect usage. " + help(m.plugin)
end
+ server = getServer()
who = params[:who]
summary = params[:phrase].join( " " )
- puts who
- puts summary
- fields = getServer().createIssue2( 'MNGFAQ', summary, 'none', '1', who, 'minor' )
+ puts summary,who
+ server.createIssue2( 'MNGFAQ', summary, 'none', '1', who, 'minor' )
end
def faqc(m,params)
unless(m.params)
m.reply "incorrect usage. " + help(m.plugin)
end
+ server = getServer()
issue = params[:issue]
- fields = issue = getServer().getIssue( issue.upcase! )
- puts fields
- getServer().closeIssue( fields )
+ fields = issue = server.getIssue( issue.upcase! )
+ server.closeIssue( fields )
end
- def issue(m,params)
- fields = getServer().createIssue2( params[:project], params[:summary], params[:description], '1', params[:assignee], 'minor' )
- m.reply( fields['key'] )
- m.reply( " created." )
- end
-
def getServer
- if @server == nil
- @server = IssueManager.new()
- end
- @server
+ return IssueManager.new()
end
end
Modified: maven/sandbox/issue/rissue/TODO.txt
URL: http://svn.apache.org/viewcvs/maven/sandbox/issue/rissue/TODO.txt?rev=358346&r1=358345&r2=358346&view=diff
==============================================================================
--- maven/sandbox/issue/rissue/TODO.txt (original)
+++ maven/sandbox/issue/rissue/TODO.txt Wed Dec 21 11:01:07 2005
@@ -1,5 +1,15 @@
- put these in JIRA :-)
- create a ruby shell for JIRA
- generate the soap goop as part of the build
+- if a jira.yaml file isn't present just prompt the operator for u/p
+- needs to be properly rdoc'd
+- needs to be tested well
+ - create a project
+ - check schemes
+ - add components and check status
+ - add issues and check status
+ - delete components
+ - delete issues
+ - delete project
x see if the SOAP library for ruby will work. SOAP stuff works great
x create a normal ruby installer for the issue manager, use ruby gems
Modified: maven/sandbox/issue/rissue/bin/get_issue.rb
URL: http://svn.apache.org/viewcvs/maven/sandbox/issue/rissue/bin/get_issue.rb?rev=358346&r1=358345&r2=358346&view=diff
==============================================================================
--- maven/sandbox/issue/rissue/bin/get_issue.rb (original)
+++ maven/sandbox/issue/rissue/bin/get_issue.rb Wed Dec 21 11:01:07 2005
@@ -4,9 +4,6 @@
require_gem 'jiraruby'
im = IssueManager.new()
-
-issue = im.getIssue( "MNG-1" )
-
-puts issue.summary
+issue = im.getIssue( "MNG-500" )
puts issue.id
-
+puts issue.assignee
Modified: maven/sandbox/issue/rissue/lib/jiraruby.rb
URL: http://svn.apache.org/viewcvs/maven/sandbox/issue/rissue/lib/jiraruby.rb?rev=358346&r1=358345&r2=358346&view=diff
==============================================================================
--- maven/sandbox/issue/rissue/lib/jiraruby.rb (original)
+++ maven/sandbox/issue/rissue/lib/jiraruby.rb Wed Dec 21 11:01:07 2005
@@ -11,13 +11,9 @@
include REXML
class IssueManager
- def initialize
- if ENV['JIRA_CONF_DIR'] != nil
- @conf_dir = ENV['JIRA_CONF_DIR']
- else
- @conf_dir = `pwd`.chomp
- end
- @jira = YAML::load( 'mappings.yaml' )
+ def initialize( debug=false )
+ @debug = debug
+ @jira = YAML::load( File.open( File.join( File.dirname( __FILE__ ), 'mappings.yaml' ) ) )
@server = getServer()
end
@@ -33,46 +29,111 @@
return @server
end
+ #----------------------------------------------------------------
+ # SOAP service delegator
+ #----------------------------------------------------------------
+
+ # Delegate calls to the underlying server where possible
+ def method_missing(method_name, *args)
+ return @server.send( method_name, *([@token] + args) )
+ end
+
+ #----------------------------------------------------------------
+ # Projects
+ #----------------------------------------------------------------
+
+ # The issue is a struct with all the issue information
+ def createProject( key, name, description, url, lead, permissionSchemeId, notificationSchemeId )
+ url = CGI.escape( url )
+ description = CGI.escape( description )
+ name = CGI.escape( name )
+ query = "#{@config['server']}/secure/admin/AddProject.jspa?name=#{name}&key=#{key}&url=#{url}&lead=#{lead}&assigneeType=2&description=#{description}¬ificationScheme=#{notificationSchemeId}&permissionScheme=#{permissionSchemeId}&issueSecurityScheme=-1&Create=Create&os_username=#{@config['user']}&os_password=#{@config['password']}"
+ request = URI.parse(query)
+ res = Net::HTTP.get(request)
+ end
+
+ #----------------------------------------------------------------
+ # Issues
+ #----------------------------------------------------------------
+
# The issue is a struct with all the issue information
def closeIssue( issue, assignee )
id = issue.id
query = "#{@config['server']}/secure/CommentAssignIssue.jspa?resolution=1&action=2&id=#{id}&assignee=#{assignee}&Close%20Issue=Close%20Issue&os_username=#{@config['user']}&os_password=#{@config['password']}"
url = URI.parse(query)
res = Net::HTTP.get(url)
- puts res
end
+ def issueUrl( issue )
+ return @config['server'] + '/browse/' + issue.key
+ end
+
+ def issuesByFilter( filterId )
+ return getIssuesFromFilter( filterId )
+ end
+
+ def updateIssue( issueId, fields )
+ return @server.updateIssue( issueId, fields )
+ end
+
+ def createIssue2( project, summary, description, type, assignee, priorityKey )
+ return createIssue( project, summary, description, type, assignee, priorityKey, nil )
+ end
+
+ def createIssue( project, summary, description, type, assignee, priorityKey, component )
+
+ issue = RemoteIssue.new()
+ issue.project = project
+ issue.summary = summary
+ issue.description = description
+ issue.type = type
+ issue.assignee = assignee
+
+ priority = @jira['priority'][priorityKey]
+ issue.priority = priority
+
+ if @debug
+ puts "project: #{project}"
+ puts "summary #{summary}"
+ puts "description: #{description}"
+ puts "type #{type}"
+ puts "assignee: #{assignee}"
+ puts "priorityKey: #{priorityKey} "
+ puts "priority: #{priority}"
+ end
+
+ if component != nil
+ issue.components = [ component ]
+ end
+
+ issue = @server.createIssue( @token, issue )
+ return issue,assignee
+ end
+
+ #----------------------------------------------------------------
+ # Permission Schemes
+ #----------------------------------------------------------------
+
# The issue is a struct with all the issue information
def assignPermissionScheme( project, notificationSchemeId )
projectId = project['id']
query = "#{@config['server']}/secure/project/SelectProjectPermissionScheme.jspa?schemeIds=#{notificationSchemeId}&projectId=#{projectId}&Associate=Associate&os_username=#{@config['user']}&os_password=#{@config['password']}"
url = URI.parse(query)
res = Net::HTTP.get(url)
- puts res
end
+ #----------------------------------------------------------------
+ # Notification Schemes
+ #----------------------------------------------------------------
+
# The issue is a struct with all the issue information
def assignNotificationScheme( project, notificationSchemeId )
projectId = project['id']
query = "#{@config['server']}/secure/project/SelectProjectScheme.jspa?schemeIds=#{notificationSchemeId}&projectId=#{projectId}&Associate=Associate&os_username=#{@config['user']}&os_password=#{@config['password']}"
url = URI.parse(query)
res = Net::HTTP.get(url)
- puts res
end
- # Delegate calls to the underlying server where possible
- def method_missing(method_name, *args)
- return getServer().send( method_name, *([@token] + args) )
- end
-
- def issueUrl( issue )
- return @config['server'] + '/browse/' + issue.key
- end
-
- def issuesByFilter( filterId )
- return getIssuesFromFilter( filterId )
- end
-
def generateXdoc( filterName )
document = REXML::Element.new( "document" )
properties = REXML::Element.new( "properties" )
@@ -101,37 +162,6 @@
end
- def updateIssue( issueId, fields )
- return getServer().updateIssue( issueId, fields )
- end
-
- def createIssue2( project, summary, description, type, assignee, priorityKey )
- return createIssue( project, summary, description, type, assignee, priorityKey, nil )
- end
-
- def createIssue( project, summary, description, type, assignee, priorityKey, component )
-
- issue = RemoteIssue.new()
- issue.project = project
- issue.summary = summary
- issue.description = description
- issue.type = type
- issue.assignee = assignee
-
- priority = @jira['priority'][priorityKey]
- issue.priority = priority
-
- if component != nil
- issue.components = [ component ]
- end
-
- issue = getServer().createIssue( @token, issue )
- puts issue.id
- #eissue = EnhancedRemoteIssue.new( issue, assignee )
- #puts eissue.id
- return issue,assignee
- end
-
#----------------------------------------------------------------
# Components
#----------------------------------------------------------------
@@ -156,19 +186,4 @@
y['components'] = components
end
end
-
- #----------------------------------------------------------------
- # Projects
- #----------------------------------------------------------------
-
- # The issue is a struct with all the issue information
- def createProject( key, name, description, url, lead, permissionSchemeId, notificationSchemeId )
- url = CGI.escape( url )
- description = CGI.escape( description )
- name = CGI.escape( name )
- query = "#{@config['server']}/secure/admin/AddProject.jspa?name=#{name}&key=#{key}&url=#{url}&lead=#{lead}&assigneeType=2&description=#{description}¬ificationScheme=#{notificationSchemeId}&permissionScheme=#{permissionSchemeId}&issueSecurityScheme=-1&Create=Create&os_username=#{@config['user']}&os_password=#{@config['password']}"
- request = URI.parse(query)
- res = Net::HTTP.get(request)
- end
-
end