damagecontrol 0.5.0 → 0.5.0.1391

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. data/README +67 -11
  2. data/Rakefile +15 -6
  3. data/app/controllers/admin_controller.rb +0 -3
  4. data/app/controllers/application.rb +42 -163
  5. data/app/controllers/build_controller.rb +33 -0
  6. data/app/controllers/files_controller.rb +1 -1
  7. data/app/controllers/project_controller.rb +23 -65
  8. data/app/controllers/rails_ext.rb +247 -0
  9. data/app/controllers/rscm_ext.rb +52 -0
  10. data/app/helpers/build_helper.rb +2 -0
  11. data/app/views/build/email.rhtml +18 -0
  12. data/app/views/build/status.rhtml +20 -0
  13. data/app/views/build/tests.rhtml +2 -0
  14. data/app/views/layouts/{rscm.rhtml → default.rhtml} +10 -4
  15. data/app/views/project/_changesets_list.rhtml +2 -2
  16. data/app/views/project/_cvs.rhtml +4 -5
  17. data/app/views/project/_project.rhtml +9 -9
  18. data/app/views/project/_select_pane.rhtml +26 -0
  19. data/app/views/project/_tab_pane.rhtml +23 -0
  20. data/app/views/project/changeset.rhtml +35 -0
  21. data/app/views/project/view.rhtml +18 -32
  22. data/app/views/setup/welcome.rhtml +118 -0
  23. data/config/database.yml +20 -20
  24. data/config/environment.rb +66 -60
  25. data/config/environments/development.rb +3 -2
  26. data/config/environments/production.rb +3 -2
  27. data/config/environments/test.rb +3 -2
  28. data/config/routes.rb +15 -0
  29. data/lib/damagecontrol/app.rb +11 -40
  30. data/lib/damagecontrol/build.rb +50 -8
  31. data/lib/damagecontrol/directories.rb +7 -6
  32. data/lib/damagecontrol/poller.rb +11 -20
  33. data/lib/damagecontrol/project.rb +83 -16
  34. data/lib/damagecontrol/publisher/ambient_orb.rb +16 -0
  35. data/lib/damagecontrol/publisher/archive.rb +16 -0
  36. data/lib/damagecontrol/publisher/base.rb +25 -0
  37. data/lib/damagecontrol/publisher/build_duration.rb +16 -0
  38. data/lib/damagecontrol/publisher/email.rb +59 -0
  39. data/lib/damagecontrol/publisher/execute.rb +49 -0
  40. data/lib/damagecontrol/publisher/ftp.rb +16 -0
  41. data/lib/damagecontrol/publisher/growl.rb +44 -0
  42. data/lib/damagecontrol/publisher/irc.rb +31 -0
  43. data/lib/damagecontrol/publisher/jabber.rb +68 -0
  44. data/lib/damagecontrol/publisher/scp.rb +16 -0
  45. data/lib/damagecontrol/publisher/x10cm11a.rb +17 -0
  46. data/lib/damagecontrol/publisher/x10cm17a.rb +17 -0
  47. data/lib/damagecontrol/publisher/yahoo.rb +16 -0
  48. data/lib/damagecontrol/standard_persister.rb +2 -2
  49. data/lib/damagecontrol/tracker.rb +48 -6
  50. data/lib/damagecontrol/visitor/rss_writer.rb +1 -1
  51. data/lib/damagecontrol/visitor/yaml_persister.rb +10 -1
  52. data/public/404.html +5 -5
  53. data/public/500.html +5 -5
  54. data/public/dispatch.cgi +2 -2
  55. data/public/dispatch.fcgi +1 -1
  56. data/public/dispatch.rb +2 -2
  57. data/public/images/growlicon.png +0 -0
  58. data/public/images/megaphone.png +0 -0
  59. data/public/images/monotone-logo.png +0 -0
  60. data/public/images/publisher/ambient_orb.png +0 -0
  61. data/public/images/publisher/build_duration.png +0 -0
  62. data/public/images/publisher/email.png +0 -0
  63. data/public/images/publisher/execute.png +0 -0
  64. data/public/images/publisher/growl.png +0 -0
  65. data/public/images/publisher/irc.png +0 -0
  66. data/public/images/publisher/jabber.png +0 -0
  67. data/public/images/publisher/x10cm11a.png +0 -0
  68. data/public/images/publisher/x10cm17a.png +0 -0
  69. data/public/images/publisher/yahoo.png +0 -0
  70. data/public/index.html +70 -1
  71. data/public/javascripts/dateFormat.js +283 -0
  72. data/public/javascripts/jscalendar/ChangeLog +500 -0
  73. data/public/javascripts/jscalendar/README +33 -0
  74. data/public/javascripts/jscalendar/bugtest-hidden-selects.html +108 -0
  75. data/public/javascripts/jscalendar/calendar-blue.css +231 -0
  76. data/public/javascripts/jscalendar/calendar-blue2.css +235 -0
  77. data/public/javascripts/jscalendar/calendar-brown.css +224 -0
  78. data/public/javascripts/jscalendar/calendar-green.css +228 -0
  79. data/public/javascripts/jscalendar/calendar-setup.js +181 -0
  80. data/public/javascripts/jscalendar/calendar-setup_stripped.js +21 -0
  81. data/public/javascripts/jscalendar/calendar-system.css +250 -0
  82. data/public/javascripts/jscalendar/calendar-tas.css +238 -0
  83. data/public/javascripts/jscalendar/calendar-win2k-1.css +270 -0
  84. data/public/javascripts/jscalendar/calendar-win2k-2.css +270 -0
  85. data/public/javascripts/jscalendar/calendar-win2k-cold-1.css +264 -0
  86. data/public/javascripts/jscalendar/calendar-win2k-cold-2.css +270 -0
  87. data/public/javascripts/jscalendar/calendar.js +1715 -0
  88. data/public/javascripts/jscalendar/calendar.php +119 -0
  89. data/public/javascripts/jscalendar/calendar_stripped.js +12 -0
  90. data/public/javascripts/jscalendar/doc/html/reference-Z-S.css +0 -0
  91. data/public/javascripts/jscalendar/doc/html/reference.css +34 -0
  92. data/public/javascripts/jscalendar/doc/html/reference.html +1316 -0
  93. data/public/javascripts/jscalendar/doc/reference.pdf +0 -0
  94. data/public/javascripts/jscalendar/img.gif +0 -0
  95. data/public/javascripts/jscalendar/index.html +333 -0
  96. data/public/javascripts/jscalendar/lang/calendar-af.js +39 -0
  97. data/public/javascripts/jscalendar/lang/calendar-br.js +45 -0
  98. data/public/javascripts/jscalendar/lang/calendar-ca.js +45 -0
  99. data/public/javascripts/jscalendar/lang/calendar-cs-win.js +34 -0
  100. data/public/javascripts/jscalendar/lang/calendar-da.js +63 -0
  101. data/public/javascripts/jscalendar/lang/calendar-de.js +100 -0
  102. data/public/javascripts/jscalendar/lang/calendar-du.js +45 -0
  103. data/public/javascripts/jscalendar/lang/calendar-el.js +89 -0
  104. data/public/javascripts/jscalendar/lang/calendar-en.js +123 -0
  105. data/public/javascripts/jscalendar/lang/calendar-es.js +114 -0
  106. data/public/javascripts/jscalendar/lang/calendar-fi.js +98 -0
  107. data/public/javascripts/jscalendar/lang/calendar-fr.js +86 -0
  108. data/public/javascripts/jscalendar/lang/calendar-hr-utf8.js +49 -0
  109. data/public/javascripts/jscalendar/lang/calendar-hr.js +0 -0
  110. data/public/javascripts/jscalendar/lang/calendar-hu.js +45 -0
  111. data/public/javascripts/jscalendar/lang/calendar-it.js +79 -0
  112. data/public/javascripts/jscalendar/lang/calendar-jp.js +45 -0
  113. data/public/javascripts/jscalendar/lang/calendar-ko-utf8.js +120 -0
  114. data/public/javascripts/jscalendar/lang/calendar-ko.js +120 -0
  115. data/public/javascripts/jscalendar/lang/calendar-lt-utf8.js +114 -0
  116. data/public/javascripts/jscalendar/lang/calendar-lt.js +114 -0
  117. data/public/javascripts/jscalendar/lang/calendar-nl.js +45 -0
  118. data/public/javascripts/jscalendar/lang/calendar-no.js +45 -0
  119. data/public/javascripts/jscalendar/lang/calendar-pl-utf8.js +93 -0
  120. data/public/javascripts/jscalendar/lang/calendar-pl.js +56 -0
  121. data/public/javascripts/jscalendar/lang/calendar-pt.js +45 -0
  122. data/public/javascripts/jscalendar/lang/calendar-ro.js +66 -0
  123. data/public/javascripts/jscalendar/lang/calendar-ru.js +45 -0
  124. data/public/javascripts/jscalendar/lang/calendar-si.js +94 -0
  125. data/public/javascripts/jscalendar/lang/calendar-sk.js +99 -0
  126. data/public/javascripts/jscalendar/lang/calendar-sp.js +63 -0
  127. data/public/javascripts/jscalendar/lang/calendar-sv.js +93 -0
  128. data/public/javascripts/jscalendar/lang/calendar-tr.js +58 -0
  129. data/public/javascripts/jscalendar/lang/calendar-zh.js +45 -0
  130. data/public/javascripts/jscalendar/menuarrow.gif +0 -0
  131. data/public/javascripts/jscalendar/menuarrow2.gif +0 -0
  132. data/public/javascripts/jscalendar/release-notes.html +334 -0
  133. data/public/javascripts/jscalendar/simple-1.html +244 -0
  134. data/public/javascripts/jscalendar/simple-2.html +108 -0
  135. data/public/javascripts/jscalendar/simple-3.html +130 -0
  136. data/public/javascripts/jscalendar/test-position.html +40 -0
  137. data/public/javascripts/jscalendar/test.php +116 -0
  138. data/public/javascripts/toggle_div.js +18 -0
  139. data/public/stylesheets/niceones.txt +1 -0
  140. data/public/stylesheets/style.css +8 -1
  141. data/script/breakpointer +4 -5
  142. data/script/console +19 -27
  143. data/script/console_sandbox.rb +7 -0
  144. data/script/destroy +5 -0
  145. data/script/generate +3 -68
  146. data/script/server +6 -16
  147. data/test/damagecontrol/build_test.rb +8 -8
  148. data/test/damagecontrol/poller_test.rb +10 -18
  149. data/test/damagecontrol/project_test.rb +49 -13
  150. data/test/damagecontrol/publisher/base_test.rb +26 -0
  151. data/test/damagecontrol/publisher/build/email.rhtml +0 -0
  152. data/test/damagecontrol/publisher/email_test.rb +26 -0
  153. data/test/damagecontrol/publisher/fixture.rb +34 -0
  154. data/test/damagecontrol/publisher/growl_test.rb +15 -0
  155. data/test/damagecontrol/publisher/jabber_test.rb +15 -0
  156. data/test/damagecontrol/scm_web_test.rb +1 -1
  157. data/test/damagecontrol/visitor/changesets.rss +1 -1
  158. data/test/damagecontrol/visitor/diff_persister_test.rb +4 -4
  159. data/test/functional/build_controller_test.rb +17 -0
  160. data/test/test_helper.rb +13 -13
  161. metadata +185 -24
  162. data/app/views/project/_bugzilla.rhtml +0 -13
  163. data/app/views/project/_jira.rhtml +0 -19
  164. data/app/views/project/_mooky.rhtml +0 -23
  165. data/app/views/project/_rubyforge.rhtml +0 -19
  166. data/app/views/project/_scarab.rhtml +0 -19
  167. data/app/views/project/_scms.rhtml +0 -15
  168. data/app/views/project/_sourceforge.rhtml +0 -19
  169. data/app/views/project/_starteam.rhtml +0 -43
  170. data/app/views/project/_svn.rhtml +0 -22
  171. data/app/views/project/_trac.rhtml +0 -13
  172. data/app/views/project/_trackers.rhtml +0 -18
  173. data/app/views/project/changesets.rhtml +0 -31
@@ -0,0 +1,16 @@
1
+ require 'damagecontrol/publisher/base'
2
+
3
+ module DamageControl
4
+ module Publisher
5
+ class AmbientOrb < Base
6
+ #register self
7
+
8
+ def name
9
+ "Ambient Orb"
10
+ end
11
+
12
+ def publish(build)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require 'damagecontrol/publisher/base'
2
+
3
+ module DamageControl
4
+ module Publisher
5
+ class Execute < Base
6
+ #register self
7
+
8
+ def name
9
+ "Execute"
10
+ end
11
+
12
+ def publish(build)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,25 @@
1
+ require 'rscm/annotations'
2
+ require 'damagecontrol/project'
3
+
4
+ module DamageControl
5
+ module Publisher
6
+
7
+ # Base class for publishers. Subclasses must extend this class and call register self.
8
+ class Base
9
+
10
+ attr_accessor :enabled
11
+
12
+ @@classes = []
13
+ def self.register(cls)
14
+ @@classes << cls unless @@classes.index(cls)
15
+ end
16
+ def self.classes
17
+ @@classes
18
+ end
19
+
20
+ Dir[File.dirname(__FILE__) + "/*.rb"].each do |src|
21
+ load(src) unless File.expand_path(src) == File.expand_path(__FILE__)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,16 @@
1
+ require 'damagecontrol/publisher/base'
2
+
3
+ module DamageControl
4
+ module Publisher
5
+ class BuildDuration < Base
6
+ #register self
7
+
8
+ def name
9
+ "Build Duration"
10
+ end
11
+
12
+ def publish(build)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,59 @@
1
+ require 'action_mailer'
2
+ require 'damagecontrol/publisher/base'
3
+
4
+ module DamageControl
5
+ module Publisher
6
+ class Email < Base
7
+ register self
8
+
9
+ attr_accessor :enabled
10
+
11
+ ann :description => "How to deliver email [\"sendmail\"|\"smtp\"]"
12
+ attr_accessor :delivery_method
13
+
14
+ ann :description => "Recipients (comma separated)"
15
+ attr_accessor :to
16
+
17
+ ann :description => "Who sends the email"
18
+ attr_accessor :from
19
+
20
+ def initialize
21
+ @delivery_method = "sendmail"
22
+ @to = ""
23
+ @from = "\"DamageControl\" <dcontrol@codehaus.org>"
24
+ end
25
+
26
+ def name
27
+ "Email"
28
+ end
29
+
30
+ def publish(build)
31
+ BuildMailer.template_root = File.expand_path(File.dirname(__FILE__) + "/../../../app/views")
32
+ BuildMailer.delivery_method = @delivery_method
33
+ BuildMailer.deliver_email(build, self)
34
+ end
35
+ end
36
+
37
+ class BuildMailer < ActionMailer::Base
38
+ def email(build, email_publisher, foo=nil, bar=nil)
39
+ @delivery_method = email_publisher.delivery_method
40
+ Log.info("Sending email to #{email_publisher.to.inspect} via #{@delivery_method}")
41
+ @recipients = email_publisher.to.split(%r{,\s*})
42
+
43
+ @from = email_publisher.from
44
+
45
+ @subject = "#{build.project.name} Build #{build.status_message}"
46
+ @sent_on = Time.new.utc
47
+ @headers['Content-Type'] = "text/html"
48
+ @body["build"] = build
49
+ end
50
+
51
+ # We have to define this, since our name is used to find the email template
52
+ class << self
53
+ def to_s
54
+ "Build"
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,49 @@
1
+ require 'fileutils'
2
+ require 'rscm/path_converter' #TODO: move safer_popen to popen_ext.rb
3
+ require 'damagecontrol/publisher/base'
4
+
5
+ module DamageControl
6
+
7
+ class Build
8
+ def execute_publisher_stdout
9
+ File.expand_path("#{execute_publisher_dir}/stdout.log")
10
+ end
11
+
12
+ def execute_publisher_stderr
13
+ File.expand_path("#{execute_publisher_dir}/stderr.log")
14
+ end
15
+
16
+ def execute_publisher_dir
17
+ File.expand_path("#{dir}/execute_publisher")
18
+ end
19
+ end
20
+
21
+ module Publisher
22
+ class Execute < Base
23
+ #register self
24
+
25
+ ann :description => "Command line"
26
+ ann :tip => "Stdout and stderr for the command will be made available on the build page. Don't redirect streams."
27
+ attr_accessor :command_line
28
+
29
+ ann :description => "Directory"
30
+ ann :tip => "Relative directory (under checkout directory) where the command will be executed."
31
+ attr_accessor :command_line
32
+
33
+ def initialize
34
+ @command_line = "echo \"The build label is $DAMAGECONTROL_BUILD_LABEL\""
35
+ end
36
+
37
+ def name
38
+ "Execute"
39
+ end
40
+
41
+ def publish(build)
42
+ FileUtils.mkdir_p(build.execute_publisher_dir)
43
+ safer_popen("{@command_line} > \"#{build.execute_publisher_stdout}\" 2> \"#{build.execute_publisher_stderr}\"") do |io|
44
+ io.read
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,16 @@
1
+ require 'damagecontrol/publisher/base'
2
+
3
+ module DamageControl
4
+ module Publisher
5
+ class Execute < Base
6
+ #register self
7
+
8
+ def name
9
+ "Execute"
10
+ end
11
+
12
+ def publish(build)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,44 @@
1
+ require 'damagecontrol/publisher/base'
2
+ require 'ruby-growl'
3
+
4
+ module DamageControl
5
+ module Publisher
6
+ class Growl < Base
7
+ register self
8
+
9
+ NOTIFICATION_TYPES = ["Build Successful", "Build Failed"] unless defined? NOTIFICATION_TYPES
10
+
11
+ ann :description => "Hosts", :tip => "Comma-separated list of (OS X) hosts that will receive Growl notifications. Requires Growl 0.6 or later."
12
+ attr_reader :hosts
13
+
14
+ def initialize
15
+ @hosts = "localhost"
16
+ end
17
+
18
+ def name
19
+ "Growl"
20
+ end
21
+
22
+ def publish(build)
23
+ message = nil
24
+ index = nil
25
+ if(build.successful?)
26
+ message = "#{build.status_message} build (by #{build.changeset.developer})"
27
+ index = 0
28
+ else
29
+ message = "#{build.changeset.developer} broke the build"
30
+ index = 1
31
+ end
32
+ @hosts.split(%r{,\s*}).each do |host|
33
+ begin
34
+ g = ::Growl.new(host, "DamageControl (#{build.project.name})", NOTIFICATION_TYPES)
35
+ # A bug in Ruby-Growl (or Growl) prevents the message from being sticky.
36
+ g.notify(NOTIFICATION_TYPES[index], build.project.name, message, 0, true)
37
+ rescue Exception => e
38
+ Log.info("Growl publisher failed to notify #{host}: #{e.message}")
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,31 @@
1
+ require 'damagecontrol/publisher/base'
2
+
3
+ module DamageControl
4
+ module Publisher
5
+ class Irc < Base
6
+ #register self
7
+
8
+ ann :description => "IRC server"
9
+ attr_reader :server
10
+
11
+ ann :description => "IRC notification channel"
12
+ attr_reader :channel
13
+
14
+ ann :description => "DamageControl's IRC nick"
15
+ attr_reader :nick
16
+
17
+ def initialize
18
+ @server = "irc.codehaus.org"
19
+ @channel = "#xxxxxx"
20
+ @nick = "dcontrol"
21
+ end
22
+
23
+ def name
24
+ "IRC"
25
+ end
26
+
27
+ def publish(build)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,68 @@
1
+ require 'damagecontrol/publisher/base'
2
+ require 'jabber4r/jabber4r'
3
+
4
+
5
+ module DamageControl
6
+ module Publisher
7
+ class Jabber < Base
8
+ register self
9
+
10
+ ann :description => "DamageControl Jabber Id/Resource"
11
+ attr_reader :id_resource
12
+
13
+ ann :description => "DamageControl Jabber Password"
14
+ attr_reader :password
15
+
16
+ ann :description => "DamageControl's Friends"
17
+ attr_reader :friends
18
+
19
+ def initialize
20
+ @id_resource = "damagecontrol@jabber.codehaus.org/damagecontrol"
21
+ @friends = "aslak@jabber.codehaus.org"
22
+ end
23
+
24
+ def name
25
+ "Jabber"
26
+ end
27
+
28
+ def publish(build)
29
+ session = nil
30
+ begin
31
+ session = login
32
+ message = nil
33
+ if(build.successful?)
34
+ message = "#{build.project.name}: #{build.status_message} build (by #{build.changeset.developer})"
35
+ else
36
+ message = "#{build.project.name}: #{build.changeset.developer} broke the build"
37
+ end
38
+ @friends.split(%r{,\s*}).each do |friend|
39
+ begin
40
+ session.new_message(friend).set_subject(message).set_body(message).send
41
+ rescue Exception => e
42
+ Log.error "Failed to send Jabber message to #{friend}"
43
+ end
44
+ end
45
+ ensure
46
+ session.release if session
47
+ end
48
+ end
49
+
50
+ private
51
+
52
+ # Logs in and tries to register (and log in again) if login fails
53
+ def login(register_if_login_fails=true)
54
+ begin
55
+ session = ::Jabber::Session.bind(@id_resource, @password)
56
+ rescue
57
+ if(register_if_login_fails)
58
+ if(::Jabber::Session.register(@id_resource, @password))
59
+ login(false)
60
+ else
61
+ raise "Failed to register #{@id_resource}"
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,16 @@
1
+ require 'damagecontrol/publisher/base'
2
+
3
+ module DamageControl
4
+ module Publisher
5
+ class Execute < Base
6
+ #register self
7
+
8
+ def name
9
+ "Execute"
10
+ end
11
+
12
+ def publish(build)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ require 'damagecontrol/publisher/base'
2
+
3
+ # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/124460
4
+ module DamageControl
5
+ module Publisher
6
+ class X10Cm11A < Base
7
+ #register self
8
+
9
+ def name
10
+ "X10-CM11A"
11
+ end
12
+
13
+ def publish(build)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ require 'damagecontrol/publisher/base'
2
+
3
+ # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/124460
4
+ module DamageControl
5
+ module Publisher
6
+ class X10Cm17A < Base
7
+ #register self
8
+
9
+ def name
10
+ "X10-CM17A"
11
+ end
12
+
13
+ def publish(build)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ require 'damagecontrol/publisher/base'
2
+
3
+ module DamageControl
4
+ module Publisher
5
+ class Yahoo < Base
6
+ #register self
7
+
8
+ def name
9
+ "Yahoo"
10
+ end
11
+
12
+ def publish(build)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -33,9 +33,9 @@ module DamageControl
33
33
  File.open(project.changesets_rss_file, "w") do |io|
