eventsimple 1.2.3 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +90 -84
- data/README.md +18 -0
- data/eventsimple.gemspec +1 -0
- data/lib/eventsimple/entity.rb +12 -0
- data/lib/eventsimple/event.rb +2 -0
- data/lib/eventsimple/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af8b1c10700108b29ba729c9bbe8984a6c1e79e2321cab48576e29e85225c7f0
|
4
|
+
data.tar.gz: 73debdd0abeeec0f17077037656b92f759f41d6c1600d17c9bed86ac0c679667
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 950e729b42d5c7f6c1aa30172e41dbd13ffdc5e44e24e8251ac471611cd41bdb8ac82fe03d145cdf917bb0396dcb2449fc6e31717e72e33b2adceeb205d7855b
|
7
|
+
data.tar.gz: db12e1bad078f9ba357c3360157adb0c5842f46fcd204ac892ff47fe105e9fc7d8618be8b4f7765eef24cf175f539f478c84a4613103af37380ad5b3d51f2b1e
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## Unreleased
|
8
8
|
|
9
|
+
## 1.3.1 - 2024-01-19
|
10
|
+
### Changed
|
11
|
+
- Restore readonly status to the original status after enable_writes! block.
|
12
|
+
|
13
|
+
## 1.3.0 - 2024-01-14
|
14
|
+
### Changed
|
15
|
+
- Prevent manual write access to the entity table by default. This is to prevent
|
16
|
+
accidental writes to the entity table. Use entity.enable_writes! to enable writes.
|
17
|
+
|
9
18
|
## 1.2.3 - 2024-01-11
|
10
19
|
### Changed
|
11
20
|
- Fix rendering of deleted events
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
eventsimple (1.
|
4
|
+
eventsimple (1.3.1)
|
5
5
|
dry-struct (~> 1.6)
|
6
6
|
dry-types (~> 1.7)
|
7
7
|
pg (~> 1.4)
|
@@ -11,35 +11,35 @@ PATH
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
actioncable (7.1.
|
15
|
-
actionpack (= 7.1.
|
16
|
-
activesupport (= 7.1.
|
14
|
+
actioncable (7.1.3)
|
15
|
+
actionpack (= 7.1.3)
|
16
|
+
activesupport (= 7.1.3)
|
17
17
|
nio4r (~> 2.0)
|
18
18
|
websocket-driver (>= 0.6.1)
|
19
19
|
zeitwerk (~> 2.6)
|
20
|
-
actionmailbox (7.1.
|
21
|
-
actionpack (= 7.1.
|
22
|
-
activejob (= 7.1.
|
23
|
-
activerecord (= 7.1.
|
24
|
-
activestorage (= 7.1.
|
25
|
-
activesupport (= 7.1.
|
20
|
+
actionmailbox (7.1.3)
|
21
|
+
actionpack (= 7.1.3)
|
22
|
+
activejob (= 7.1.3)
|
23
|
+
activerecord (= 7.1.3)
|
24
|
+
activestorage (= 7.1.3)
|
25
|
+
activesupport (= 7.1.3)
|
26
26
|
mail (>= 2.7.1)
|
27
27
|
net-imap
|
28
28
|
net-pop
|
29
29
|
net-smtp
|
30
|
-
actionmailer (7.1.
|
31
|
-
actionpack (= 7.1.
|
32
|
-
actionview (= 7.1.
|
33
|
-
activejob (= 7.1.
|
34
|
-
activesupport (= 7.1.
|
30
|
+
actionmailer (7.1.3)
|
31
|
+
actionpack (= 7.1.3)
|
32
|
+
actionview (= 7.1.3)
|
33
|
+
activejob (= 7.1.3)
|
34
|
+
activesupport (= 7.1.3)
|
35
35
|
mail (~> 2.5, >= 2.5.4)
|
36
36
|
net-imap
|
37
37
|
net-pop
|
38
38
|
net-smtp
|
39
39
|
rails-dom-testing (~> 2.2)
|
40
|
-
actionpack (7.1.
|
41
|
-
actionview (= 7.1.
|
42
|
-
activesupport (= 7.1.
|
40
|
+
actionpack (7.1.3)
|
41
|
+
actionview (= 7.1.3)
|
42
|
+
activesupport (= 7.1.3)
|
43
43
|
nokogiri (>= 1.8.5)
|
44
44
|
racc
|
45
45
|
rack (>= 2.2.4)
|
@@ -47,35 +47,35 @@ GEM
|
|
47
47
|
rack-test (>= 0.6.3)
|
48
48
|
rails-dom-testing (~> 2.2)
|
49
49
|
rails-html-sanitizer (~> 1.6)
|
50
|
-
actiontext (7.1.
|
51
|
-
actionpack (= 7.1.
|
52
|
-
activerecord (= 7.1.
|
53
|
-
activestorage (= 7.1.
|
54
|
-
activesupport (= 7.1.
|
50
|
+
actiontext (7.1.3)
|
51
|
+
actionpack (= 7.1.3)
|
52
|
+
activerecord (= 7.1.3)
|
53
|
+
activestorage (= 7.1.3)
|
54
|
+
activesupport (= 7.1.3)
|
55
55
|
globalid (>= 0.6.0)
|
56
56
|
nokogiri (>= 1.8.5)
|
57
|
-
actionview (7.1.
|
58
|
-
activesupport (= 7.1.
|
57
|
+
actionview (7.1.3)
|
58
|
+
activesupport (= 7.1.3)
|
59
59
|
builder (~> 3.1)
|
60
60
|
erubi (~> 1.11)
|
61
61
|
rails-dom-testing (~> 2.2)
|
62
62
|
rails-html-sanitizer (~> 1.6)
|
63
|
-
activejob (7.1.
|
64
|
-
activesupport (= 7.1.
|
63
|
+
activejob (7.1.3)
|
64
|
+
activesupport (= 7.1.3)
|
65
65
|
globalid (>= 0.3.6)
|
66
|
-
activemodel (7.1.
|
67
|
-
activesupport (= 7.1.
|
68
|
-
activerecord (7.1.
|
69
|
-
activemodel (= 7.1.
|
70
|
-
activesupport (= 7.1.
|
66
|
+
activemodel (7.1.3)
|
67
|
+
activesupport (= 7.1.3)
|
68
|
+
activerecord (7.1.3)
|
69
|
+
activemodel (= 7.1.3)
|
70
|
+
activesupport (= 7.1.3)
|
71
71
|
timeout (>= 0.4.0)
|
72
|
-
activestorage (7.1.
|
73
|
-
actionpack (= 7.1.
|
74
|
-
activejob (= 7.1.
|
75
|
-
activerecord (= 7.1.
|
76
|
-
activesupport (= 7.1.
|
72
|
+
activestorage (7.1.3)
|
73
|
+
actionpack (= 7.1.3)
|
74
|
+
activejob (= 7.1.3)
|
75
|
+
activerecord (= 7.1.3)
|
76
|
+
activesupport (= 7.1.3)
|
77
77
|
marcel (~> 1.0)
|
78
|
-
activesupport (7.1.
|
78
|
+
activesupport (7.1.3)
|
79
79
|
base64
|
80
80
|
bigdecimal
|
81
81
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
@@ -89,7 +89,7 @@ GEM
|
|
89
89
|
public_suffix (>= 2.0.2, < 6.0)
|
90
90
|
ast (2.4.2)
|
91
91
|
base64 (0.2.0)
|
92
|
-
bigdecimal (3.1.
|
92
|
+
bigdecimal (3.1.6)
|
93
93
|
builder (3.2.4)
|
94
94
|
bundle-audit (0.1.0)
|
95
95
|
bundler-audit
|
@@ -97,11 +97,11 @@ GEM
|
|
97
97
|
bundler (>= 1.2.0, < 3)
|
98
98
|
thor (~> 1.0)
|
99
99
|
coderay (1.1.3)
|
100
|
-
concurrent-ruby (1.2.
|
100
|
+
concurrent-ruby (1.2.3)
|
101
101
|
connection_pool (2.4.1)
|
102
102
|
crass (1.0.6)
|
103
103
|
date (3.3.4)
|
104
|
-
diff-lcs (1.5.
|
104
|
+
diff-lcs (1.5.1)
|
105
105
|
drb (2.2.0)
|
106
106
|
ruby2_keywords
|
107
107
|
dry-core (1.0.1)
|
@@ -125,6 +125,11 @@ GEM
|
|
125
125
|
dry-logic (~> 1.4)
|
126
126
|
zeitwerk (~> 2.6)
|
127
127
|
erubi (1.12.0)
|
128
|
+
factory_bot (6.4.6)
|
129
|
+
activesupport (>= 5.0.0)
|
130
|
+
factory_bot_rails (6.4.3)
|
131
|
+
factory_bot (~> 6.4)
|
132
|
+
railties (>= 5.0.0)
|
128
133
|
ffi (1.16.3)
|
129
134
|
formatador (1.1.0)
|
130
135
|
fuubar (2.5.1)
|
@@ -152,8 +157,8 @@ GEM
|
|
152
157
|
i18n (1.14.1)
|
153
158
|
concurrent-ruby (~> 1.0)
|
154
159
|
ice_nine (0.11.2)
|
155
|
-
io-console (0.7.
|
156
|
-
irb (1.11.
|
160
|
+
io-console (0.7.2)
|
161
|
+
irb (1.11.2)
|
157
162
|
rdoc
|
158
163
|
reline (>= 0.4.2)
|
159
164
|
json (2.7.1)
|
@@ -174,10 +179,10 @@ GEM
|
|
174
179
|
marcel (1.0.2)
|
175
180
|
method_source (1.0.0)
|
176
181
|
mini_mime (1.1.5)
|
177
|
-
minitest (5.
|
182
|
+
minitest (5.22.2)
|
178
183
|
mutex_m (0.2.0)
|
179
184
|
nenv (0.3.0)
|
180
|
-
net-imap (0.4.
|
185
|
+
net-imap (0.4.10)
|
181
186
|
date
|
182
187
|
net-protocol
|
183
188
|
net-pop (0.1.2)
|
@@ -187,9 +192,9 @@ GEM
|
|
187
192
|
net-smtp (0.4.0.1)
|
188
193
|
net-protocol
|
189
194
|
nio4r (2.7.0)
|
190
|
-
nokogiri (1.16.
|
195
|
+
nokogiri (1.16.2-arm64-darwin)
|
191
196
|
racc (~> 1.4)
|
192
|
-
nokogiri (1.16.
|
197
|
+
nokogiri (1.16.2-x86_64-linux)
|
193
198
|
racc (~> 1.4)
|
194
199
|
notiffany (0.1.3)
|
195
200
|
nenv (~> 0.1)
|
@@ -197,10 +202,10 @@ GEM
|
|
197
202
|
parallel (1.24.0)
|
198
203
|
parse_a_changelog (1.3.0)
|
199
204
|
treetop (~> 1.6)
|
200
|
-
parser (3.3.0.
|
205
|
+
parser (3.3.0.5)
|
201
206
|
ast (~> 2.4.1)
|
202
207
|
racc
|
203
|
-
pg (1.5.
|
208
|
+
pg (1.5.5)
|
204
209
|
polyglot (0.3.5)
|
205
210
|
pry (0.14.2)
|
206
211
|
coderay (~> 1.1)
|
@@ -211,7 +216,7 @@ GEM
|
|
211
216
|
puma (6.4.2)
|
212
217
|
nio4r (~> 2.0)
|
213
218
|
racc (1.7.3)
|
214
|
-
rack (3.0.
|
219
|
+
rack (3.0.9)
|
215
220
|
rack-session (2.0.0)
|
216
221
|
rack (>= 3.0.0)
|
217
222
|
rack-test (2.1.0)
|
@@ -219,20 +224,20 @@ GEM
|
|
219
224
|
rackup (2.1.0)
|
220
225
|
rack (>= 3)
|
221
226
|
webrick (~> 1.8)
|
222
|
-
rails (7.1.
|
223
|
-
actioncable (= 7.1.
|
224
|
-
actionmailbox (= 7.1.
|
225
|
-
actionmailer (= 7.1.
|
226
|
-
actionpack (= 7.1.
|
227
|
-
actiontext (= 7.1.
|
228
|
-
actionview (= 7.1.
|
229
|
-
activejob (= 7.1.
|
230
|
-
activemodel (= 7.1.
|
231
|
-
activerecord (= 7.1.
|
232
|
-
activestorage (= 7.1.
|
233
|
-
activesupport (= 7.1.
|
227
|
+
rails (7.1.3)
|
228
|
+
actioncable (= 7.1.3)
|
229
|
+
actionmailbox (= 7.1.3)
|
230
|
+
actionmailer (= 7.1.3)
|
231
|
+
actionpack (= 7.1.3)
|
232
|
+
actiontext (= 7.1.3)
|
233
|
+
actionview (= 7.1.3)
|
234
|
+
activejob (= 7.1.3)
|
235
|
+
activemodel (= 7.1.3)
|
236
|
+
activerecord (= 7.1.3)
|
237
|
+
activestorage (= 7.1.3)
|
238
|
+
activesupport (= 7.1.3)
|
234
239
|
bundler (>= 1.15.0)
|
235
|
-
railties (= 7.1.
|
240
|
+
railties (= 7.1.3)
|
236
241
|
rails-dom-testing (2.2.0)
|
237
242
|
activesupport (>= 5.0.0)
|
238
243
|
minitest
|
@@ -240,9 +245,9 @@ GEM
|
|
240
245
|
rails-html-sanitizer (1.6.0)
|
241
246
|
loofah (~> 2.21)
|
242
247
|
nokogiri (~> 1.14)
|
243
|
-
railties (7.1.
|
244
|
-
actionpack (= 7.1.
|
245
|
-
activesupport (= 7.1.
|
248
|
+
railties (7.1.3)
|
249
|
+
actionpack (= 7.1.3)
|
250
|
+
activesupport (= 7.1.3)
|
246
251
|
irb
|
247
252
|
rackup (>= 1.0.0)
|
248
253
|
rake (>= 12.2)
|
@@ -261,19 +266,19 @@ GEM
|
|
261
266
|
io-console (~> 0.5)
|
262
267
|
retriable (3.1.2)
|
263
268
|
rexml (3.2.6)
|
264
|
-
rspec (3.
|
265
|
-
rspec-core (~> 3.
|
266
|
-
rspec-expectations (~> 3.
|
267
|
-
rspec-mocks (~> 3.
|
268
|
-
rspec-core (3.
|
269
|
-
rspec-support (~> 3.
|
270
|
-
rspec-expectations (3.
|
269
|
+
rspec (3.13.0)
|
270
|
+
rspec-core (~> 3.13.0)
|
271
|
+
rspec-expectations (~> 3.13.0)
|
272
|
+
rspec-mocks (~> 3.13.0)
|
273
|
+
rspec-core (3.13.0)
|
274
|
+
rspec-support (~> 3.13.0)
|
275
|
+
rspec-expectations (3.13.0)
|
271
276
|
diff-lcs (>= 1.2.0, < 2.0)
|
272
|
-
rspec-support (~> 3.
|
273
|
-
rspec-mocks (3.
|
277
|
+
rspec-support (~> 3.13.0)
|
278
|
+
rspec-mocks (3.13.0)
|
274
279
|
diff-lcs (>= 1.2.0, < 2.0)
|
275
|
-
rspec-support (~> 3.
|
276
|
-
rspec-rails (6.1.
|
280
|
+
rspec-support (~> 3.13.0)
|
281
|
+
rspec-rails (6.1.1)
|
277
282
|
actionpack (>= 6.1)
|
278
283
|
activesupport (>= 6.1)
|
279
284
|
railties (>= 6.1)
|
@@ -281,12 +286,12 @@ GEM
|
|
281
286
|
rspec-expectations (~> 3.12)
|
282
287
|
rspec-mocks (~> 3.12)
|
283
288
|
rspec-support (~> 3.12)
|
284
|
-
rspec-support (3.
|
285
|
-
rubocop (1.
|
289
|
+
rspec-support (3.13.0)
|
290
|
+
rubocop (1.60.2)
|
286
291
|
json (~> 2.3)
|
287
292
|
language_server-protocol (>= 3.17.0)
|
288
293
|
parallel (~> 1.10)
|
289
|
-
parser (>= 3.
|
294
|
+
parser (>= 3.3.0.2)
|
290
295
|
rainbow (>= 2.2.2, < 4.0)
|
291
296
|
regexp_parser (>= 1.8, < 3.0)
|
292
297
|
rexml (>= 3.2.5, < 4.0)
|
@@ -316,10 +321,10 @@ GEM
|
|
316
321
|
ruby-progressbar (1.13.0)
|
317
322
|
ruby2_keywords (0.0.5)
|
318
323
|
shellany (0.0.1)
|
319
|
-
standard (1.
|
324
|
+
standard (1.34.0)
|
320
325
|
language_server-protocol (~> 3.17.0.2)
|
321
326
|
lint_roller (~> 1.0)
|
322
|
-
rubocop (~> 1.
|
327
|
+
rubocop (~> 1.60)
|
323
328
|
standard-custom (~> 1.0.0)
|
324
329
|
standard-performance (~> 1.3)
|
325
330
|
standard-custom (1.0.2)
|
@@ -343,13 +348,13 @@ GEM
|
|
343
348
|
websocket-driver (0.7.6)
|
344
349
|
websocket-extensions (>= 0.1.0)
|
345
350
|
websocket-extensions (0.1.5)
|
346
|
-
ws-style (7.3
|
351
|
+
ws-style (7.4.3)
|
347
352
|
rubocop-rspec (>= 2.2.0)
|
348
353
|
rubocop-vendor (>= 0.11)
|
349
354
|
standard (>= 1.30.1)
|
350
355
|
standard-custom (>= 1.0.2)
|
351
356
|
standard-rails (>= 0.1.0)
|
352
|
-
zeitwerk (2.6.
|
357
|
+
zeitwerk (2.6.13)
|
353
358
|
|
354
359
|
PLATFORMS
|
355
360
|
arm64-darwin-22
|
@@ -358,6 +363,7 @@ PLATFORMS
|
|
358
363
|
DEPENDENCIES
|
359
364
|
bundle-audit
|
360
365
|
eventsimple!
|
366
|
+
factory_bot_rails
|
361
367
|
fuubar
|
362
368
|
git
|
363
369
|
guard-rspec
|
data/README.md
CHANGED
@@ -342,6 +342,24 @@ Create a rake task to run the consumer
|
|
342
342
|
## Helper methods
|
343
343
|
Some convenience methods are provided to help with common use cases.
|
344
344
|
|
345
|
+
**`#enable_writes!`**
|
346
|
+
Write access on entities is disabled by default outside of writes via events. Use this method to enable writes on an entity.
|
347
|
+
|
348
|
+
```ruby
|
349
|
+
user = User.find_by(canonical_id: 'user-123')
|
350
|
+
user.enable_writes! do
|
351
|
+
user.reproject
|
352
|
+
user.save!
|
353
|
+
end
|
354
|
+
```
|
355
|
+
|
356
|
+
If you are using FactoryBot, you can add the following in your rails_helper.rb to enable writes on the entity:
|
357
|
+
```ruby
|
358
|
+
FactoryBot.define do
|
359
|
+
after(:build) { |model| model.enable_writes! if model.class.ancestors.include?(Eventsimple::Entity::InstanceMethods) }
|
360
|
+
end
|
361
|
+
```
|
362
|
+
|
345
363
|
**`#reproject(at: nil)`**
|
346
364
|
|
347
365
|
Reproject an entity from events (rebuilds in memory but does not persist the entity).
|
data/eventsimple.gemspec
CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_runtime_dependency 'retriable', '~> 3.1'
|
31
31
|
|
32
32
|
spec.add_development_dependency 'bundle-audit'
|
33
|
+
spec.add_development_dependency 'factory_bot_rails'
|
33
34
|
spec.add_development_dependency 'fuubar'
|
34
35
|
spec.add_development_dependency 'git'
|
35
36
|
spec.add_development_dependency 'guard-rspec'
|
data/lib/eventsimple/entity.rb
CHANGED
@@ -11,6 +11,8 @@ module Eventsimple
|
|
11
11
|
autosave: false,
|
12
12
|
validate: false
|
13
13
|
|
14
|
+
after_initialize :readonly!
|
15
|
+
|
14
16
|
class_attribute :ignored_for_projection, default: []
|
15
17
|
|
16
18
|
class_attribute :_filter_attributes
|
@@ -32,6 +34,16 @@ module Eventsimple
|
|
32
34
|
attributes == reprojected.attributes
|
33
35
|
end
|
34
36
|
|
37
|
+
def enable_writes!(&block)
|
38
|
+
was_readonly = @readonly
|
39
|
+
@readonly = false
|
40
|
+
|
41
|
+
if block
|
42
|
+
yield
|
43
|
+
@readonly = true if was_readonly
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
35
47
|
def reproject(at: nil)
|
36
48
|
event_history = at ? events.where('created_at <= ?', at).load : events.load
|
37
49
|
ignore_props = (DEFAULT_IGNORE_PROPS + ignored_for_projection).map(&:to_s)
|
data/lib/eventsimple/event.rb
CHANGED
data/lib/eventsimple/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eventsimple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zulfiqar Ali
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-struct
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: factory_bot_rails
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: fuubar
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|