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(commit, config) ⇒ Base

Returns a new instance of Base.



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

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

Instance Attribute Details

#commitObject (readonly)

Returns the value of attribute commit.



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

def commit
  @commit
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

#buildObject



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

def build
  warn "Notifier::Base#build is deprecated, use Notifier::Base#commit instead"
  commit
end

#commit_urlObject



48
49
50
51
# File 'lib/integrity/notifier/base.rb', line 48

def commit_url
  raise if Integrity.config[:base_uri].nil?
  Integrity.config[:base_uri] / commit.project.permalink / "commits" / commit.identifier
end

#deliver!Object

Raises:

  • (NoMethodError)


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

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

#full_messageObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/integrity/notifier/base.rb', line 32

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

Commit Message: #{commit.message}
Commit Date: #{commit.committed_at}
Commit Author: #{commit.author.name}

Link: #{commit_url}

Build Output:

#{stripped_commit_output}
EOM
end

#short_messageObject



28
29
30
# File 'lib/integrity/notifier/base.rb', line 28

def short_message
  commit.human_readable_status
end