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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 785cd994046d6e1654c06999c5909ab81b76056cd463c7b63cd72c58e096966e
4
- data.tar.gz: a9db9eb14963b03a8ca59939a2a8afbf30994fa8b3fd1a8eea40689b72fcb298
3
+ metadata.gz: 377af5a8879bb88936db164c3fa8e4db3b91e8c5792140b696b27b3ec209b116
4
+ data.tar.gz: 303c3a76b92b391b46e6e934185400efde32171bfe7fa3f39d16fe3c4262ca5e
5
5
  SHA512:
6
- metadata.gz: f4b7c8f09062e9589abb6fa89c2266bf16c02d826ed428e3d04d139b651d370ca952ffc3ccaf53aa0f856f798ae5d7cabf14a34a29a217896a74f35973c104cb
7
- data.tar.gz: 12c3ad81bd54842c608b84e3b4de1393e457e32f42e25c391ddae3952ebb7128419eb8009e26be14bc1cc656ad5a7d09d964755a2d40698cfd37a7215aee11a1
6
+ metadata.gz: 3e85191b23b8f6d25748a67ae87b468c8888122552359f5442e6b859fc4d3a0260770e687506639898ccab1f610c551efed2a185bce8eac2d58d8afb1368522d
7
+ data.tar.gz: cebec2c75267e1b7d76a922eb11cd214f310d480f8d8c3a292d2263011ec957c01ece5e33f87c761fc1ad2245d3663e171146ebf03554cdfc433691837bbf59f
@@ -4,7 +4,7 @@ module Notifier
4
4
  module Version
5
5
  MAJOR = 1
6
6
  MINOR = 3
7
- PATCH = 0
7
+ PATCH = 1
8
8
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}".freeze
9
9
  end
10
10
  end
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(ENV.fetch("NOTIFIER", default_notifier)) ||
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
@@ -38,15 +38,15 @@ class NotifierTest < Minitest::Test
38
38
  assert_equal Notifier::Knotify, Notifier.notifier
39
39
  end
40
40
 
41
- test "prefers default notifier using env var" do
42
- ENV["NOTIFIER"] = "knotify"
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.default_notifier = :snarl
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira