junk_drawer 1.6.3 → 1.7.0
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/.gitignore +1 -0
- data/README.md +34 -3
- data/lib/junk_drawer/notifier.rb +7 -8
- data/lib/junk_drawer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41bdf84aed0cada468a2754eaeb98650346f35789f2ffaae69b2b79026abe720
|
4
|
+
data.tar.gz: 7e8394ce972f2eeb72d2c28ba5966a67da30f1561575595d329d8533781a3c46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55ae0cc6d20c582a88be1cd28d92bb2942ffc44d671aabff3cc4d6c6dbd3c1ee61d5232f2e86d6cfa44422d98c8daf86563c097db6ef078261d584a80c389c9a
|
7
|
+
data.tar.gz: 07d25dce3efde1f44f6d41382453d2e3b1d9f7c2cf7d5658006acd6bf21ecfe4c62237e64a3a324094d1bf17ea6ca7a023395ae09da531a07830fa7538941308
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -27,9 +27,18 @@ gem 'junk_drawer', require: 'junk_drawer/rails'
|
|
27
27
|
|
28
28
|
### Contents
|
29
29
|
|
30
|
-
- [JunkDrawer
|
31
|
-
- [
|
32
|
-
- [
|
30
|
+
- [JunkDrawer](#junkdrawer)
|
31
|
+
- [Installation](#installation)
|
32
|
+
- [Contents](#contents)
|
33
|
+
- [Usage](#usage)
|
34
|
+
- [JunkDrawer::Callable](#junkdrawercallable)
|
35
|
+
- [JunkDrawer::Notifier](#junkdrawernotifier)
|
36
|
+
- [Rails](#rails)
|
37
|
+
- [JunkDrawer::BulkUpdatable](#junkdrawerbulkupdatable)
|
38
|
+
- [Caveats](#caveats)
|
39
|
+
- [Development](#development)
|
40
|
+
- [Contributing](#contributing)
|
41
|
+
- [License](#license)
|
33
42
|
|
34
43
|
## Usage
|
35
44
|
|
@@ -129,6 +138,28 @@ your selected strategy. The strategies available are as follows:
|
|
129
138
|
3) `:null` is a noop. If you want to disable notifications temporarily, you can
|
130
139
|
configure the strategy to `:null`.
|
131
140
|
|
141
|
+
4) To create your own custom notifier, configure `JunkDrawer::Notifier` with
|
142
|
+
a callable object as the strategy.
|
143
|
+
|
144
|
+
```ruby
|
145
|
+
class MyNotifier
|
146
|
+
include JunkDrawer::Callable
|
147
|
+
|
148
|
+
def call(*args)
|
149
|
+
SomeMonitoringService.notify(*args)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
JunkDrawer::Notifier.strategy = MyNotifier
|
154
|
+
```
|
155
|
+
|
156
|
+
```ruby
|
157
|
+
JunkDrawer::Notifier.strategy = ->(*args) {
|
158
|
+
MonitoringServiceA.notify(*args)
|
159
|
+
MonitoringServiceB.notify(*args)
|
160
|
+
}
|
161
|
+
```
|
162
|
+
|
132
163
|
If you're using Rails, you may want to configure `Notifier` based on the
|
133
164
|
environment, so in your `config/environments/development.rb` you might have:
|
134
165
|
|
data/lib/junk_drawer/notifier.rb
CHANGED
@@ -12,7 +12,12 @@ module JunkDrawer
|
|
12
12
|
|
13
13
|
class << self
|
14
14
|
|
15
|
-
|
15
|
+
attr_reader :strategy
|
16
|
+
|
17
|
+
def strategy=(strategy)
|
18
|
+
@strategy =
|
19
|
+
strategy.is_a?(Symbol) ? STRATEGIES.fetch(strategy) : strategy
|
20
|
+
end
|
16
21
|
|
17
22
|
end
|
18
23
|
|
@@ -23,13 +28,7 @@ module JunkDrawer
|
|
23
28
|
}.freeze
|
24
29
|
|
25
30
|
def call(*args)
|
26
|
-
strategy.(*args)
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def strategy
|
32
|
-
STRATEGIES.fetch(self.class.strategy)
|
31
|
+
self.class.strategy.(*args)
|
33
32
|
end
|
34
33
|
|
35
34
|
end
|
data/lib/junk_drawer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: junk_drawer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Fletcher
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby2_keywords
|