34
34
  rss_writer = DamageControl::Visitor::RssWriter.new(
35
35
  rss,
36
- "Changesets for #{@name}",
36
+ "Changesets for #{project.name}",
37
37
  "http://localhost:4712/", # TODO point to web version of changeset
38
- project.description,
38
+ project.name,
39
39
  project.tracker || Tracker::Null.new,
40
40
  project.scm_web || SCMWeb::Null.new
41
41
  )
@@ -1,4 +1,5 @@
1
1
  require 'rscm/path_converter'
2
+ require 'rscm/annotations'
2
3
 
3
4
  module DamageControl
4
5
  module Tracker
@@ -6,12 +7,23 @@ module DamageControl
6
7
  # Simple superclass so we can easily include mixins
7
8
  # for all subclasses in one fell swoop.
8
9
  class Base #:nodoc:
10
+ @@classes = []
11
+ def self.register(cls)
12
+ @@classes << cls unless @@classes.index(cls)
13
+ end
14
+
15
+ def self.classes
16
+ @@classes
17
+ end
18
+
9
19
  def htmlize(str)
10
20
  str.gsub(/\n/, "<br>")
11
21
  end
12
22
  end
13
23
 
14
24
  class Null < Base
25
+ register self
26
+
15
27
  def name
16
28
  "No Tracker"
