abstractivator 0.15.0 → 0.16.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54f3b2d12bb7c97e29e93c119a4765d096bd67d8
4
- data.tar.gz: 0b51547e1f0d6dd51d166094aa1fc49e86f3d9be
3
+ metadata.gz: 26f878ae4109bef8680cc85a6b0d903b97778871
4
+ data.tar.gz: ce8833f063703cdba55a4c7367cc66143f19c622
5
5
  SHA512:
6
- metadata.gz: 7ef0efeda3115b72e4e5c68050f01ed5da7b28771be78177aa8069c27eb0151583e6fc1d59356165797a7150a7dd98fd95eb8b768a27df1e9a02669c11ecad50
7
- data.tar.gz: 2cd2fd65d5d5da79a16bcace335f1ea136a43bea38e69a5a51656486c0a3663536b5a2db8000d766fed4336b1d97974024fac19fbd410c109080a7b1850d1766
6
+ metadata.gz: d45dc88be70f404b5449d61cc8684bf2b45c2deb2a07503d5586d75a1ab3295b15fde8fc5c2e180a266f1e7602832c82b2e409d94b8270b5b1d1b32445eafc30
7
+ data.tar.gz: 96b27bef0776b6c25c5ea7bc0c1aff4f0801439e53f866938e6c4e02db8e14efda2f7bc2203352066b75b2c9a17a493d8e6cdd227c7909df702245beb8b30a1b
@@ -0,0 +1 @@
1
+ 2.4.1
@@ -98,6 +98,12 @@ module Abstractivator
98
98
  safe_action = proc do
99
99
  begin
100
100
  [action.call, nil]
101
+ rescue SignalException => e
102
+ # The thread has been instructed to shut down, so let it.
103
+ # Don't pass on the exception to another thread/fiber.
104
+ # We will assume whatever is shutting down the thread will
105
+ # also account for the paused fiber on its own.
106
+ raise
101
107
  rescue Exception => e
102
108
  [nil, e]
103
109
  end
@@ -1,3 +1,3 @@
1
1
  module Abstractivator
2
- VERSION = '0.15.0'
2
+ VERSION = '0.16.0'
3
3
  end
@@ -40,7 +40,7 @@ describe Abstractivator::FiberDefer do
40
40
  it 'propagates the thread/fiber-local variables into the block' do
41
41
  EM.run do
42
42
  guard = {
43
- Thread.current[:meaning] => proc { |x| Thread.current[:meaning] = x }
43
+ Thread.current[:meaning] => proc { |x| Thread.current[:meaning] = x }
44
44
  }
45
45
  with_fiber_defer(guard) do
46
46
  expect(Thread.current[:meaning]).to eql 42
@@ -123,6 +123,34 @@ describe Abstractivator::FiberDefer do
123
123
  end
124
124
  end
125
125
  end
126
+ it 'terminates the worker thread on SignalError' do
127
+ EM.run do
128
+ with_fiber_defer do
129
+ worker_thread = nil
130
+ f = Fiber.current
131
+ fiber_defer do
132
+ worker_thread = Thread.current
133
+ worker_thread.abort_on_exception = false # don't immediately exit() the main thread when we raise
134
+ EM.next_tick { f.resume([nil, nil]) } # allow fiber_defer to return when control returns to the event loop on the main thread
135
+ raise SignalException.new('TERM')
136
+ end
137
+ expect { worker_thread.join(1) }.to raise_error SignalException # join raises when Thread#abort_on_exception is false
138
+ expect(worker_thread.alive?).to be_falsey
139
+ EM.threadpool.clear # otherwise, EM will try to re-join these during its cleanup, crash, and leave the EM singleton in a bad state for future tests
140
+ EM.stop
141
+ end
142
+ end
143
+ end
144
+ it 'does not terminate the worker thread on non-SignalErrors' do
145
+ EM.run do
146
+ with_fiber_defer do
147
+ worker_thread = nil
148
+ expect{fiber_defer{ worker_thread = Thread.current; raise 'oops' }}.to raise_error 'oops'
149
+ expect(worker_thread.alive?).to be_truthy
150
+ EM.stop
151
+ end
152
+ end
153
+ end
126
154
  it 'works with simultaneous deferred actions' do
127
155
  EM.run do
128
156
  log = []
@@ -205,15 +233,15 @@ describe Abstractivator::FiberDefer do
205
233
  it 'applies the inherited guard and then the local guard upon entering and exiting the block' do
