futuroscope 0.1.9 → 0.1.10
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/README.md +2 -0
- data/lib/futuroscope/future.rb +9 -5
- data/lib/futuroscope/version.rb +1 -1
- data/spec/futuroscope/future_spec.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 337e18c04c9dafa5a2680bc3f1565fa1f8fd93e2
|
4
|
+
data.tar.gz: 178323eacd389f23797b512639853a6a00e2a4db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4c25e2154015c1165048966eac5fd73de8193b944428b95c41e7b21cebb6d2e5f721bef55fcfe7ef2864d4dd8338e41ffe4ac5f043477dd0f98678eda06a8ce
|
7
|
+
data.tar.gz: 6863eb57bce929a577d196e4ce2a6a477deec66f032292f9efee777d3e21fb2ad7073c7d86735ea16886e6627886380063a0686af3f4ee2b7e1c820b6ec8b82e
|
data/README.md
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
[](https://coveralls.io/r/codegram/futuroscope)
|
6
6
|
[](https://gemnasium.com/codegram/futuroscope)
|
7
7
|
|
8
|
+
**Join a live discussion on Gitter**: [](https://gitter.im/codegram/futuroscope)
|
9
|
+
|
8
10
|
Futursocope is a simple library that implements futures in ruby. Futures are a
|
9
11
|
concurrency pattern meant to help you deal with threads in a simple, transparent way.
|
10
12
|
|
data/lib/futuroscope/future.rb
CHANGED
@@ -46,10 +46,7 @@ module Futuroscope
|
|
46
46
|
#
|
47
47
|
# Returns the Future's block execution result.
|
48
48
|
def __getobj__
|
49
|
-
|
50
|
-
|
51
|
-
raise resolved[:exception] if resolved[:exception]
|
52
|
-
resolved[:value]
|
49
|
+
resolved_future_value_or_raise[:value]
|
53
50
|
end
|
54
51
|
|
55
52
|
def __setobj__ obj
|
@@ -57,7 +54,7 @@ module Futuroscope
|
|
57
54
|
end
|
58
55
|
|
59
56
|
def marshal_dump
|
60
|
-
|
57
|
+
resolved_future_value_or_raise
|
61
58
|
end
|
62
59
|
|
63
60
|
def marshal_load value
|
@@ -70,6 +67,13 @@ module Futuroscope
|
|
70
67
|
|
71
68
|
private
|
72
69
|
|
70
|
+
def resolved_future_value_or_raise
|
71
|
+
resolved = resolved_future_value
|
72
|
+
|
73
|
+
raise resolved[:exception] if resolved[:exception]
|
74
|
+
resolved
|
75
|
+
end
|
76
|
+
|
73
77
|
def resolved_future_value
|
74
78
|
@resolved_future || @mutex.synchronize do
|
75
79
|
@resolved_future ||= @queue.pop
|
data/lib/futuroscope/version.rb
CHANGED
@@ -59,6 +59,14 @@ module Futuroscope
|
|
59
59
|
expect(Marshal.load(dumped).future_value).to eq(object)
|
60
60
|
end
|
61
61
|
|
62
|
+
it "re-raises captured exception when trying to marshal" do
|
63
|
+
future = Future.new{ raise Exception }
|
64
|
+
|
65
|
+
expect(lambda{
|
66
|
+
Marshal.dump(future)
|
67
|
+
}).to raise_error(Exception)
|
68
|
+
end
|
69
|
+
|
62
70
|
it "correctly duplicates a future object" do
|
63
71
|
object = [1, 2, 3]
|
64
72
|
future = Future.new { object }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: futuroscope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep Jaume Rey Peroy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|