Sha256: 9a709bd42e56bd97638416fc13ebeada394975b192741fd5fac0eeb8b6a45bb4

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Boppers
  require "thor"
  require "aitch"

  require "boppers/version"
  require "boppers/cli"
  require "boppers/configuration"
  require "boppers/http_client"
  require "boppers/runner"

  def self.configure
    yield configuration
  end

  def self.configuration
    @configuration ||= Configuration.new
  end

  # Send notification.
  # The `name` identifies the message type, which is used to
  # filter out the notifications and their subscribers.
  def self.notify(name, title:, message:, options: {})
    configuration
      .notifiers
      .select {|notifier| subscribed?(notifier, name) }
      .each do |notifier|
        notifier.call(title, message, options)
      end
  end

  def self.subscribed?(notifier, name)
    subscriptions = if notifier.respond_to?(:subscribe)
                      [notifier.subscribe || name]
                    else
                      [name]
                    end
    subscriptions = subscriptions.flatten.compact.map(&:to_sym)

    subscriptions.include?(name)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
boppers-0.0.10 lib/boppers.rb
boppers-0.0.9 lib/boppers.rb
boppers-0.0.8 lib/boppers.rb
boppers-0.0.7 lib/boppers.rb
boppers-0.0.6 lib/boppers.rb
boppers-0.0.5 lib/boppers.rb
boppers-0.0.3 lib/boppers.rb