17
29
  end
@@ -27,9 +39,12 @@ module DamageControl
27
39
  end
28
40
 
29
41
  class Bugzilla < Base
42
+ register self
43
+
44
+ ann :description => "Bugzilla URL", :tip => "The URL of the Bugzilla installation."
30
45
  attr_accessor :url
31
46
 
32
- def initialize(url=nil)
47
+ def initialize(url="http://bugzilla.org/")
33
48
  @url = url
34
49
  end
35
50
 
@@ -48,9 +63,12 @@ module DamageControl
48
63
  end
49
64
 
50
65
  class Trac < Base
66
+ register self
67
+
68
+ ann :description => "Trac URL", :tip => "The URL of the Trac installation. This URL should include no trailing slash. Example: http://my.trac.home/cgi-bin/trac.cgi"
51
69
  attr_accessor :url
52
70
 
53
- def initialize(url=nil)
71
+ def initialize(url="http://trac.org/")
54
72
  @url = url
55
73
  end
56
74
 
@@ -69,10 +87,15 @@ module DamageControl
69
87
  end
70
88
 
71
89
  class JIRA < Base
90
+ register self
91
+
92
+ ann :description => "Base URL", :tip => "The base URL of the JIRA installation (not the URL to the specific JIRA project)."
72
93
  attr_accessor :baseurl
