delayer-deferred 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/delayer/deferred.rb +9 -1
- data/lib/delayer/deferred/tools.rb +2 -1
- data/lib/delayer/deferred/version.rb +1 -1
- data/test/deferred_test.rb +12 -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: 480af4c09dcc44eb42d3b9c0cc0524a6ac41c5c3b40d0bcf36eeb6bfda22ce7f
|
4
|
+
data.tar.gz: 39b94a04b5a6081e5a37320461f957ca07f69fd87ae1aa19e440cfb4cc20ab82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6eda321b6639b2cb6ac638e9068c18cf82ac80ba78070c8dfce045e55d0fcd3d88467091905a9351622a385ac5b5ce32bc2b5b9b87a1b9fd826db2a89b772923
|
7
|
+
data.tar.gz: e869a145b9f6de42f278740f53514e37d37bda44255698229d059bd244c17275e42295d82321dd6d2736a0638b8ad17666e47e995a27e8838938c900572df879
|
data/lib/delayer/deferred.rb
CHANGED
@@ -14,8 +14,16 @@ module Delayer
|
|
14
14
|
#真ならデバッグ情報を集める
|
15
15
|
attr_accessor :debug
|
16
16
|
|
17
|
+
def new(*rest, name: caller_locations(1,1).first.to_s, &block)
|
18
|
+
super(*rest, name: name, &block)
|
19
|
+
end
|
20
|
+
|
17
21
|
def method_missing(*rest, &block)
|
18
|
-
Delayer::Deferred::
|
22
|
+
Delayer::Deferred::Promise.__send__(*rest, &block)
|
23
|
+
end
|
24
|
+
|
25
|
+
def respond_to_missing?(symbol, include_private)
|
26
|
+
Delayer::Deferred::Promise.respond_to?(symbol, include_private)
|
19
27
|
end
|
20
28
|
end
|
21
29
|
end
|
@@ -32,8 +32,8 @@ module Delayer::Deferred
|
|
32
32
|
# ==== Return
|
33
33
|
# Deferred
|
34
34
|
def when(*args)
|
35
|
-
return self.next{[]} if args.empty?
|
36
35
|
args = args.flatten
|
36
|
+
return self.next{ [].freeze } if args.empty?
|
37
37
|
args.each_with_index{|d, index|
|
38
38
|
unless d.is_a?(Deferredable::Chainable) || d.is_a?(Deferredable::Awaitable)
|
39
39
|
raise TypeError, "Argument #{index} of Deferred.when must be #{Deferredable::Chainable}, but given #{d.class}"
|
@@ -47,6 +47,7 @@ module Delayer::Deferred
|
|
47
47
|
[res, *follow.map{|d| +d }]
|
48
48
|
}
|
49
49
|
end
|
50
|
+
|
50
51
|
# Kernel#systemを呼び出して、コマンドが成功たら成功するDeferredを返す。
|
51
52
|
# 失敗した場合、trap{}ブロックには $? の値(Process::Status)か、例外が発生した場合それが渡される
|
52
53
|
# ==== Args
|
data/test/deferred_test.rb
CHANGED
@@ -189,6 +189,18 @@ describe(Delayer::Deferred) do
|
|
189
189
|
assert_empty result
|
190
190
|
end
|
191
191
|
|
192
|
+
it "empty array given" do
|
193
|
+
result = failure = false
|
194
|
+
delayer = Delayer.generate_class
|
195
|
+
eval_all_events(delayer) do
|
196
|
+
delayer.Deferred.when([]).next{ |values|
|
197
|
+
result = values
|
198
|
+
}.trap{ |exception|
|
199
|
+
failure = exception } end
|
200
|
+
assert_equal false, failure
|
201
|
+
assert_empty result
|
202
|
+
end
|
203
|
+
|
192
204
|
it "no deferred given for default delayer" do
|
193
205
|
result = failure = false
|
194
206
|
eval_all_events do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delayer-deferred
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toshiaki Asai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: delayer
|
@@ -207,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0'
|
209
209
|
requirements: []
|
210
|
-
rubygems_version: 3.0.
|
210
|
+
rubygems_version: 3.0.4
|
211
211
|
signing_key:
|
212
212
|
specification_version: 4
|
213
213
|
summary: Deferred for Delayer
|