Module: CIJoe::Email

Defined in:
lib/cijoe/email.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.activateObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cijoe/email.rb', line 5

def self.activate
  if valid_config?
    CIJoe::Build.class_eval do
      include CIJoe::Email
    end

    puts "Loaded Email notifier"
  else
    puts "Can't load Email notifier."
    puts "Please add the following to your project's .git/config:"
    puts "[email]"
    puts "\tto = [email protected]"
    puts "\tuser = horst"
    puts "\tpass = passw0rd"
    puts "\thost = mail.example.com"
  end
end

.configObject



23
24
25
26
27
28
29
30
# File 'lib/cijoe/email.rb', line 23

def self.config
  @config ||= {
    :to        => Config.email.to.to_s, 
    :user      => Config.email.user.to_s,
    :pass      => Config.email.pass.to_s,
    :host      => Config.email.host.to_s
  }
end

.valid_config?Boolean

Returns:

  • (Boolean)


32
33
34
35
36
# File 'lib/cijoe/email.rb', line 32

def self.valid_config?
  %w( host user pass to ).all? do |key|
    !config[key.intern].empty?
  end
end

Instance Method Details

#notifyObject



38
39
40
41
42
43
44
45
46
# File 'lib/cijoe/email.rb', line 38

def notify
  options = {
    :to => Email.config[:to],
    :from => Email.config[:to],
    :subject => 'Build failed',
    :body => "The commit #{commit.url} causes the build to fail."
  }
  MmMail.send(options) if failed?
end