206
234
  EM.run do
207
235
  guard1 = {
208
- Thread.current[:a] => proc {|x| Thread.current[:a] = x},
209
- Thread.current[:b] => proc {|x| Thread.current[:b] = x}
236
+ Thread.current[:a] => proc {|x| Thread.current[:a] = x},
237
+ Thread.current[:b] => proc {|x| Thread.current[:b] = x}
210
238
  }
211
239
  with_fiber_defer(guard1) do
212
240
  Thread.current[:b] = 22
213
241
  Thread.current[:c] = 33
214
242
  guard2 = {
215
- Thread.current[:b] => proc {|x| Thread.current[:b] = x},
216
- Thread.current[:c] => proc {|x| Thread.current[:c] = x}
243
+ Thread.current[:b] => proc {|x| Thread.current[:b] = x},
244
+ Thread.current[:c] => proc {|x| Thread.current[:c] = x}
217
245
  }
218
246
  fiber_defer(guard2) do
219
247
  expect(Thread.current[:a]).to eql 1
@@ -29,7 +29,7 @@ describe Abstractivator::Lazy do
29
29
  expect(lazy { 42 } != 42).to be false
30
30
  expect(lazy { 42 } != 99).to be true
31
31
  expect(lazy { 42 } === 42).to be true
32
- expect(Fixnum === lazy { 42 }).to be true
32
+ expect(Integer === lazy { 42 }).to be true
33
33
  expect(Array === lazy { 42 }).to be false
34
34
  expect(!(lazy { true })).to be false
35
35
  expect(!(lazy { false })).to be true
@@ -54,7 +54,7 @@ describe Abstractivator::Lazy do
54
54
  it 'reveals the value type if the value has already been forced' do
55
55
  value = lazy { 42 }
56
56
  value.to_s
57
- expect(value.inspect).to match /#<Abstractivator::Lazy:Fixnum:0x[0-9a-f]+>/
57
+ expect(value.inspect).to match /#<Abstractivator::Lazy:Integer:0x[0-9a-f]+>/
58
58
  end
59
59
  end
60
60
 
@@ -118,7 +118,7 @@ describe Abstractivator::Trees do
118
118
  expect(call_count).to eql 2
119
119
  end
120
120
  it 'raises an error is the value is not an array' do
121
- expect{transform_one_path({a: 1}, 'a[]') { |x| x }}.to raise_error 'Expected an array but got Fixnum: 1'
121
+ expect{transform_one_path({a: 1}, 'a[]') { |x| x }}.to raise_error 'Expected an array but got Integer: 1'
122
122
  expect{transform_one_path({a: {b: 1}}, 'a[]') { |x| x }}.to raise_error 'Expected an array but got Hash: {:b=>1}'
123
123
  end
124
124
  end
@@ -140,7 +140,7 @@ describe Abstractivator::Trees do
140
140
  expect(call_count).to eql 2
141
141
  end
142
142
  it 'raises an error is the value is not a hash' do
143
- expect{transform_one_path({a: 1}, 'a{}') { |x| x }}.to raise_error 'Expected a hash but got Fixnum: 1'
143
+ expect{transform_one_path({a: 1}, 'a{}') { |x| x }}.to raise_error 'Expected a hash but got Integer: 1'
144
144
  expect{transform_one_path({a: [1, 2]}, 'a{}') { |x| x }}.to raise_error 'Expected a hash but got Array: [1, 2]'
145
145
  end
146
146
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abstractivator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Winton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-27 00:00:00.000000000 Z
11
+ date: 2017-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -109,6 +109,7 @@ extra_rdoc_files: []
109
109
  files:
110
110
  - ".gitignore"
111
111
  - ".rspec"
112
+ - ".ruby-version"
112
113
  - CHANGES.md
113
114
  - Gemfile
114
115
  - LICENSE.txt
@@ -185,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
186
  version: '0'
186
187
  requirements: []
187
188
  rubyforge_project:
188
- rubygems_version: 2.6.2
189
+ rubygems_version: 2.6.12
189
190
  signing_key:
190
191
  specification_version: 4
191
192
  summary: Utilities
@@ -212,4 +213,3 @@ test_files:
212
213
  - spec/lib/abstractivator/value_map_spec.rb
213
214
  - spec/lib/enumerable_ext_spec.rb
214
215
  - spec/lib/exception_ext_spec.rb
215
- has_rdoc: