Module: Sc4ry::Notifiers

Defined in:
lib/sc4ry/notifiers/init.rb,
lib/sc4ry/notifiers/mattermost.rb,
lib/sc4ry/notifiers/prometheus.rb

Overview

Note:

namespace

Sc4ry::Notifiers module

Defined Under Namespace

Classes: Mattermost, Prometheus

Constant Summary collapse

DEFAULT_NOTIFIERS =

default notifiers specifications

{ prometheus: { class: Sc4ry::Notifiers::Prometheus, config: { url: 'http://localhost:9091' } },
mattermost: { class: Sc4ry::Notifiers::Mattermost, config: { url: 'http://localhost:9999', token: '<CHANGE_ME>' } } }
@@notifiers_list =
DEFAULT_NOTIFIERS.dup

Class Method Summary collapse

Class Method Details

.config(name:, config:) ⇒ Hash

class method how configure a specific notifier

Parameters:

  • name (Symbol)

    a notifier name

  • config (Hash)

    a notifier config

Returns:

  • (Hash)

    the notifier structure



53
54
55
56
# File 'lib/sc4ry/notifiers/init.rb', line 53

def self.config(name:, config:)
  @@notifiers_list[name][:config] = config
  config
end

.display_config(notifier:) ⇒ Hash

class method how display a specific notifier config

Parameters:

  • notifier (Symbol)

    a notifier name

Returns:

  • (Hash)

    the config



19
20
21
22
23
24
25
26
# File 'lib/sc4ry/notifiers/init.rb', line 19

def self.display_config(notifier:)
  unless @@notifiers_list.include? notifier
    raise Sc4ry::Exceptions::Sc4ryNotifierError,
          "Notifier #{notifier} not found"
  end

  @@notifiers_list[notifier][:config]
end

.get(name:) ⇒ Hash

class method how return a specific notifier by name

Parameters:

  • name (Symbol)

    a notifier name

Returns:

  • (Hash)

    the notifier structure



37
38
39
# File 'lib/sc4ry/notifiers/init.rb', line 37

def self.get(name:)
  @@notifiers_list[name]
end

.listArray

class method how return the list of known notifiers

Returns:

  • (Array)

    a list of [Symbol] notifiers name



30
31
32
# File 'lib/sc4ry/notifiers/init.rb', line 30

def self.list
  @@notifiers_list.keys
end

.register(name:, definition:) ⇒ Hash

class method how register a specific notifier

Parameters:

  • name (Symbol)

    a notifier name

  • definition (Hash)

    a notifier definition

Returns:

  • (Hash)

    the notifier structure



45
46
47
# File 'lib/sc4ry/notifiers/init.rb', line 45

def self.register(name:, definition:)
  @@notifiers_list[name] = definition
end