Class: Spectator::SuccessNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/spectator/success_notifier.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ SuccessNotifier

Returns a new instance of SuccessNotifier.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/spectator/success_notifier.rb', line 7

def initialize(config)
  @config ||= config
  if osx?
    begin
      require 'terminal-notifier'
    rescue LoadError => e
      $stderr.puts e.message
      $stderr.puts 'On OSX you should use notification center: gem install terminal-notifier'.red
    end
  end
end

Instance Method Details

#failed_messageObject



29
30
31
32
# File 'lib/spectator/success_notifier.rb', line 29

def failed_message
  @failed_message ||= osx? ? '💔 FAILED'.freeze :
                             '♠♠ FAILED >:( ♠♠'.freeze
end

#notify(success) ⇒ Object



19
20
21
22
# File 'lib/spectator/success_notifier.rb', line 19

def notify(success)
  message = success ? success_message : failed_message
  Thread.new { Notify.notify 'RSpec Result:', message }
end

#osx?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/spectator/success_notifier.rb', line 34

def osx?
  @osx ||= RUBY_PLATFORM.include? 'darwin'
end

#success_messageObject



24
25
26
27
# File 'lib/spectator/success_notifier.rb', line 24

def success_message
  @success_message ||= osx? ? '🎉 SUCCESS'.freeze :
                              '♥♥ SUCCESS :) ♥♥'.freeze
end