Class: Guard::Karma::Notifier

Inherits:
Object
  • Object
show all
Defined in:
lib/guard/karma/notifier.rb

Constant Summary collapse

RUNNING_TITLE =
'Karma running...'.freeze
FAILURE_TITLE =
'Karma failure.'.freeze
SUCCESS_TITLE =
'Karma success.'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Notifier

Returns a new instance of Notifier.



10
11
12
# File 'lib/guard/karma/notifier.rb', line 10

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#notify(summary) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/guard/karma/notifier.rb', line 20

def notify(summary)
  return unless options[:notification]

  run_count, total_count, failure_count = parse_summary(summary)

  body = "Executed #{run_count} of #{total_count}"
  if failure_count > 0
    body += " with #{failure_count} failure(s)"
  end

  title = title(failure_count)
  image = image(failure_count)
  priority = priority(image)
  Guard::Compat::UI.notify(body, title: title, image: image, priority: priority)
end

#notify_startObject



14
15
16
17
18
# File 'lib/guard/karma/notifier.rb', line 14

def notify_start
  return unless options[:notification]

  Guard::Compat::UI.notify('', title: RUNNING_TITLE, image: :pending, priority: -1)
end