Class: Gitdocs::Notifier

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/gitdocs/notifier.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.disconnectvoid

This method returns an undefined value.



63
64
65
# File 'lib/gitdocs/notifier.rb', line 63

def self.disconnect
  instance.disconnect
end

.error(title, message) ⇒ void .error(title, message, show_notification) ⇒ void

This method returns an undefined value.

Overloads:

  • .error(title, message) ⇒ void

    Parameters:

    • title (String)
    • message (String)
  • .error(title, message, show_notification) ⇒ void

    Parameters:

    • title (String)
    • message (String)
    • show_notification (Boolean)


50
51
52
53
54
55
56
57
58
59
60
# File 'lib/gitdocs/notifier.rb', line 50

def self.error(title, message, show_notification = true)
  Gitdocs.log_error("#{title}: #{message}")

  if show_notification
    instance.notify(title, message, :failed)
  else
    Kernel.warn("#{title}: #{message}")
  end
rescue # rubocop:disable Lint/HandleExceptions
  # Prevent StandardErrors from stopping the daemon.
end

.info(title, message, show_notification) ⇒ void

This method returns an undefined value.

Parameters:

  • title (String)
  • message (String)
  • show_notification (Boolean)


13
14
15
16
17
18
19
20
21
22
# File 'lib/gitdocs/notifier.rb', line 13

def self.info(title, message, show_notification)
  Gitdocs.log_info("#{title}: #{message}")
  if show_notification
    instance.notify(title, message, :success)
  else
    puts("#{title}: #{message}")
  end
rescue # rubocop:disable Lint/HandleExceptions
  # Prevent StandardErrors from stopping the daemon.
end

.warn(title, message, show_notification) ⇒ void

This method returns an undefined value.

Parameters:

  • title (String)
  • message (String)
  • show_notification (Boolean)


29
30
31
32
33
34
35
36
37
38
# File 'lib/gitdocs/notifier.rb', line 29

def self.warn(title, message, show_notification)
  Gitdocs.log_warn("#{title}: #{message}")
  if show_notification
    instance.notify(title, message, :pending)
  else
    Kernel.warn("#{title}: #{message}")
  end
rescue # rubocop:disable Lint/HandleExceptions
  # Prevent StandardErrors from stopping the daemon.
end

Instance Method Details

#disconnectvoid

This method returns an undefined value.



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

def disconnect
  @notifier.disconnect if @notifier
  @notifier = nil
end

#notify(title, message, type) ⇒ void

This method returns an undefined value.

Parameters:

  • title (String)
  • message (String)
  • type (:success, :pending, :failed)


75
76
77
78
# File 'lib/gitdocs/notifier.rb', line 75

def notify(title, message, type)
  @notifier ||= Notiffany.connect
  @notifier.notify(message, title: title, image: type)
end