Module: Janky::Notifier

Defined in:
lib/janky/notifier.rb,
lib/janky/notifier/mock.rb,
lib/janky/notifier/multi.rb,
lib/janky/notifier/chat_service.rb,
lib/janky/notifier/github_status.rb,
lib/janky/notifier/failure_service.rb

Defined Under Namespace

Classes: ChatService, FailureService, GithubStatus, Mock, Multi

Class Method Summary collapse

Class Method Details

.adapterObject

The implementation used to send notifications.

Returns a Multi instance by default or Mock when in mock mode.



42
43
44
# File 'lib/janky/notifier.rb', line 42

def self.adapter
  @adapter ||= Multi.new(@notifiers)
end

.completed(build) ⇒ Object

Called whenever a build completes.

build - the Build record.

Returns nothing.



35
36
37
# File 'lib/janky/notifier.rb', line 35

def self.completed(build)
  adapter.completed(build)
end

.empty?Boolean

Was any notification sent out? Only available when mocked.

Returns a Boolean.

Returns:

  • (Boolean)


65
66
67
# File 'lib/janky/notifier.rb', line 65

def self.empty?
  notifications.empty?
end

.enable_mock!Object

Enable mocking. Once enabled, notifications are stored in a in-memory Array exposed by the notifications method.

Returns nothing.



50
51
52
# File 'lib/janky/notifier.rb', line 50

def self.enable_mock!
  @adapter = Mock.new
end

.failure?(repo, branch, room = nil) ⇒ Boolean

Same as ‘success?` but for failed notifications.

Returns:

  • (Boolean)


82
83
84
# File 'lib/janky/notifier.rb', line 82

def self.failure?(repo, branch, room=nil)
  adapter.failure?(repo, branch, room)
end

.notificationsObject

Access the notification log. Only available when mocked.

Returns an Array of notified Builds.



89
90
91
# File 'lib/janky/notifier.rb', line 89

def self.notifications
  adapter.notifications
end

.queued(build) ⇒ Object

Called whenever a build is queued

build - the Build record.

Returns nothing



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

def self.queued(build)
  adapter.queued(build)
end

.reset!Object

Reset notification log. Only available when mocked. Typically called before each test.

Returns nothing.



58
59
60
# File 'lib/janky/notifier.rb', line 58

def self.reset!
  adapter.reset!
end

.setup(notifiers) ⇒ Object

Setup the notifier.

notifiers - One or more notifiers implementation to notify with.

Returns nothing.



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

def self.setup(notifiers)
  @adapter = Multi.new(Array(notifiers))
end

.started(build) ⇒ Object

Called whenever a build starts.

build - the Build record.

Returns nothing.



26
27
28
# File 'lib/janky/notifier.rb', line 26

def self.started(build)
  adapter.started(build)
end

.success?(repo, branch, room = nil) ⇒ Boolean

Was a success notification sent to the given room for the given repo and branch?

repo - the String repository name. branch - the String branch name. room - the optional String Campfire room slug.

Returns a boolean.

Returns:

  • (Boolean)


77
78
79
# File 'lib/janky/notifier.rb', line 77

def self.success?(repo, branch, room=nil)
  adapter.success?(repo, branch, room)
end