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/11/24 18:34:49 UTC
svn commit: r348774 - /maven/sandbox/issue/rbot/jira.rb
Author: jvanzyl
Date: Thu Nov 24 09:34:41 2005
New Revision: 348774
URL: http://svn.apache.org/viewcvs?rev=348774&view=rev
Log:
o get the password from a user YAML file.
Modified:
maven/sandbox/issue/rbot/jira.rb
Modified: maven/sandbox/issue/rbot/jira.rb
URL: http://svn.apache.org/viewcvs/maven/sandbox/issue/rbot/jira.rb?rev=348774&r1=348773&r2=348774&view=diff
==============================================================================
--- maven/sandbox/issue/rbot/jira.rb (original)
+++ maven/sandbox/issue/rbot/jira.rb Thu Nov 24 09:34:41 2005
@@ -1,26 +1,13 @@
require 'jira4r'
+require 'yaml'
class JiraPlugin < Plugin
- def initialize
- url = "http://jira.codehaus.org"
- user = "user"
- password = "password"
- @server = JIRA::Server.new( url )
- @server.login( user, password )
- puts @server
- end
+ @server = nil
+ @url = nil
- # return a help string when the bot is asked for help on this plugin
- def help(plugin, topic="")
- return "length <string> => return length of string <string>"
- end
-
- # reply to a private message that we've registered for
def privmsg(m)
- # m.params contains the rest of the message, m.plugin contains the first
- # word (useful because it's possible to register for multiple commands)
unless(m.params)
m.reply "incorrect usage. " + help(m.plugin)
end
@@ -28,22 +15,34 @@
# Using the jira library directly seems to crash rbot ...
# so i'm just exec'ing the command line tool used to query
# JIRA from the command line.
-
- puts "working..."
- ret = Utils.safe_exec("cm", m.params.to_s )
- m.reply( ret )
- #issue = @server.getIssue( m.params.to_s )
- #user = @server.getUser( issue['reporter'] )
- #string = " Issue: #{issue['key']}\n"
- #string << " URL: #{url}/browse/#{issue['key']}"
- #string << " Summary: #{issue['summary']}"
- #string << "Reporter: #{user['fullname']} (#{issue['reporter']})"
- #m.reply( string )
+ issue = getServer().getIssue( m.params.to_s.upcase )
+ user = getServer().getUser( issue['reporter'] )
+ m.reply( " " )
+ string = " Issue: #{issue['key']}\n"
+ string << " URL: #{@url}/browse/#{issue['key']}\n"
+ string << " Status: #{issue['status']}\n"
+ string << " Summary: #{issue['summary']}\n"
+ string << "Reporter: #{user['fullname']} (#{issue['reporter']})"
+ m.reply( string )
+ m.reply( " " )
+ end
+
+ def getServer
+ if @server == nil
+ jira = YAML::load( File.open( File.join( ENV['HOME'], 'jira.yaml' ) ) )
+
+ user = jira['user']
+ password = jira['password']
+ @url = jira['server']
+
+ @server = JIRA::Server.new( @url )
+ @server.login( user, password )
+ end
+ return @server
end
end
-# create an instance of our plugin class and register for the "length" command
plugin = JiraPlugin.new
plugin.register("jira")