Class: Guard::Librarian::Notifier

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

Class Method Summary collapse

Class Method Details

.guard_image(result) ⇒ Object

failed | success



18
19
20
21
22
23
24
# File 'lib/guard/librarian/notifier.rb', line 18

def self.guard_image(result)
  icon = if result
    :success
  else
    :failed
  end
end

.guard_message(result, duration) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/guard/librarian/notifier.rb', line 6

def self.guard_message(result, duration)
  case result
  when 'up-to-date'
    "Cookbooks already up-to-date"
  when true
    "Cookbooks have been updated\nin %.1f seconds." % [duration]
  else
    "Cookbooks can't be updated,\nplease check manually."
  end
end

.notify(result, duration) ⇒ Object



26
27
28
29
30
31
# File 'lib/guard/librarian/notifier.rb', line 26

def self.notify(result, duration)
  message = guard_message(result, duration)
  image   = guard_image(result)

  ::Guard::Notifier.notify(message, :title => 'Cookbooks updated', :image => image)
end