Class: Integrity::Notifier::Growl

Inherits:
Notifier::Base
  • Object
show all
Defined in:
lib/notifier/growl.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(build, config = {}) ⇒ Growl

Returns a new instance of Growl.



9
10
11
12
13
14
15
# File 'lib/notifier/growl.rb', line 9

def initialize(build, config = {})
  @addresses = config['addresses'].nil? ? [] : config.delete('addresses').split(/,\s+?|\s+/)
  @growls = @addresses.map do |address|
    ::Growl.new address, "Integrity", ["Build Successful", "Build Failed"]
  end
  super
end

Class Method Details

.to_hamlObject



17
18
19
# File 'lib/notifier/growl.rb', line 17

def self.to_haml
  File.read File.dirname(__FILE__) / "config.haml"
end

Instance Method Details

#deliver!Object



21
22
23
24
25
# File 'lib/notifier/growl.rb', line 21

def deliver!
  @growls.each do |g|
    g.notify growl_type, "#{commit.project.name}: #{growl_type}", message
  end
end

#growl_typeObject



27
28
29
# File 'lib/notifier/growl.rb', line 27

def growl_type
  "Build #{commit.successful? ? 'Successful' : 'Failed'}"
end

#messageObject



31
32
33
34
35
36
37
38
39
# File 'lib/notifier/growl.rb', line 31

def message
  @message ||= begin
    <<-MSG.gsub!(/^ {12}/, '')
      Author: #{commit.author.name}
    
      #{commit.message}
    MSG
  end
end