futuroscope 0.1.6 → 0.1.7
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/.ruby-version +1 -1
- data/.travis.yml +4 -1
- data/Gemfile +3 -0
- data/README.md +5 -5
- data/futuroscope.gemspec +1 -0
- data/lib/futuroscope/future.rb +6 -2
- data/lib/futuroscope/version.rb +1 -1
- data/spec/futuroscope/future_spec.rb +8 -1
- data/spec/spec_helper.rb +1 -1
- metadata +18 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03cdb1ddd7c212ef63c625d610754a92386a1c73
|
4
|
+
data.tar.gz: 90f54b489a3176aa6ad82c17195cb7d8e429d687
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7cf8ff237e9610854c1dd2ab2aabb24143ce632cdf376900e68685811ba72075532c8eb0d06e685992de2ac1a5bc1da556774f9b1ce4db6a7e0e62c5fda752f
|
7
|
+
data.tar.gz: 7dd1ea1d9c1dda894349798a74da9b9b3f05a73774c2a135b213b762662f8ac0ef9fd6d6723eac02c77c3b7ada1082601930a203c83a3fa6c0fa05f120d22f4e
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.1.0
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -17,14 +17,14 @@ You can learn more about futures here in this excellent article from @jpignata:
|
|
17
17
|
[Concurrency Patterns in Ruby:
|
18
18
|
Futures](http://tx.pignata.com/2012/11/concurrency-patterns-in-ruby-futures.html)
|
19
19
|
|
20
|
-
In Futuroscope, futures are instantiated with a simple ruby block. The future's
|
20
|
+
In Futuroscope, futures are instantiated with a simple ruby block. The future's
|
21
21
|
execution will immediately start in a different thread and when you call a
|
22
22
|
method on in it will be forwarded to the block's return value.
|
23
23
|
|
24
24
|
If the thread didn't finish yet, it will block the program's execution until
|
25
25
|
it's finished. Otherwise, it will immediately return its value.
|
26
26
|
|
27
|
-
Futuroscope is tested on `MRI 1.9.3`, `MRI 2.0.0`, `Rubinius (1.9)` and `JRuby (1.9)`.
|
27
|
+
Futuroscope is tested on `MRI 1.9.3`, `MRI 2.0.0`, `MRI 2.1.0`, `Rubinius (1.9)` and `JRuby (1.9)`.
|
28
28
|
|
29
29
|
Check out [futuroscope's post on Codegram's blog](http://blog.codegram.com/2013/5/new-gem-released-futuroscope) to get started.
|
30
30
|
|
@@ -120,9 +120,9 @@ end
|
|
120
120
|
|
121
121
|
## Considerations
|
122
122
|
|
123
|
-
You should never add **side-effects** to a future. They have to be thought of
|
124
|
-
like they were a local variable, with the only outcome that they're returning a
|
125
|
-
value.
|
123
|
+
You should never add **side-effects** to a future. They have to be thought of
|
124
|
+
like they were a local variable, with the only outcome that they're returning a
|
125
|
+
value.
|
126
126
|
|
127
127
|
You have to take into account that they really run in a different thread, so
|
128
128
|
you'll be potentially accessing code in parallel that could not be thread-safe.
|
data/futuroscope.gemspec
CHANGED
data/lib/futuroscope/future.rb
CHANGED
@@ -51,12 +51,16 @@ module Futuroscope
|
|
51
51
|
resolved[:value]
|
52
52
|
end
|
53
53
|
|
54
|
+
def __setobj__ obj
|
55
|
+
@resolved_future = { value: obj }
|
56
|
+
end
|
57
|
+
|
54
58
|
def marshal_dump
|
55
59
|
resolved_future_value
|
56
60
|
end
|
57
61
|
|
58
|
-
def
|
59
|
-
@resolved_future =
|
62
|
+
def marshal_load value
|
63
|
+
@resolved_future = value
|
60
64
|
end
|
61
65
|
|
62
66
|
def_delegators :__getobj__, :class, :kind_of?, :is_a?, :clone
|
data/lib/futuroscope/version.rb
CHANGED
@@ -46,7 +46,7 @@ module Futuroscope
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it "returns the original object when future_value gets called" do
|
49
|
-
object =
|
49
|
+
object = double
|
50
50
|
future = Future.new{ object }
|
51
51
|
|
52
52
|
expect(future.future_value.object_id === object.object_id).to eq(true)
|
@@ -59,5 +59,12 @@ module Futuroscope
|
|
59
59
|
expect(Marshal.load(dumped).future_value).to eq(object)
|
60
60
|
end
|
61
61
|
|
62
|
+
it "correctly duplicates a future object" do
|
63
|
+
object = [1, 2, 3]
|
64
|
+
future = Future.new { object }
|
65
|
+
|
66
|
+
expect(future.dup).to eq future
|
67
|
+
end
|
68
|
+
|
62
69
|
end
|
63
70
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
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.7
|
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:
|
11
|
+
date: 2014-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec-mocks
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: Futuroscope is yet another simple gem that implements the Futures concurrency
|
@@ -74,11 +74,11 @@ executables: []
|
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
-
- .gitignore
|
78
|
-
- .rspec
|
79
|
-
- .ruby-gemset
|
80
|
-
- .ruby-version
|
81
|
-
- .travis.yml
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".ruby-gemset"
|
80
|
+
- ".ruby-version"
|
81
|
+
- ".travis.yml"
|
82
82
|
- Gemfile
|
83
83
|
- Guardfile
|
84
84
|
- LICENSE.txt
|
@@ -110,17 +110,17 @@ require_paths:
|
|
110
110
|
- lib
|
111
111
|
required_ruby_version: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
|
-
- -
|
113
|
+
- - ">="
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
117
|
requirements:
|
118
|
-
- -
|
118
|
+
- - ">="
|
119
119
|
- !ruby/object:Gem::Version
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.0
|
123
|
+
rubygems_version: 2.2.0
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Futuroscope is yet another simple gem that implements the Futures concurrency
|
@@ -133,4 +133,3 @@ test_files:
|
|
133
133
|
- spec/futuroscope/worker_spec.rb
|
134
134
|
- spec/futuroscope_spec.rb
|
135
135
|
- spec/spec_helper.rb
|
136
|
-
has_rdoc:
|