Module: Travis::Tools::Notification

Defined in:
lib/travis/tools/notification.rb

Defined Under Namespace

Classes: Dummy, Growl, LibNotify, OSX

Constant Summary collapse

DEFAULT =
%i[osx growl libnotify].freeze
ICON =
Assets['notifications/icon.png']

Class Method Summary collapse

Class Method Details

.get(name) ⇒ Object

Raises:

  • (ArgumentError)


24
25
26
27
28
29
# File 'lib/travis/tools/notification.rb', line 24

def get(name)
  const = constants.detect { |c| c.to_s[/[^:]+$/].downcase == name.to_s }
  raise ArgumentError, 'unknown notifications type %p' % name unless const

  const_get(const).new
end

.new(*list) ⇒ Object

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
# File 'lib/travis/tools/notification.rb', line 16

def new(*list)
  list.concat(DEFAULT) if list.empty?
  notification = list.map { |n| get(n) }.detect { |n| n.available? }
  raise ArgumentError, "no notification system found (looked for #{list.join(', ')})" unless notification

  notification
end