94
+
95
+ ann :description => "Project id", :tip => "The id of the project - example: 'DC'"
73
96
  attr_accessor :project_id
74
97
 
75
- def initialize(baseurl=nil, project_id=nil)
98
+ def initialize(baseurl="http://jira.codehaus.org/", project_id="")
76
99
  @baseurl, @project_id = baseurl, project_id
77
100
  end
78
101
 
@@ -95,12 +118,19 @@ module DamageControl
95
118
  end
96
119
 
97
120
  class SourceForge < Base
121
+ register self
122
+
98
123
  PATTERN = /#([0-9]+)/
99
124
 
125
+ ann :description => "Project id"
126
+ ann :tip => "The id of the project (group_id). Example: <br><tt>http://sourceforge.net/tracker/index.php?func=detail&amp;aid=1051927&amp;group_id=<strong>7856</strong>&amp;atid=107856</tt>"
100
127
  attr_accessor :group_id
128
+
129
+ ann :description => "Tracker id"
130
+ ann :tip => "The id of the tracker (aid). Example: <br><tt>http://sourceforge.net/tracker/index.php?func=detail&amp;aid=<strong>1051927</strong>&amp;group_id=7856&amp;atid=107856</tt>."
101
131
  attr_accessor :tracker_id
102
132
 
