Class: Cerberus::Publisher::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/cerberus/publisher/base.rb

Direct Known Subclasses

Campfire, IRC, Jabber, Mail, RSS, Twitter

Class Method Summary collapse

Class Method Details

.formatted_message(state, manager, options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/cerberus/publisher/base.rb', line 6

def self.formatted_message(state, manager, options)
  subject = 
  case state.current_state
  when :setup
    "Cerberus set up for project (#{manager.scm.current_revision})"
  when :broken
    additional_message = nil
    if state.previous_brokeness and state.current_brokeness
      additional_message =
      case
        when state.previous_brokeness > state.current_brokeness
          ' but getting better'
        when state.previous_brokeness < state.current_brokeness
          ' and getting worse'
      end
    end
    "Build still broken#{additional_message} (#{manager.scm.current_revision})"

  #FIXME instead of using last author as person that broken build try to guess it. I.e. only if one author since last commit did commit - then he broken it.
  when :failed
    "Build broken by #{manager.scm.last_author} (#{manager.scm.current_revision})"
  when :revival
    "Build fixed by #{manager.scm.last_author} (#{manager.scm.current_revision})"
  when :successful
    "Build successful (#{manager.scm.current_revision})"
  else                              
    raise "Unknown build state '#{state.current_state.to_s}'"
  end

  subject = "[#{options[:application_name]}]#{options[:publisher, :extra_subject]} #{subject}"
  generated_by = "--\nThis email generated by Cerberus tool ver. #{Cerberus::VERSION}, http://cerberus.rubyforge.org/"
  body = [ manager.scm.last_commit_message ]
  if options[:changeset_url]
    body << options[:changeset_url] + manager.scm.current_revision.to_s + "\n"
  end
  body += [ manager.setup_script_output, manager.builder.output, generated_by ].compact

  return subject, body.join("\n")
end