Class: Integrity::Notifier::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/integrity/notifier/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(build, config) ⇒ Base

Returns a new instance of Base.



14
15
16
17
# File 'lib/integrity/notifier/base.rb', line 14

def initialize(build, config)
  @build = build
  @config = config
end

Instance Attribute Details

#buildObject (readonly)

Returns the value of attribute build.



12
13
14
# File 'lib/integrity/notifier/base.rb', line 12

def build
  @build
end

Class Method Details

.notify_of_build(build, config) ⇒ Object



4
5
6
# File 'lib/integrity/notifier/base.rb', line 4

def self.notify_of_build(build, config)
  Timeout.timeout(8) { new(build, config).deliver! }
end

.to_hamlObject

Raises:

  • (NoMethodError)


8
9
10
# File 'lib/integrity/notifier/base.rb', line 8

def self.to_haml
  raise NoMethodError, "you need to implement this method in your notifier"
end

Instance Method Details

#build_urlObject



43
44
45
46
# File 'lib/integrity/notifier/base.rb', line 43

def build_url
  raise if Integrity.config[:base_uri].nil?
  Integrity.config[:base_uri] / build.project.permalink / "builds" / build.commit_identifier
end

#deliver!Object

Raises:

  • (NoMethodError)


19
20
21
# File 'lib/integrity/notifier/base.rb', line 19

def deliver!
  raise NoMethodError, "you need to implement this method in your notifier"
end

#full_messageObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/integrity/notifier/base.rb', line 27

def full_message
  <<-EOM
"Build #{build.commit_identifier} #{build.successful? ? "was successful" : "failed"}"

Commit Message: #{build.commit_message}
Commit Date: #{build.commited_at}
Commit Author: #{build.commit_author.name}

Link: #{build_url}

Build Output:

#{stripped_build_output}
EOM
end

#short_messageObject



23
24
25
# File 'lib/integrity/notifier/base.rb', line 23

def short_message
  "Build #{build.short_commit_identifier} #{build.successful? ? "was successful" : "failed"}"
end