zaikio-loom 0.1.1 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +33 -0
- data/.gitignore +4 -0
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +21 -0
- data/Gemfile.lock +143 -14
- data/README.md +34 -6
- data/app/jobs/zaikio/loom/fire_event_job.rb +9 -0
- data/bin/test +5 -0
- data/config/initializers/register_zaikio_loom_event_serializer.rb +1 -0
- data/lib/zaikio/loom.rb +5 -1
- data/lib/zaikio/loom/app_configuration.rb +11 -0
- data/lib/zaikio/loom/configuration.rb +10 -14
- data/lib/zaikio/loom/engine.rb +9 -0
- data/lib/zaikio/loom/event.rb +36 -23
- data/lib/zaikio/loom/event_serializer.rb +20 -0
- data/lib/zaikio/loom/railtie.rb +6 -0
- data/lib/zaikio/loom/version.rb +1 -1
- data/zaikio-loom.gemspec +2 -0
- metadata +44 -3
- data/.travis.yml +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a73006847e32a2ba98ff3c5cc9dfd1639b9d0e198d1886f59eabf699f6872a11
|
4
|
+
data.tar.gz: 1706ee24ba6b90be47c15fa00ce8e889892fc6457c1a86267dcad091567b2654
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57bc16d2760ae45ea9518f5485226d0a3de33e41d71b1865acad56bd7728ef18ecd237ed84f716c3acbdf8867a2523bb907753fa5cab17cb0657cc85445d5c1c
|
7
|
+
data.tar.gz: 348db1e985341b8ce6faf351490ff3532add06bea87db825881f3806c1b0aa5cf719cc10594070eee1892ca0f85a0be208aabe874d3d9195420e8c5f428b96fa
|
@@ -0,0 +1,33 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
build:
|
4
|
+
docker:
|
5
|
+
- image: circleci/ruby:2.6.5
|
6
|
+
- image: circleci/redis:3.2-alpine
|
7
|
+
|
8
|
+
working_directory: ~/repo
|
9
|
+
|
10
|
+
steps:
|
11
|
+
- checkout
|
12
|
+
|
13
|
+
- restore_cache:
|
14
|
+
keys:
|
15
|
+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
16
|
+
# fallback to using the latest cache if no exact match is found
|
17
|
+
- v1-dependencies-
|
18
|
+
|
19
|
+
- run:
|
20
|
+
name: install dependencies
|
21
|
+
command: |
|
22
|
+
gem install bundler:2.1.4 && bundle install --jobs=4 --retry=3 --path vendor/bundle
|
23
|
+
|
24
|
+
- save_cache:
|
25
|
+
paths:
|
26
|
+
- ./vendor/bundle
|
27
|
+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
28
|
+
|
29
|
+
# run tests!
|
30
|
+
- run:
|
31
|
+
name: run tests
|
32
|
+
command: |
|
33
|
+
bundle exec rake test
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,26 @@
|
|
1
1
|
# Zaikio Loom Ruby Gem Changelog
|
2
2
|
|
3
|
+
## 1.0.0 - 2020-06-03
|
4
|
+
|
5
|
+
- Fix a bug in the event serializer
|
6
|
+
|
7
|
+
## 1.0.0 - 2020-06-03
|
8
|
+
|
9
|
+
- Add multi client support
|
10
|
+
- Confguration format changed
|
11
|
+
|
12
|
+
## 0.3.0 - 2020-04-22
|
13
|
+
|
14
|
+
- Do not send events to Loom in development or staging environment
|
15
|
+
|
16
|
+
## 0.2.1 - 2020-03-30
|
17
|
+
|
18
|
+
- Fix bug with event serialization
|
19
|
+
|
20
|
+
## 0.2.0 - 2020-03-30
|
21
|
+
|
22
|
+
- Events are now fired in background with ActiveJob.
|
23
|
+
|
3
24
|
## 0.1.1 – 2020-01-29
|
4
25
|
|
5
26
|
- Fixes an issue with URLS build on staging and in the sandbox
|
data/Gemfile.lock
CHANGED
@@ -1,43 +1,171 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
zaikio-loom (0.1
|
4
|
+
zaikio-loom (1.0.1)
|
5
5
|
oj
|
6
|
+
rails (~> 6.0, >= 6.0.2.2)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
9
10
|
specs:
|
11
|
+
actioncable (6.0.3.1)
|
12
|
+
actionpack (= 6.0.3.1)
|
13
|
+
nio4r (~> 2.0)
|
14
|
+
websocket-driver (>= 0.6.1)
|
15
|
+
actionmailbox (6.0.3.1)
|
16
|
+
actionpack (= 6.0.3.1)
|
17
|
+
activejob (= 6.0.3.1)
|
18
|
+
activerecord (= 6.0.3.1)
|
19
|
+
activestorage (= 6.0.3.1)
|
20
|
+
activesupport (= 6.0.3.1)
|
21
|
+
mail (>= 2.7.1)
|
22
|
+
actionmailer (6.0.3.1)
|
23
|
+
actionpack (= 6.0.3.1)
|
24
|
+
actionview (= 6.0.3.1)
|
25
|
+
activejob (= 6.0.3.1)
|
26
|
+
mail (~> 2.5, >= 2.5.4)
|
27
|
+
rails-dom-testing (~> 2.0)
|
28
|
+
actionpack (6.0.3.1)
|
29
|
+
actionview (= 6.0.3.1)
|
30
|
+
activesupport (= 6.0.3.1)
|
31
|
+
rack (~> 2.0, >= 2.0.8)
|
32
|
+
rack-test (>= 0.6.3)
|
33
|
+
rails-dom-testing (~> 2.0)
|
34
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
35
|
+
actiontext (6.0.3.1)
|
36
|
+
actionpack (= 6.0.3.1)
|
37
|
+
activerecord (= 6.0.3.1)
|
38
|
+
activestorage (= 6.0.3.1)
|
39
|
+
activesupport (= 6.0.3.1)
|
40
|
+
nokogiri (>= 1.8.5)
|
41
|
+
actionview (6.0.3.1)
|
42
|
+
activesupport (= 6.0.3.1)
|
43
|
+
builder (~> 3.1)
|
44
|
+
erubi (~> 1.4)
|
45
|
+
rails-dom-testing (~> 2.0)
|
46
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
47
|
+
activejob (6.0.3.1)
|
48
|
+
activesupport (= 6.0.3.1)
|
49
|
+
globalid (>= 0.3.6)
|
50
|
+
activemodel (6.0.3.1)
|
51
|
+
activesupport (= 6.0.3.1)
|
52
|
+
activerecord (6.0.3.1)
|
53
|
+
activemodel (= 6.0.3.1)
|
54
|
+
activesupport (= 6.0.3.1)
|
55
|
+
activestorage (6.0.3.1)
|
56
|
+
actionpack (= 6.0.3.1)
|
57
|
+
activejob (= 6.0.3.1)
|
58
|
+
activerecord (= 6.0.3.1)
|
59
|
+
marcel (~> 0.3.1)
|
60
|
+
activesupport (6.0.3.1)
|
61
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
62
|
+
i18n (>= 0.7, < 2)
|
63
|
+
minitest (~> 5.1)
|
64
|
+
tzinfo (~> 1.1)
|
65
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
10
66
|
addressable (2.7.0)
|
11
67
|
public_suffix (>= 2.0.2, < 5.0)
|
12
68
|
ast (2.4.0)
|
69
|
+
builder (3.2.4)
|
70
|
+
concurrent-ruby (1.1.6)
|
13
71
|
crack (0.4.3)
|
14
72
|
safe_yaml (~> 1.0.0)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
73
|
+
crass (1.0.6)
|
74
|
+
erubi (1.9.0)
|
75
|
+
globalid (0.4.2)
|
76
|
+
activesupport (>= 4.2.0)
|
77
|
+
hashdiff (1.0.1)
|
78
|
+
i18n (1.8.2)
|
79
|
+
concurrent-ruby (~> 1.0)
|
80
|
+
loofah (2.5.0)
|
81
|
+
crass (~> 1.0.2)
|
82
|
+
nokogiri (>= 1.5.9)
|
83
|
+
mail (2.7.1)
|
84
|
+
mini_mime (>= 0.1.1)
|
85
|
+
marcel (0.3.3)
|
86
|
+
mimemagic (~> 0.3.2)
|
87
|
+
method_source (1.0.0)
|
88
|
+
mimemagic (0.3.5)
|
89
|
+
mini_mime (1.0.2)
|
90
|
+
mini_portile2 (2.4.0)
|
91
|
+
minitest (5.14.1)
|
92
|
+
mocha (1.11.2)
|
93
|
+
nio4r (2.5.2)
|
94
|
+
nokogiri (1.10.9)
|
95
|
+
mini_portile2 (~> 2.4.0)
|
96
|
+
oj (3.10.6)
|
19
97
|
parallel (1.19.1)
|
20
|
-
parser (2.7.
|
98
|
+
parser (2.7.1.3)
|
21
99
|
ast (~> 2.4.0)
|
22
|
-
public_suffix (4.0.
|
100
|
+
public_suffix (4.0.4)
|
101
|
+
rack (2.2.2)
|
102
|
+
rack-test (1.1.0)
|
103
|
+
rack (>= 1.0, < 3)
|
104
|
+
rails (6.0.3.1)
|
105
|
+
actioncable (= 6.0.3.1)
|
106
|
+
actionmailbox (= 6.0.3.1)
|
107
|
+
actionmailer (= 6.0.3.1)
|
108
|
+
actionpack (= 6.0.3.1)
|
109
|
+
actiontext (= 6.0.3.1)
|
110
|
+
actionview (= 6.0.3.1)
|
111
|
+
activejob (= 6.0.3.1)
|
112
|
+
activemodel (= 6.0.3.1)
|
113
|
+
activerecord (= 6.0.3.1)
|
114
|
+
activestorage (= 6.0.3.1)
|
115
|
+
activesupport (= 6.0.3.1)
|
116
|
+
bundler (>= 1.3.0)
|
117
|
+
railties (= 6.0.3.1)
|
118
|
+
sprockets-rails (>= 2.0.0)
|
119
|
+
rails-dom-testing (2.0.3)
|
120
|
+
activesupport (>= 4.2.0)
|
121
|
+
nokogiri (>= 1.6)
|
122
|
+
rails-html-sanitizer (1.3.0)
|
123
|
+
loofah (~> 2.3)
|
124
|
+
railties (6.0.3.1)
|
125
|
+
actionpack (= 6.0.3.1)
|
126
|
+
activesupport (= 6.0.3.1)
|
127
|
+
method_source
|
128
|
+
rake (>= 0.8.7)
|
129
|
+
thor (>= 0.20.3, < 2.0)
|
23
130
|
rainbow (3.0.0)
|
24
131
|
rake (13.0.1)
|
25
|
-
|
26
|
-
|
132
|
+
regexp_parser (1.7.0)
|
133
|
+
rexml (3.2.4)
|
134
|
+
rubocop (0.85.0)
|
27
135
|
parallel (~> 1.10)
|
28
136
|
parser (>= 2.7.0.1)
|
29
137
|
rainbow (>= 2.2.2, < 4.0)
|
138
|
+
regexp_parser (>= 1.7)
|
139
|
+
rexml
|
140
|
+
rubocop-ast (>= 0.0.3)
|
30
141
|
ruby-progressbar (~> 1.7)
|
31
|
-
unicode-display_width (>= 1.4.0, <
|
32
|
-
rubocop-
|
142
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
143
|
+
rubocop-ast (0.0.3)
|
144
|
+
parser (>= 2.7.0.1)
|
145
|
+
rubocop-performance (1.6.0)
|
33
146
|
rubocop (>= 0.71.0)
|
34
147
|
ruby-progressbar (1.10.1)
|
35
148
|
safe_yaml (1.0.5)
|
36
|
-
|
37
|
-
|
149
|
+
sprockets (4.0.0)
|
150
|
+
concurrent-ruby (~> 1.0)
|
151
|
+
rack (> 1, < 3)
|
152
|
+
sprockets-rails (3.2.1)
|
153
|
+
actionpack (>= 4.0)
|
154
|
+
activesupport (>= 4.0)
|
155
|
+
sprockets (>= 3.0.0)
|
156
|
+
thor (1.0.1)
|
157
|
+
thread_safe (0.3.6)
|
158
|
+
tzinfo (1.2.7)
|
159
|
+
thread_safe (~> 0.1)
|
160
|
+
unicode-display_width (1.7.0)
|
161
|
+
webmock (3.8.3)
|
38
162
|
addressable (>= 2.3.6)
|
39
163
|
crack (>= 0.3.2)
|
40
164
|
hashdiff (>= 0.4.0, < 2.0.0)
|
165
|
+
websocket-driver (0.7.2)
|
166
|
+
websocket-extensions (>= 0.1.0)
|
167
|
+
websocket-extensions (0.1.5)
|
168
|
+
zeitwerk (2.3.0)
|
41
169
|
|
42
170
|
PLATFORMS
|
43
171
|
ruby
|
@@ -45,6 +173,7 @@ PLATFORMS
|
|
45
173
|
DEPENDENCIES
|
46
174
|
bundler
|
47
175
|
minitest
|
176
|
+
mocha
|
48
177
|
rake
|
49
178
|
rubocop
|
50
179
|
rubocop-performance
|
@@ -52,4 +181,4 @@ DEPENDENCIES
|
|
52
181
|
zaikio-loom!
|
53
182
|
|
54
183
|
BUNDLED WITH
|
55
|
-
2.1.
|
184
|
+
2.1.4
|
data/README.md
CHANGED
@@ -35,17 +35,35 @@ Zaikio::Loom.configure do |config|
|
|
35
35
|
|
36
36
|
# The name of your application like it is named in the directory of the
|
37
37
|
# choosen enviroment.
|
38
|
-
config.
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
config.application 'my_application' do |app|
|
39
|
+
# Your application's event password for the choosen environment
|
40
|
+
# Do not add this password into version control.
|
41
|
+
app.password = ENV.fetch('ZAIKIO_LOOM_PASSWORD')
|
42
|
+
end
|
43
43
|
|
44
44
|
# The version of the event's payload format and structure
|
45
45
|
config.version = '1.0'
|
46
46
|
end
|
47
47
|
```
|
48
48
|
|
49
|
+
#### Multiple Clients
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
# in config/initializers/zaikio_loom.rb
|
53
|
+
Zaikio::Loom.configure do |config|
|
54
|
+
config.environment = :sandbox
|
55
|
+
config.version = '1.0'
|
56
|
+
|
57
|
+
config.application 'my_application' do |app|
|
58
|
+
app.password = ENV.fetch('ZAIKIO_LOOM_PASSWORD')
|
59
|
+
end
|
60
|
+
|
61
|
+
config.application 'my_other_app' do |app|
|
62
|
+
app.password = ENV.fetch('ZAIKIO_LOOM_OTHER_APP_PASSWORD')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
49
67
|
### Usage
|
50
68
|
|
51
69
|
Firing events to Zaikio Loom:
|
@@ -58,7 +76,17 @@ Zaikio::Loom.fire_event(
|
|
58
76
|
)
|
59
77
|
```
|
60
78
|
|
61
|
-
This example would publish an event to Zaikio Loom with a random UUID and the current timestamp.
|
79
|
+
This example would publish an event (in the background) to Zaikio Loom with a random UUID and the current timestamp.
|
80
|
+
|
81
|
+
If you want to publish the event for a specific client, you have to add it as part of the event name:
|
82
|
+
|
83
|
+
```rb
|
84
|
+
Zaikio::Loom.fire_event(
|
85
|
+
'my_other_app.event_name',
|
86
|
+
subject: 'Org/3a242896-fa57-41ba-997e-8c212d7157f3',
|
87
|
+
payload: { foo: 'bar', baz: [1, 2, 3] }
|
88
|
+
)
|
89
|
+
```
|
62
90
|
|
63
91
|
If you need more control over the published event, for example:
|
64
92
|
|
data/bin/test
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Rails.application.config.active_job.custom_serializers << Zaikio::Loom::EventSerializer
|
data/lib/zaikio/loom.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
require "zaikio/loom/app_configuration"
|
1
2
|
require "zaikio/loom/configuration"
|
2
3
|
require "zaikio/loom/event"
|
4
|
+
require "zaikio/loom/event_serializer"
|
5
|
+
require "zaikio/loom/railtie"
|
6
|
+
require "zaikio/loom/engine"
|
3
7
|
require "zaikio/loom/version"
|
4
8
|
|
5
9
|
module Zaikio
|
@@ -15,7 +19,7 @@ module Zaikio
|
|
15
19
|
|
16
20
|
def self.fire_event(name, **args)
|
17
21
|
event = Event.new(name, **args)
|
18
|
-
event
|
22
|
+
FireEventJob.perform_later(event)
|
19
23
|
end
|
20
24
|
end
|
21
25
|
end
|
@@ -4,19 +4,18 @@ module Zaikio
|
|
4
4
|
module Loom
|
5
5
|
class Configuration
|
6
6
|
HOSTS = {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
sandbox: "https://loom.sandbox.zaikio.com",
|
11
|
-
production: "https://loom.zaikio.com"
|
7
|
+
test: "http://loom.zaikio.test",
|
8
|
+
sandbox: "https://loom.sandbox.zaikio.com",
|
9
|
+
production: "https://loom.zaikio.com"
|
12
10
|
}.freeze
|
13
11
|
|
14
|
-
attr_accessor :
|
15
|
-
attr_reader :environment, :host
|
12
|
+
attr_accessor :version
|
13
|
+
attr_reader :environment, :host, :apps
|
16
14
|
attr_writer :logger
|
17
15
|
|
18
16
|
def initialize
|
19
17
|
@environment = :sandbox
|
18
|
+
@apps = {}
|
20
19
|
end
|
21
20
|
|
22
21
|
def logger
|
@@ -25,15 +24,12 @@ module Zaikio
|
|
25
24
|
|
26
25
|
def environment=(env)
|
27
26
|
@environment = env.to_sym
|
28
|
-
@host =
|
27
|
+
@host = HOSTS[environment]
|
29
28
|
end
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
HOSTS.fetch(environment) do
|
35
|
-
raise StandardError.new, "Invalid Zaikio::Loom environment '#{environment}'"
|
36
|
-
end
|
30
|
+
def application(name)
|
31
|
+
@apps[name.to_s] = AppConfiguration.new(name.to_s)
|
32
|
+
yield(@apps[name.to_s])
|
37
33
|
end
|
38
34
|
end
|
39
35
|
end
|
data/lib/zaikio/loom/event.rb
CHANGED
@@ -5,10 +5,10 @@ require "securerandom"
|
|
5
5
|
module Zaikio
|
6
6
|
module Loom
|
7
7
|
class Event
|
8
|
-
attr_reader :status_code, :response_body
|
8
|
+
attr_reader :id, :status_code, :response_body
|
9
9
|
|
10
|
-
def initialize(name, subject:, id: nil, link: nil, payload: nil, receiver: nil, timestamp: nil, version: nil) # rubocop:disable Metrics/ParameterLists
|
11
|
-
@event_name = "#{configuration.app_name}.#{name}"
|
10
|
+
def initialize(name, subject:, id: nil, link: nil, payload: nil, receiver: nil, timestamp: nil, version: nil) # rubocop:disable Metrics/AbcSize, Metrics/ParameterLists
|
11
|
+
@event_name = name.to_s.count(".").zero? ? "#{configuration.apps.values.first.app_name}.#{name}" : name.to_s
|
12
12
|
@id = id || SecureRandom.uuid
|
13
13
|
@link = link
|
14
14
|
@payload = payload
|
@@ -17,13 +17,15 @@ module Zaikio
|
|
17
17
|
@timestamp = timestamp
|
18
18
|
@version = version || configuration.version
|
19
19
|
|
20
|
-
return if
|
20
|
+
return if app_password
|
21
21
|
|
22
22
|
configuration.logger.error("Zaikio::Loom is disabled – event password is missing")
|
23
23
|
end
|
24
24
|
|
25
25
|
def fire # rubocop:disable Metrics/AbcSize
|
26
|
-
|
26
|
+
log_event
|
27
|
+
|
28
|
+
return false unless app_password && configuration.host
|
27
29
|
|
28
30
|
uri = URI("#{configuration.host}/api/v1/events")
|
29
31
|
|
@@ -38,11 +40,34 @@ module Zaikio
|
|
38
40
|
response.is_a?(Net::HTTPSuccess)
|
39
41
|
end
|
40
42
|
|
43
|
+
def to_h # rubocop:disable Metrics/MethodLength
|
44
|
+
timestamp = @timestamp || Time.now.getutc
|
45
|
+
|
46
|
+
{
|
47
|
+
id: @id,
|
48
|
+
name: @event_name,
|
49
|
+
subject: @subject,
|
50
|
+
timestamp: timestamp.iso8601,
|
51
|
+
receiver: @receiver,
|
52
|
+
version: @version,
|
53
|
+
payload: @payload,
|
54
|
+
link: @link
|
55
|
+
}.compact
|
56
|
+
end
|
57
|
+
|
41
58
|
private
|
42
59
|
|
60
|
+
def app_name
|
61
|
+
@event_name.split(".").first
|
62
|
+
end
|
63
|
+
|
64
|
+
def app_password
|
65
|
+
configuration.apps[app_name].password
|
66
|
+
end
|
67
|
+
|
43
68
|
def build_request(uri)
|
44
69
|
Net::HTTP::Post.new(uri, "User-Agent" => "zaikio-loom:#{Zaikio::Loom::VERSION}").tap do |request|
|
45
|
-
request.basic_auth(
|
70
|
+
request.basic_auth(app_name, app_password)
|
46
71
|
request.body = event_as_json
|
47
72
|
request.content_type = "application/json"
|
48
73
|
end
|
@@ -52,24 +77,12 @@ module Zaikio
|
|
52
77
|
Zaikio::Loom.configuration
|
53
78
|
end
|
54
79
|
|
55
|
-
def event_as_json
|
56
|
-
|
80
|
+
def event_as_json
|
81
|
+
@event_as_json ||= Oj.dump({ event: to_h }, mode: :compat)
|
82
|
+
end
|
57
83
|
|
58
|
-
|
59
|
-
|
60
|
-
event: {
|
61
|
-
id: @id,
|
62
|
-
name: @event_name,
|
63
|
-
subject: @subject,
|
64
|
-
timestamp: timestamp.iso8601,
|
65
|
-
receiver: @receiver,
|
66
|
-
version: @version,
|
67
|
-
payload: @payload,
|
68
|
-
link: @link
|
69
|
-
}.compact
|
70
|
-
},
|
71
|
-
mode: :compat
|
72
|
-
)
|
84
|
+
def log_event
|
85
|
+
configuration.logger.info("Zaikio::Loom event\n#{event_as_json}")
|
73
86
|
end
|
74
87
|
end
|
75
88
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Zaikio
|
2
|
+
module Loom
|
3
|
+
class EventSerializer < ActiveJob::Serializers::ObjectSerializer
|
4
|
+
def serialize?(argument)
|
5
|
+
argument.is_a? Event
|
6
|
+
end
|
7
|
+
|
8
|
+
def serialize(event)
|
9
|
+
super(event.to_h.stringify_keys)
|
10
|
+
end
|
11
|
+
|
12
|
+
def deserialize(hash)
|
13
|
+
name = hash.delete("name")
|
14
|
+
timestamp = DateTime.parse(hash.delete("timestamp"))
|
15
|
+
hash.delete("_aj_serialized")
|
16
|
+
Event.new(name, **hash.symbolize_keys.merge(timestamp: timestamp))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/zaikio/loom/version.rb
CHANGED
data/zaikio-loom.gemspec
CHANGED
@@ -24,9 +24,11 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
26
26
|
spec.add_runtime_dependency "oj"
|
27
|
+
spec.add_dependency "rails", "~> 6.0", ">= 6.0.2.2"
|
27
28
|
|
28
29
|
spec.add_development_dependency "bundler"
|
29
30
|
spec.add_development_dependency "minitest"
|
31
|
+
spec.add_development_dependency "mocha"
|
30
32
|
spec.add_development_dependency "rake"
|
31
33
|
spec.add_development_dependency "rubocop"
|
32
34
|
spec.add_development_dependency "rubocop-performance"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zaikio-loom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- crispymtn
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-06-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oj
|
@@ -25,6 +25,26 @@ dependencies:
|
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rails
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '6.0'
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 6.0.2.2
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - "~>"
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '6.0'
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 6.0.2.2
|
28
48
|
- !ruby/object:Gem::Dependency
|
29
49
|
name: bundler
|
30
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,6 +73,20 @@ dependencies:
|
|
53
73
|
- - ">="
|
54
74
|
- !ruby/object:Gem::Version
|
55
75
|
version: '0'
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: mocha
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
type: :development
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
56
90
|
- !ruby/object:Gem::Dependency
|
57
91
|
name: rake
|
58
92
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,9 +151,9 @@ executables: []
|
|
117
151
|
extensions: []
|
118
152
|
extra_rdoc_files: []
|
119
153
|
files:
|
154
|
+
- ".circleci/config.yml"
|
120
155
|
- ".gitignore"
|
121
156
|
- ".rubocop.yml"
|
122
|
-
- ".travis.yml"
|
123
157
|
- CHANGELOG.md
|
124
158
|
- CODE_OF_CONDUCT.md
|
125
159
|
- Gemfile
|
@@ -127,10 +161,17 @@ files:
|
|
127
161
|
- LICENSE.txt
|
128
162
|
- README.md
|
129
163
|
- Rakefile
|
164
|
+
- app/jobs/zaikio/loom/fire_event_job.rb
|
130
165
|
- bin/setup
|
166
|
+
- bin/test
|
167
|
+
- config/initializers/register_zaikio_loom_event_serializer.rb
|
131
168
|
- lib/zaikio/loom.rb
|
169
|
+
- lib/zaikio/loom/app_configuration.rb
|
132
170
|
- lib/zaikio/loom/configuration.rb
|
171
|
+
- lib/zaikio/loom/engine.rb
|
133
172
|
- lib/zaikio/loom/event.rb
|
173
|
+
- lib/zaikio/loom/event_serializer.rb
|
174
|
+
- lib/zaikio/loom/railtie.rb
|
134
175
|
- lib/zaikio/loom/version.rb
|
135
176
|
- zaikio-loom.gemspec
|
136
177
|
homepage: https://github.com/crispymtn/zai-loom-ruby
|