reactor 2.0.0 → 2.0.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 +4 -4
- data/Gemfile.lock +9 -9
- data/README.md +6 -0
- data/lib/reactor/event.rb +4 -2
- data/lib/reactor/version.rb +1 -1
- data/spec/event_spec.rb +29 -8
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9e066203f8df6c24028af68d5c0bcbb9c67ca222621202af2e4fe9a23b04745
|
4
|
+
data.tar.gz: '0691a70c8cacb2177147eaf8b16e6791e9e17a6ffeda29cc219691dcf5c65a47'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed53ede525d728213b96c704dfe00bfa760e2b7343903361364f517c34a887c162834671a418ffc9628e6f5416b4e171c7251dfc4d2ff899f7d77238869d7819
|
7
|
+
data.tar.gz: e7b143688eea7641248f2aa9b7bc721f891389ad25977bf4fcb3980d528eb2e7571bc1ce82991dc827ed3300b4ad694e79dd85959a4c957175687bc135376779
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
reactor (2.0.
|
4
|
+
reactor (2.0.1)
|
5
5
|
rails (~> 5.2.3)
|
6
6
|
sidekiq (> 4.0)
|
7
7
|
|
@@ -77,11 +77,11 @@ GEM
|
|
77
77
|
mimemagic (~> 0.3.2)
|
78
78
|
method_source (0.8.2)
|
79
79
|
mimemagic (0.3.3)
|
80
|
-
mini_mime (1.0.
|
80
|
+
mini_mime (1.0.2)
|
81
81
|
mini_portile2 (2.4.0)
|
82
82
|
minitest (5.11.3)
|
83
|
-
nio4r (2.
|
84
|
-
nokogiri (1.10.
|
83
|
+
nio4r (2.5.1)
|
84
|
+
nokogiri (1.10.4)
|
85
85
|
mini_portile2 (~> 2.4.0)
|
86
86
|
pry (0.10.4)
|
87
87
|
coderay (~> 1.1.0)
|
@@ -91,7 +91,7 @@ GEM
|
|
91
91
|
byebug (~> 9.0)
|
92
92
|
pry (~> 0.10)
|
93
93
|
rack (2.0.7)
|
94
|
-
rack-protection (2.0.
|
94
|
+
rack-protection (2.0.7)
|
95
95
|
rack
|
96
96
|
rack-test (1.1.0)
|
97
97
|
rack (>= 1.0, < 3)
|
@@ -111,7 +111,7 @@ GEM
|
|
111
111
|
rails-dom-testing (2.0.3)
|
112
112
|
activesupport (>= 4.2.0)
|
113
113
|
nokogiri (>= 1.6)
|
114
|
-
rails-html-sanitizer (1.0
|
114
|
+
rails-html-sanitizer (1.2.0)
|
115
115
|
loofah (~> 2.2, >= 2.2.2)
|
116
116
|
railties (5.2.3)
|
117
117
|
actionpack (= 5.2.3)
|
@@ -120,7 +120,7 @@ GEM
|
|
120
120
|
rake (>= 0.8.7)
|
121
121
|
thor (>= 0.19.0, < 2.0)
|
122
122
|
rake (12.0.0)
|
123
|
-
redis (4.1.
|
123
|
+
redis (4.1.2)
|
124
124
|
rspec (3.6.0)
|
125
125
|
rspec-core (~> 3.6.0)
|
126
126
|
rspec-expectations (~> 3.6.0)
|
@@ -160,9 +160,9 @@ GEM
|
|
160
160
|
thread_safe (0.3.6)
|
161
161
|
tzinfo (1.2.5)
|
162
162
|
thread_safe (~> 0.1)
|
163
|
-
websocket-driver (0.7.
|
163
|
+
websocket-driver (0.7.1)
|
164
164
|
websocket-extensions (>= 0.1.0)
|
165
|
-
websocket-extensions (0.1.
|
165
|
+
websocket-extensions (0.1.4)
|
166
166
|
|
167
167
|
PLATFORMS
|
168
168
|
ruby
|
data/README.md
CHANGED
@@ -188,6 +188,12 @@ Subscribers can opt into certain queues with `on_event :whatever, sidekiq_option
|
|
188
188
|
|
189
189
|
You can also override _all queue choices_ with `ENV['REACTOR_QUEUE']`. You may want to do this if you wish to contain the 'cascade' of events for more expensive or risky operations.
|
190
190
|
|
191
|
+
#### Executing in a Console
|
192
|
+
|
193
|
+
By default, running a Rails console in a `production` `ENV['RACK_ENV']` will cause publish events to
|
194
|
+
bomb out unless `srsly: true` is provided as an additional parameter to event publishing. To control
|
195
|
+
this behavior, set `ENV['REACTOR_CONSOLE_ENABLED']` to a value.
|
196
|
+
|
191
197
|
## Contributing
|
192
198
|
|
193
199
|
1. Fork it
|
data/lib/reactor/event.rb
CHANGED
@@ -5,7 +5,8 @@ class Reactor::Event
|
|
5
5
|
|
6
6
|
CONSOLE_CONFIRMATION_MESSAGE = <<-eos
|
7
7
|
It looks like you are on a production console. Only fire an event if you intend to trigger
|
8
|
-
all of its subscribers. In order to proceed, you must pass `srsly: true` in the event data.
|
8
|
+
all of its subscribers. In order to proceed, you must pass `srsly: true` in the event data. To
|
9
|
+
configure Reactor to ignore this validation, set `ENV['REACTOR_CONSOLE_ENABLED']` to a value.
|
9
10
|
eos
|
10
11
|
|
11
12
|
attr_accessor :__data__
|
@@ -60,7 +61,8 @@ class Reactor::Event
|
|
60
61
|
end
|
61
62
|
|
62
63
|
def publish(name, data = {})
|
63
|
-
if defined?(Rails::Console) && ENV['RACK_ENV'] == 'production' && data[:srsly].blank?
|
64
|
+
if defined?(Rails::Console) && ENV['RACK_ENV'] == 'production' && data[:srsly].blank? &&
|
65
|
+
!ENV['REACTOR_CONSOLE_ENABLED']
|
64
66
|
raise ArgumentError.new(CONSOLE_CONFIRMATION_MESSAGE)
|
65
67
|
end
|
66
68
|
|
data/lib/reactor/version.rb
CHANGED
data/spec/event_spec.rb
CHANGED
@@ -63,19 +63,40 @@ describe Reactor::Event do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
context 'when in a production rails console' do
|
66
|
-
|
66
|
+
before do
|
67
67
|
stub_const('Rails::Console', Class.new)
|
68
68
|
ENV['RACK_ENV'] = 'production'
|
69
|
+
end
|
69
70
|
|
70
|
-
|
71
|
-
|
72
|
-
|
71
|
+
after do
|
72
|
+
ENV['RACK_ENV'] = 'development'
|
73
|
+
end
|
73
74
|
|
74
|
-
|
75
|
-
|
76
|
-
}
|
75
|
+
context 'when allowing console usage' do
|
76
|
+
before { ENV['REACTOR_CONSOLE_ENABLED'] = 'true' }
|
77
|
+
after { ENV['REACTOR_CONSOLE_ENABLED'] = nil }
|
77
78
|
|
78
|
-
|
79
|
+
it 'does not require `srsly: true`' do
|
80
|
+
expect {
|
81
|
+
Reactor::Event.publish(:thing)
|
82
|
+
}.to_not raise_exception
|
83
|
+
|
84
|
+
expect {
|
85
|
+
Reactor::Event.publish(:thing, srsly: true)
|
86
|
+
}.to_not raise_exception
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'without specifying console usage' do
|
91
|
+
it 'requires a second argument srsly: true' do
|
92
|
+
expect {
|
93
|
+
Reactor::Event.publish(:thing)
|
94
|
+
}.to raise_exception(ArgumentError)
|
95
|
+
|
96
|
+
expect {
|
97
|
+
Reactor::Event.publish(:thing, srsly: true)
|
98
|
+
}.to_not raise_exception
|
99
|
+
end
|
79
100
|
end
|
80
101
|
end
|
81
102
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reactor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- winfred
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2019-
|
16
|
+
date: 2019-08-28 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: rails
|
@@ -234,7 +234,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
234
234
|
- !ruby/object:Gem::Version
|
235
235
|
version: '0'
|
236
236
|
requirements: []
|
237
|
-
|
237
|
+
rubyforge_project:
|
238
|
+
rubygems_version: 2.7.6
|
238
239
|
signing_key:
|
239
240
|
specification_version: 4
|
240
241
|
summary: Sidekiq/ActiveRecord pubsub lib
|