103
- def initialize(group_id=nil, tracker_id=nil)
133
+ def initialize(group_id="", tracker_id="")
104
134
  @group_id, @tracker_id = group_id, tracker_id
105
135
  end
106
136
 
@@ -118,8 +148,15 @@ module DamageControl
118
148
  end
119
149
 
120
150
  class RubyForge < SourceForge
151
+ register self
152
+
153
+ ann :description => "Project id"
154
+ ann :tip => "The id of the project (group_id). Example: <br><tt>http://rubyforge.org/tracker/index.php?func=detail&amp;aid=1120&amp;group_id=<strong>426</strong>&amp;atid=1698</tt>."
155
+ attr_accessor :group_id
121
156
 
122
- # TODO: share the same rhtml template
157
+ ann :description => "Tracker id"
158
+ ann :tip => "The id of the tracker (aid). Example: <br><tt>http://rubyforge.org/tracker/index.php?func=detail&amp;aid=<strong>1120</strong>&amp;group_id=426&amp;atid=1698</tt>."
159
+ attr_accessor :tracker_id
123
160
 
124
161
  def name
125
162
  "RubyForge"
@@ -135,10 +172,15 @@ module DamageControl
135
172
  end
136
173
 
137
174
  class Scarab < Base
175
+ register self
176
+
177
+ ann :description => "Base URL", :tip => "The URL of the Scarab installation."
138
178
  attr_accessor :baseurl
179
+
180
+ ann :description => "Scarab Module", :tip => "The Scarab Module key."
139
181
  attr_accessor :module_key
140
182
 
141
- def initialize(baseurl=nil, module_key=nil)
183
+ def initialize(baseurl="http://scarab.org/", module_key="")
142
184
  @baseurl, @module_key = baseurl, module_key
143
185
  end
144
186