stenotype 0.1.13 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +3 -3
- data/README.md +5 -9
- data/lib/stenotype.rb +0 -2
- data/lib/stenotype/context_handlers.rb +7 -4
- data/lib/stenotype/context_handlers/base.rb +13 -0
- data/lib/stenotype/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: a42b44b8b7a3c69fe9bfc179aaef8e274c67ace47d3609edda524358ff59d6ec
|
4
|
+
data.tar.gz: 58b3185d8391de7473da08bc9ffb4de8ca9ca37e8d948b8c7d26b14d3bd1a928
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3578df8a2213ad6bfff4c8be71f902fba440ceed806e7b2cd4a3a7c443194e5abf11cc624f1466768f1a845e6a3696e108879e1524de5be553435b5fc443cc37
|
7
|
+
data.tar.gz: 2550d63b410c460b663562d453b97659dc014fde50cd250949530e210d9dc80cd251964858f90aa331de3303fb3b534f1601444c1208fdd7739ec309bb505e3c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### 0.1.15
|
4
|
+
* Updates readme.
|
5
|
+
|
6
|
+
### 0.1.14
|
7
|
+
* Allows autodiscovering of the context handlers and Rails development env autoreload.
|
8
|
+
|
3
9
|
### 0.1.13
|
4
10
|
* Removes obsolete rails pre-configuration for the sake of default configuration settings
|
5
11
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
stenotype (0.1.
|
4
|
+
stenotype (0.1.15)
|
5
5
|
activesupport (>= 5.0.0)
|
6
6
|
google-cloud-pubsub (~> 1.0.0)
|
7
7
|
spicery (>= 0.22.0, < 1.0)
|
@@ -102,7 +102,7 @@ GEM
|
|
102
102
|
googleauth (~> 0.9)
|
103
103
|
grpc (~> 1.24)
|
104
104
|
rly (~> 0.2.3)
|
105
|
-
google-protobuf (3.11.4)
|
105
|
+
google-protobuf (3.11.4-universal-darwin)
|
106
106
|
googleapis-common-protos (1.3.9)
|
107
107
|
google-protobuf (~> 3.0)
|
108
108
|
googleapis-common-protos-types (~> 1.0)
|
@@ -116,7 +116,7 @@ GEM
|
|
116
116
|
multi_json (~> 1.11)
|
117
117
|
os (>= 0.9, < 2.0)
|
118
118
|
signet (~> 0.12)
|
119
|
-
grpc (1.27.0)
|
119
|
+
grpc (1.27.0-universal-darwin)
|
120
120
|
google-protobuf (~> 3.11)
|
121
121
|
googleapis-common-protos-types (~> 1.0)
|
122
122
|
grpc-google-iam-v1 (0.6.9)
|
data/README.md
CHANGED
@@ -105,7 +105,7 @@ Controls whether the hook `auto_initialize!` is run for each adapter. If set to
|
|
105
105
|
|
106
106
|
#### Configuring context handlers
|
107
107
|
|
108
|
-
Each event is emitted in a context which might be an ActionController instance or an ActiveJob instance or potentially any other place. Context handlers are implemented as plain ruby classes
|
108
|
+
Each event is emitted in a context which might be an ActionController instance or an ActiveJob instance or potentially any other place. Context handlers are implemented as plain ruby classes. By default a plain `Class` handler is registered when not used with any framework. In case Ruby on Rails is used, then there are two additional context handlers for `ActionController` and `ActiveJob` instances. Registration of the context handler happens upon inheriting from `Stenotype::ContextHandlers::Base`.
|
109
109
|
|
110
110
|
### Emitting Events
|
111
111
|
|
@@ -118,7 +118,7 @@ Stenotype::Event.emit!(
|
|
118
118
|
)
|
119
119
|
```
|
120
120
|
|
121
|
-
The event is then going to be passed to a dispatcher responsible for sending the evens to targets.
|
121
|
+
The event is then going to be passed to a dispatcher responsible for sending the evens to targets. See [Custom context handlers](#custom-context-handlers) for more details.
|
122
122
|
|
123
123
|
#### ActionController
|
124
124
|
|
@@ -201,8 +201,6 @@ class CustomHandler < Stenotype::ContextHandlers::Base
|
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
204
|
-
Stenotype::ContextHandlers.register CustomHandler
|
205
|
-
|
206
204
|
# Event is being emitted twice. First time with default options.
|
207
205
|
# Second time with overriden method name and eval_context.
|
208
206
|
class PlainRubyClass < BaseClass
|
@@ -251,7 +249,7 @@ Stenotype.config.targets.push(CustomAdapter.new)
|
|
251
249
|
|
252
250
|
#### Custom context handlers
|
253
251
|
|
254
|
-
A list of context handlers might be extended by defining a class inheriting from `Stenotype::ContextHandlers::Base
|
252
|
+
A list of context handlers might be extended by defining a class inheriting from `Stenotype::ContextHandlers::Base`. Event handler must have a `self.handler_name` in order to use it during context serialization. Also custom handler must implement method `#as_json`:
|
255
253
|
```ruby
|
256
254
|
class CustomHandler < Stenotype::ContextHandlers::Base
|
257
255
|
self.handler_name = :custom_handler_name
|
@@ -275,10 +273,8 @@ class CustomHandler < Stenotype::ContextHandlers::Base
|
|
275
273
|
end
|
276
274
|
```
|
277
275
|
|
278
|
-
|
279
|
-
|
280
|
-
Stenotype::ContextHandlers.register CustomHandler
|
281
|
-
```
|
276
|
+
You do not have to manually register the context handler since it happens upon inheriting from `Stenotype::ContextHandlers::Base`
|
277
|
+
|
282
278
|
|
283
279
|
## Development
|
284
280
|
|
data/lib/stenotype.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "stenotype/context_handlers/base"
|
4
|
-
require "stenotype/context_handlers/rails/controller"
|
5
|
-
require "stenotype/context_handlers/rails/active_job"
|
6
|
-
require "stenotype/context_handlers/klass"
|
7
3
|
require "stenotype/context_handlers/collection"
|
8
4
|
|
9
5
|
module Stenotype
|
@@ -14,6 +10,7 @@ module Stenotype
|
|
14
10
|
module ContextHandlers
|
15
11
|
class << self
|
16
12
|
attr_writer :known
|
13
|
+
|
17
14
|
#
|
18
15
|
# @return {Array<#publish>} A list of handlers implementing [#publish]
|
19
16
|
#
|
@@ -28,3 +25,9 @@ module Stenotype
|
|
28
25
|
end
|
29
26
|
end
|
30
27
|
end
|
28
|
+
|
29
|
+
require "stenotype/context_handlers/base"
|
30
|
+
require "stenotype/context_handlers/rails/controller"
|
31
|
+
require "stenotype/context_handlers/rails/active_job"
|
32
|
+
require "stenotype/context_handlers/klass"
|
33
|
+
|
@@ -24,6 +24,10 @@ module Stenotype
|
|
24
24
|
class Base
|
25
25
|
attr_reader :context, :options
|
26
26
|
|
27
|
+
def self.inherited(subklass)
|
28
|
+
ContextHandlers.register(subklass)
|
29
|
+
end
|
30
|
+
|
27
31
|
#
|
28
32
|
# @param context {Object} A context where the event was emitted
|
29
33
|
# @param options {Hash} A hash of additional options
|
@@ -58,6 +62,15 @@ module Stenotype
|
|
58
62
|
@handler_name || raise(NotImplementedError, "Please, specify the handler_name of #{self}")
|
59
63
|
end
|
60
64
|
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
#
|
69
|
+
# A rails specific workaround to make reloading in dev env happy
|
70
|
+
#
|
71
|
+
def self.before_remove_const
|
72
|
+
Stenotype::ContextHandlers.known.unregister(self)
|
73
|
+
end
|
61
74
|
end
|
62
75
|
end
|
63
76
|
end
|
data/lib/stenotype/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stenotype
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Kapitonov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|