diff options
author | 2008-07-31 01:29:57 +0000 | |
---|---|---|
committer | 2008-07-31 01:29:57 +0000 | |
commit | 0c1fd8d17e43593c28fcf8bdd6a542b2c02a2bd4 (patch) | |
tree | d4ad8d72be686a616b6246eab1fac5bb907ec83e | |
parent | Be consistent. (diff) | |
download | rbot-bugzilla-0c1fd8d17e43593c28fcf8bdd6a542b2c02a2bd4.tar.gz rbot-bugzilla-0c1fd8d17e43593c28fcf8bdd6a542b2c02a2bd4.tar.bz2 rbot-bugzilla-0c1fd8d17e43593c28fcf8bdd6a542b2c02a2bd4.zip |
Add support for templatable output.
-rw-r--r-- | bugzilla.rb | 57 |
1 files changed, 42 insertions, 15 deletions
diff --git a/bugzilla.rb b/bugzilla.rb index a89be3c..69d84d2 100644 --- a/bugzilla.rb +++ b/bugzilla.rb @@ -43,7 +43,7 @@ VALID_RESO = ['FIXED', 'INVALID', 'WONTFIX', 'LATER', 'REMIND', 'DUPLICATE', 'W # Each zilla instance may have these parameters # TODO: Add 'nicename' that is used for output to IRC. Defaults to name.capitialize -OPTIONS = [ 'name', 'baseurl', 'dataurl', 'showbugurl', 'reporturl', 'buglisturl' ] +OPTIONS = [ 'name', 'baseurl', 'dataurl', 'showbugurl', 'reporturl', 'buglisturl', 'template' ] # Now life gets fun, these are regular expresses to check the above arrays _STATUS_INPUT = (DONE_STATUS+OPEN_STATUS+['ALL']).uniq.join('|') @@ -207,6 +207,21 @@ class BugzillaPlugin < Plugin @buglisturl = @registry["zilla.#{name}.buglisturl"] = val end + def template + @template = @registry["zilla.#{name}.template"] unless @template + + unless @template + #@template = "Bug @BUGNO@; \"@DESC@\"; @PRODCOMP@; @STATUS@; @REPORTER@ -> @ASSIGNEE@; @URL@" + @template = "@URL@ \"@DESC@\"; @PRODCOMP@; @STATUS@; @REPORTER@ -> @ASSIGNEE@" + end + + return @template + end + + def template=(val) + @template = @registry["zilla.#{name}.template"] = val + end + def lastseenid return @registry["zilla.#{name}.lastseenid"] end @@ -351,16 +366,17 @@ class BugzillaPlugin < Plugin end end + product = bugxml.get_text("product").to_s + component = bugxml.get_text("component").to_s product_component = - "#{bugxml.get_text("product")} | #{bugxml.get_text("component")}". - chomp(" | ") + "#{product} | #{component}".chomp(" | ") - status = bugxml.get_text("bug_status").to_s - issue = bugxml.get_text("issue_status").to_s + bug_status = bugxml.get_text("bug_status").to_s + issue_status = bugxml.get_text("issue_status").to_s reso = bugxml.get_text("resolution").to_s - status = status[0..3] - status += ", #{issue[0..3]}" if issue and issue.length > 0 + status = bug_status[0..3] + status += ", #{issue_status[0..3]}" if issue_status and issue_status.length > 0 status += ", #{reso[0..3]}" if reso and reso.length > 0 desc = bugxml.get_text("short_desc").to_s.decode_entities @@ -369,14 +385,25 @@ class BugzillaPlugin < Plugin assignee = bugxml.get_text("assigned_to").to_s assignee = shrink_email(assignee) - # TODO: summary output templatable - return "" + - "Bug #{bugno}; " + - "\"#{desc}\"; " + - "#{product_component}; " + - "#{status}; " + - "#{reporter} -> #{assignee}; " + - "#{showbugurl.gsub('@BUGNO@', bugno)}" + mapping = { + 'BUGNO' => bugno, + 'DESC' => desc, + 'PRODUCT' => product, + 'COMPONENT' => component, + 'PRODCOMP' => product_component, + 'BUGSTATUS' => bug_status, + 'ISSUESTATUS' => issue_status, + 'RESO' => reso, + 'STATUS' => status, + 'REPORTER' => reporter, + 'ASSIGNEE' => assignee, + 'URL' => showbugurl.gsub('@BUGNO@', bugno), + } + output = template.dup + mapping.each { |k,v| + output.gsub!("@#{k}@", v) + } + return output end def add_announcement(channel_name) |