Module: Boppers

Defined in:
lib/boppers.rb,
lib/boppers/cli.rb,
lib/boppers/utils.rb,
lib/boppers/runner.rb,
lib/boppers/version.rb,
lib/boppers/http_client.rb,
lib/boppers/configuration.rb,
lib/boppers/generator/app.rb,
lib/boppers/notifier/slack.rb,
lib/boppers/notifier/stdout.rb,
lib/boppers/generator/plugin.rb,
lib/boppers/notifier/hipchat.rb,
lib/boppers/notifier/twitter.rb,
lib/boppers/notifier/pushover.rb,
lib/boppers/notifier/sendgrid.rb,
lib/boppers/notifier/telegram.rb,
lib/boppers/testing/bopper_linter.rb,
lib/boppers/testing/notifier_linter.rb

Defined Under Namespace

Modules: Generator, Notifier, Testing, Utils Classes: CLI, Configuration, Runner

Constant Summary collapse

VERSION =
"0.0.10"
HttpClient =
Aitch::Namespace.new

Class Method Summary collapse

Class Method Details

.configurationObject



17
18
19
# File 'lib/boppers.rb', line 17

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

.configure {|configuration| ... } ⇒ Object

Yields:



13
14
15
# File 'lib/boppers.rb', line 13

def self.configure
  yield configuration
end

.notify(name, title:, message:, options: {}) ⇒ Object

Send notification. The ‘name` identifies the message type, which is used to filter out the notifications and their subscribers.



24
25
26
27
28
29
30
31
# File 'lib/boppers.rb', line 24

def self.notify(name, title:, message:, options: {})
  configuration
    .notifiers
    .select {|notifier| subscribed?(notifier, name) }
    .each do |notifier|
      notifier.call(title, message, options)
    end
end

.subscribed?(notifier, name) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
39
40
41
42
# File 'lib/boppers.rb', line 33

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