notifier 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/notifier/version.rb +1 -1
- data/lib/notifier.rb +8 -2
- data/test/notifier_test.rb +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 377af5a8879bb88936db164c3fa8e4db3b91e8c5792140b696b27b3ec209b116
|
|
4
|
+
data.tar.gz: 303c3a76b92b391b46e6e934185400efde32171bfe7fa3f39d16fe3c4262ca5e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3e85191b23b8f6d25748a67ae87b468c8888122552359f5442e6b859fc4d3a0260770e687506639898ccab1f610c551efed2a185bce8eac2d58d8afb1368522d
|
|
7
|
+
data.tar.gz: cebec2c75267e1b7d76a922eb11cd214f310d480f8d8c3a292d2263011ec957c01ece5e33f87c761fc1ad2245d3663e171146ebf03554cdfc433691837bbf59f
|
data/lib/notifier/version.rb
CHANGED
data/lib/notifier.rb
CHANGED
|
@@ -25,13 +25,16 @@ module Notifier
|
|
|
25
25
|
attr_accessor :default_notifier
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
def setup
|
|
29
|
+
self.default_notifier = ENV.fetch("NOTIFIER", nil)
|
|
30
|
+
end
|
|
31
|
+
|
|
28
32
|
def skip_constants
|
|
29
33
|
@skip_constants ||= %w[Noop Adapters Version]
|
|
30
34
|
end
|
|
31
35
|
|
|
32
36
|
def notifier
|
|
33
|
-
supported_notifier_from_name(
|
|
34
|
-
supported_notifiers.first
|
|
37
|
+
supported_notifier_from_name(default_notifier) || supported_notifiers.first
|
|
35
38
|
end
|
|
36
39
|
|
|
37
40
|
def notify(options)
|
|
@@ -69,4 +72,7 @@ module Notifier
|
|
|
69
72
|
string.gsub(/_(.)/sm) { Regexp.last_match(1).upcase.to_s }
|
|
70
73
|
.gsub(/^(.)/) { Regexp.last_match(1).upcase.to_s }
|
|
71
74
|
end
|
|
75
|
+
|
|
76
|
+
# Run setup, which sets default notifier from env var.
|
|
77
|
+
setup
|
|
72
78
|
end
|
data/test/notifier_test.rb
CHANGED
|
@@ -38,15 +38,15 @@ class NotifierTest < Minitest::Test
|
|
|
38
38
|
assert_equal Notifier::Knotify, Notifier.notifier
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
test "
|
|
42
|
-
|
|
41
|
+
test "sets default notifier from env var" do
|
|
42
|
+
# Comes later in the list
|
|
43
|
+
ENV["NOTIFIER"] = "snarl"
|
|
43
44
|
|
|
45
|
+
Notifier.setup
|
|
44
46
|
Notifier::Snarl.stubs(:supported?).returns(true)
|
|
45
47
|
Notifier::Knotify.stubs(:supported?).returns(true)
|
|
46
48
|
|
|
47
|
-
Notifier.
|
|
48
|
-
|
|
49
|
-
assert_equal Notifier::Knotify, Notifier.notifier
|
|
49
|
+
assert_equal Notifier::Snarl, Notifier.notifier
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
test "sends notification" do
|