async-proxy 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/async-proxy.gemspec +2 -2
- data/lib/computed_proxy.rb +5 -3
- data/lib/object_proxy.rb +3 -3
- data/spec/async-proxy_spec.rb +5 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/async-proxy.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{async-proxy}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Angel Faus"]
|
12
|
-
s.date = %q{2010-09-
|
12
|
+
s.date = %q{2010-09-20}
|
13
13
|
s.description = %q{turn any object into an async version of itself, so that all method calls will run asynchronously, including dependent computations}
|
14
14
|
s.email = %q{angel@vlex.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/computed_proxy.rb
CHANGED
@@ -12,10 +12,12 @@ module AsyncProxy
|
|
12
12
|
|
13
13
|
attr_reader :callable
|
14
14
|
attr_reader :proc
|
15
|
+
attr_reader :trace_name
|
15
16
|
|
16
|
-
def initialize(callable, proc)
|
17
|
-
@callable
|
18
|
-
@proc
|
17
|
+
def initialize(callable, proc, trace_name = nil)
|
18
|
+
@callable = callable
|
19
|
+
@proc = proc
|
20
|
+
@trace_name = trace_name
|
19
21
|
@callbacks = []
|
20
22
|
end
|
21
23
|
|
data/lib/object_proxy.rb
CHANGED
@@ -46,8 +46,8 @@ module AsyncProxy
|
|
46
46
|
#
|
47
47
|
# returns an async proxy object, that can be used exactly to recover the block's return
|
48
48
|
# value or chain more computations
|
49
|
-
def when_ready(&block)
|
50
|
-
result_proxy = AsyncProxy::ComputedProxy.new(self, block)
|
49
|
+
def when_ready(trace_name = nil, &block)
|
50
|
+
result_proxy = AsyncProxy::ComputedProxy.new(self, block, trace_name)
|
51
51
|
register_callback {result_proxy.launch_computation}
|
52
52
|
result_proxy
|
53
53
|
end
|
@@ -65,7 +65,7 @@ module AsyncProxy
|
|
65
65
|
|
66
66
|
private
|
67
67
|
def method_missing(symbol, *args)
|
68
|
-
when_ready do |obj|
|
68
|
+
when_ready(symbol) do |obj|
|
69
69
|
obj.send(symbol, *args)
|
70
70
|
end
|
71
71
|
end
|
data/spec/async-proxy_spec.rb
CHANGED
@@ -52,5 +52,10 @@ describe "AsyncProxy" do
|
|
52
52
|
it "timeout" do
|
53
53
|
lambda {1.async.slow_inc.sync(:timeout => 0.5)}.should raise_error(Timeout::Error)
|
54
54
|
end
|
55
|
+
|
56
|
+
it "trace_name exposes the method name" do
|
57
|
+
x = 1.async.slow_inc
|
58
|
+
x.trace_name.should == :slow_inc
|
59
|
+
end
|
55
60
|
|
56
61
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Angel Faus
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-09-
|
17
|
+
date: 2010-09-20 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|