quack_concurrency 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/quack_concurrency/future.rb +7 -3
- data/spec/future_spec.rb +36 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44dbae9778d3d75b1415d9616a4e34eb621a878047f02672826114c931b343f5
|
4
|
+
data.tar.gz: 284808d284aca2332d1dc5e10304e666246ece69fa65d17d785bb46e6a4de843
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 742a8ca5bd55cf8619e070466731f00847801145f98430855dd696e41199fba4ab112fd189965348d77307f237ec9db9d61df3ef28c41e7e53d91369a791fd72
|
7
|
+
data.tar.gz: 3e5e029887be11e3a98bb4be5012035800be934e005ce0d72936f9ebc1166e8d168d011b767b50d340091a6dcfae0e563af34de0e9c011ba2881be0ed44e689d
|
@@ -45,13 +45,17 @@ module QuackConcurrency
|
|
45
45
|
# @param exception [Exception]
|
46
46
|
# @return [void]
|
47
47
|
def raise(exception = nil)
|
48
|
-
|
49
|
-
|
48
|
+
exception = case
|
49
|
+
when exception == nil then StandardError.new
|
50
|
+
when exception.is_a?(Exception) then exception
|
51
|
+
when exception <= Exception then exception.new
|
52
|
+
else
|
53
|
+
Kernel.raise(ArgumentError, "'exception' must be nil or an instance of or descendant of Exception")
|
50
54
|
end
|
51
55
|
@mutex.synchronize do
|
52
56
|
Kernel.raise(Complete) if @complete
|
53
57
|
@complete = true
|
54
|
-
@exception = exception
|
58
|
+
@exception = exception
|
55
59
|
@waiter.resume_all_forever
|
56
60
|
end
|
57
61
|
nil
|
data/spec/future_spec.rb
CHANGED
@@ -108,5 +108,41 @@ RSpec.describe QuackConcurrency::Future do
|
|
108
108
|
end
|
109
109
|
|
110
110
|
end
|
111
|
+
|
112
|
+
describe "#raise" do
|
113
|
+
|
114
|
+
context "when called with nil" do
|
115
|
+
it "should set the error to raise StandardError" do
|
116
|
+
future = QuackConcurrency::Future.new
|
117
|
+
expect{ future.raise }.not_to raise_error
|
118
|
+
expect{ future.get }.to raise_error(StandardError)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
context "when called with an error instance" do
|
123
|
+
it "should set the error to that instance" do
|
124
|
+
future = QuackConcurrency::Future.new
|
125
|
+
e = TypeError.new
|
126
|
+
expect{ future.raise(e) }.not_to raise_error
|
127
|
+
expect{ future.get }.to raise_error(e)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
context "when called with an error class" do
|
132
|
+
it "should set the error to an instance of that class" do
|
133
|
+
future = QuackConcurrency::Future.new
|
134
|
+
expect{ future.raise(TypeError) }.not_to raise_error
|
135
|
+
expect{ future.get }.to raise_error(TypeError)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
context "when called with an invalid argument" do
|
140
|
+
it "should raise ArgumentError" do
|
141
|
+
future = QuackConcurrency::Future.new
|
142
|
+
expect{ future.raise("error") }.to raise_error(ArgumentError)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
111
147
|
|
112
148
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quack_concurrency
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Fors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Offers concurrency tools that could also be found in the 'Concurrent
|
14
14
|
Ruby'. However, all these tools will also accept core class duck types to build
|
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
63
|
version: '0'
|
64
64
|
requirements: []
|
65
65
|
rubyforge_project:
|
66
|
-
rubygems_version: 2.7.
|
66
|
+
rubygems_version: 2.7.7
|
67
67
|
signing_key:
|
68
68
|
specification_version: 4
|
69
69
|
summary: Concurrency tools that accept duck types of core classes.
|