boppers 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gems.locked +1 -1
- data/lib/boppers.rb +6 -3
- data/lib/boppers/notifier/slack.rb +6 -1
- data/lib/boppers/notifier/stdout.rb +10 -3
- data/lib/boppers/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d57b01f4de1f2472c5b6ee6c84c698aad3f6a302
|
4
|
+
data.tar.gz: 6cdeb3cb8e621ad6e218bae54f7b6448ce861739
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b136924d3bc70057a24d7ad093615dfd8a6d3264758128ffd1faec58d63f2c4a2dd83d7af56b626665c23adc812f53560e980bd4f23f2d0c29d9bf7f54d0db2
|
7
|
+
data.tar.gz: 8d830fe8c126c43ced453346dcc3261fbb88b7cbe8ac9bd651d37e58f3bc9a635d012a06cd2a721a0c9796f64e9d6bf195ff90e835d0bbdb8784fe690392ed8e
|
data/gems.locked
CHANGED
data/lib/boppers.rb
CHANGED
@@ -31,9 +31,12 @@ module Boppers
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def self.subscribed?(notifier, name)
|
34
|
-
subscriptions =
|
35
|
-
|
36
|
-
|
34
|
+
subscriptions = if notifier.respond_to?(:subscribe)
|
35
|
+
[notifier.subscribe || name]
|
36
|
+
else
|
37
|
+
[name]
|
38
|
+
end
|
39
|
+
subscriptions = subscriptions.flatten.compact.map(&:to_sym)
|
37
40
|
|
38
41
|
subscriptions.include?(name)
|
39
42
|
end
|
@@ -3,6 +3,11 @@
|
|
3
3
|
module Boppers
|
4
4
|
module Notifier
|
5
5
|
class Slack
|
6
|
+
COLORS = {
|
7
|
+
green: "good",
|
8
|
+
red: "danger"
|
9
|
+
}.freeze
|
10
|
+
|
6
11
|
attr_reader :api_token, :channel, :subscribe
|
7
12
|
|
8
13
|
def initialize(api_token:, channel:, subscribe: nil)
|
@@ -22,7 +27,7 @@ module Boppers
|
|
22
27
|
fallback: message,
|
23
28
|
title: subject,
|
24
29
|
text: message,
|
25
|
-
color: options[:color]
|
30
|
+
color: COLORS.fetch(options[:color])
|
26
31
|
}
|
27
32
|
]
|
28
33
|
)
|
@@ -3,17 +3,24 @@
|
|
3
3
|
module Boppers
|
4
4
|
module Notifier
|
5
5
|
class Stdout
|
6
|
+
COLORS = {
|
7
|
+
green: "\e[32m",
|
8
|
+
red: "\e[31m"
|
9
|
+
}.freeze
|
10
|
+
|
6
11
|
attr_reader :subscribe
|
7
12
|
|
8
13
|
def initialize(subscribe: nil)
|
9
14
|
@subscribe = subscribe
|
10
15
|
end
|
11
16
|
|
12
|
-
def call(title, message,
|
17
|
+
def call(title, message, options)
|
18
|
+
color = COLORS.fetch(options[:color], "\e[0m")
|
19
|
+
|
13
20
|
puts [
|
14
|
-
"## #{title}",
|
21
|
+
"#{color}## #{title}",
|
15
22
|
message.gsub(/^/m, " "),
|
16
|
-
"\n"
|
23
|
+
"\e[0m\n"
|
17
24
|
].join("\n")
|
18
25
|
end
|
19
26
|
end
|
data/lib/boppers/version.rb
CHANGED