bubble-wrap 1.9.1 → 1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/Gemfile.lock +1 -1
- data/README.md +22 -2
- data/lib/bubble-wrap/version.rb +1 -1
- data/motion/reactor/deferrable.rb +8 -0
- data/motion/reactor/dependent_deferrable.rb +27 -0
- data/spec/motion/reactor/dependent_deferrable_spec.rb +93 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95bb977273e17a942c1eafb9b1b50310c6e0eb9d
|
4
|
+
data.tar.gz: 05a96c0c6101319c9e182f857d2f598eafa2011f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6947c06f77c6dc682e3dfc96d1c998187ae7a6fadd523d55e0a7031a2fc85fcdc1a444ada67de7314ea1484e42dc49deb9540f9a38ba93bff520f65563994865
|
7
|
+
data.tar.gz: 3e9c849bb376dfbb3b9cd1a73747a420fb25168cea4907991cfa17b5e8b6197e0e6d0e386c44f1e536a77d7d18c712e5d516abfde1c9820dbf001bb4eb6e94ba
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,17 @@
|
|
1
1
|
## Unreleased
|
2
2
|
|
3
|
-
[Commit history](https://github.com/rubymotion/BubbleWrap/compare/v1.9.
|
3
|
+
[Commit history](https://github.com/rubymotion/BubbleWrap/compare/v1.9.2...master)
|
4
|
+
|
5
|
+
## 1.9.2
|
6
|
+
|
7
|
+
[Commit history](https://github.com/rubymotion/BubbleWrap/compare/v1.9.1...v1.9.2)
|
8
|
+
|
9
|
+
* Added `DependentDeferrable`. ([#469](https://github.com/rubymotion/BubbleWrap/pull/469))
|
4
10
|
|
5
11
|
## 1.9.1
|
6
12
|
|
13
|
+
[Commit history](https://github.com/rubymotion/BubbleWrap/compare/v1.9.0...v1.9.1)
|
14
|
+
|
7
15
|
* Fix issue in loading iOS 8 constants for CoreLocation
|
8
16
|
|
9
17
|
## 1.9.0
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -24,10 +24,10 @@ gem install bubble-wrap
|
|
24
24
|
require 'bubble-wrap'
|
25
25
|
```
|
26
26
|
|
27
|
-
If you
|
27
|
+
If you use Bundler:
|
28
28
|
|
29
29
|
```ruby
|
30
|
-
gem "bubble-wrap", "~> 1.9.
|
30
|
+
gem "bubble-wrap", "~> 1.9.2"
|
31
31
|
```
|
32
32
|
|
33
33
|
BubbleWrap is split into multiple modules so that you can easily choose which parts are included at compile-time.
|
@@ -1118,6 +1118,26 @@ Great sadness!
|
|
1118
1118
|
=> [:passed]
|
1119
1119
|
```
|
1120
1120
|
|
1121
|
+
#### DependentDeferrable
|
1122
|
+
|
1123
|
+
`DependentDeferrable` depends on children deferrables. A `DependentDeferrable`
|
1124
|
+
succeeds only when every child succeeds and fails immediately when any child
|
1125
|
+
fails
|
1126
|
+
|
1127
|
+
```ruby
|
1128
|
+
> d1 = EM::DefaultDeferrable.new
|
1129
|
+
=> #<BubbleWrap::Reactor::DefaultDeferrable:0x10c713750>
|
1130
|
+
> d2 = EM::DefaultDeferrable.new
|
1131
|
+
=> #<BubbleWrap::Reactor::DefaultDeferrable:0x10370bb10>
|
1132
|
+
> d = EM::DependentDeferrable.on(d1, d2)
|
1133
|
+
=> #<BubbleWrap::Reactor::DependentDeferrable:0x106c17b80>
|
1134
|
+
> d.callback {|a, b| puts "a: #{a} b: #{b}"}
|
1135
|
+
=> [#<Proc:0x103075210>]
|
1136
|
+
> d1.succeed 'one', 'one more'
|
1137
|
+
> d2.succeed :two
|
1138
|
+
a: ["one", "one more"] b: [:two]
|
1139
|
+
```
|
1140
|
+
|
1121
1141
|
#### ThreadAwareDeferrable
|
1122
1142
|
|
1123
1143
|
```ruby
|
data/lib/bubble-wrap/version.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
module BubbleWrap
|
2
|
+
module Reactor
|
3
|
+
class DependentDeferrable < DefaultDeferrable
|
4
|
+
# args are Deferrable(s) which the returned Deferrable depends on.
|
5
|
+
# returns a Deferrable that depends on args.
|
6
|
+
# which:
|
7
|
+
# succeeds only when every Deferrable in args succeeds
|
8
|
+
# fails immediately when any Deferrable in args fails
|
9
|
+
# Have to be careful that #deferred_args for DependentDeferrable is a list of #deferred_args from its children Deferrable(s).
|
10
|
+
def self.on(*args)
|
11
|
+
deferrable = self.new
|
12
|
+
@children_deferrables = args
|
13
|
+
@children_deferrables.each do |e|
|
14
|
+
e.callback do |result|
|
15
|
+
if @children_deferrables.all? {|a| a.deferred_status == :succeeded}
|
16
|
+
deferrable.succeed(*@children_deferrables.map(&:deferred_args))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
e.errback do |result|
|
20
|
+
deferrable.fail(*e.deferred_args)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
deferrable
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
describe BubbleWrap::Reactor::DependentDeferrable do
|
2
|
+
|
3
|
+
before do
|
4
|
+
@subject = Class.new do
|
5
|
+
include BubbleWrap::Reactor::Deferrable
|
6
|
+
end
|
7
|
+
@d1 = @subject.new
|
8
|
+
@d2 = @subject.new
|
9
|
+
@object = BubbleWrap::Reactor::DependentDeferrable.on(@d1, @d2)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '.callback' do
|
13
|
+
|
14
|
+
it "calls the callback block with arguments after all children .succeed" do
|
15
|
+
args1 = [1, 2]
|
16
|
+
args2 = [3, 4]
|
17
|
+
@object.callback do |*passed_args|
|
18
|
+
passed_args.should.equal [args1, args2]
|
19
|
+
end
|
20
|
+
@d1.succeed *args1
|
21
|
+
@d2.succeed *args2
|
22
|
+
end
|
23
|
+
|
24
|
+
it "calls the callback block with arguments only after all children .succeed" do
|
25
|
+
execution_order = []
|
26
|
+
@object.callback do |*passed_args|
|
27
|
+
execution_order << 3
|
28
|
+
end
|
29
|
+
execution_order << 1
|
30
|
+
@d1.succeed :succeeds
|
31
|
+
execution_order << 2
|
32
|
+
@d2.succeed :succeeds
|
33
|
+
execution_order.should.equal [1, 2, 3]
|
34
|
+
end
|
35
|
+
|
36
|
+
it "calls the callback if even if the deferrable already succeeded" do
|
37
|
+
@d1.succeed :succeeded1
|
38
|
+
@d2.succeed :succeeded2
|
39
|
+
@object.callback do |*args|
|
40
|
+
NSLog "args: #{args} class: #{args.class}"
|
41
|
+
args[0].should.equal [:succeeded1]
|
42
|
+
args[1].should.equal [:succeeded2]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '.errback' do
|
49
|
+
it "calls the errback block after a child fails" do
|
50
|
+
args1 = [1, 2]
|
51
|
+
args2 = [3, 4]
|
52
|
+
@object.errback do |*passed_args|
|
53
|
+
passed_args.should.equal args1
|
54
|
+
end
|
55
|
+
@d1.fail *args1
|
56
|
+
end
|
57
|
+
|
58
|
+
it "calls the errback block immediately after a child fails" do
|
59
|
+
execution_order = []
|
60
|
+
@object.errback do |*passed_args|
|
61
|
+
execution_order << 2
|
62
|
+
end
|
63
|
+
execution_order << 1
|
64
|
+
@d1.fail :fail
|
65
|
+
execution_order << 3
|
66
|
+
@d2.fail :fail
|
67
|
+
execution_order.should.equal [1, 2, 3]
|
68
|
+
end
|
69
|
+
|
70
|
+
it "calls the errback block after a child fails even if others succeeds" do
|
71
|
+
args1 = [1, 2]
|
72
|
+
args2 = [3, 4]
|
73
|
+
callback_called = false
|
74
|
+
@object.callback do |*passed_args|
|
75
|
+
callback_called = true
|
76
|
+
end
|
77
|
+
@object.errback do |*passed_args|
|
78
|
+
passed_args.should.equal args2
|
79
|
+
end
|
80
|
+
@d1.succeed *args1
|
81
|
+
@d2.fail *args2
|
82
|
+
callback_called.should.equal false
|
83
|
+
end
|
84
|
+
|
85
|
+
it "calls the errback block even if the deferrable failed first" do
|
86
|
+
@d1.fail :err
|
87
|
+
@object.errback do |err|
|
88
|
+
err.should.equal :err
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bubble-wrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Aimonetti
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2015-07-
|
17
|
+
date: 2015-07-27 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: mocha
|
@@ -141,6 +141,7 @@ extra_rdoc_files:
|
|
141
141
|
- motion/reactor.rb
|
142
142
|
- motion/reactor/default_deferrable.rb
|
143
143
|
- motion/reactor/deferrable.rb
|
144
|
+
- motion/reactor/dependent_deferrable.rb
|
144
145
|
- motion/reactor/eventable.rb
|
145
146
|
- motion/reactor/future.rb
|
146
147
|
- motion/reactor/periodic_timer.rb
|
@@ -190,6 +191,7 @@ extra_rdoc_files:
|
|
190
191
|
- spec/motion/motion/core_motion_spec.rb
|
191
192
|
- spec/motion/network-indicator/network_indicator_spec.rb
|
192
193
|
- spec/motion/reactor/deferrable_spec.rb
|
194
|
+
- spec/motion/reactor/dependent_deferrable_spec.rb
|
193
195
|
- spec/motion/reactor/eventable_spec.rb
|
194
196
|
- spec/motion/reactor/thread_aware_deferrable_spec.rb
|
195
197
|
- spec/motion/reactor_spec.rb
|
@@ -280,6 +282,7 @@ files:
|
|
280
282
|
- motion/reactor.rb
|
281
283
|
- motion/reactor/default_deferrable.rb
|
282
284
|
- motion/reactor/deferrable.rb
|
285
|
+
- motion/reactor/dependent_deferrable.rb
|
283
286
|
- motion/reactor/eventable.rb
|
284
287
|
- motion/reactor/future.rb
|
285
288
|
- motion/reactor/periodic_timer.rb
|
@@ -386,6 +389,7 @@ files:
|
|
386
389
|
- spec/motion/motion/core_motion_spec.rb
|
387
390
|
- spec/motion/network-indicator/network_indicator_spec.rb
|
388
391
|
- spec/motion/reactor/deferrable_spec.rb
|
392
|
+
- spec/motion/reactor/dependent_deferrable_spec.rb
|
389
393
|
- spec/motion/reactor/eventable_spec.rb
|
390
394
|
- spec/motion/reactor/thread_aware_deferrable_spec.rb
|
391
395
|
- spec/motion/reactor_spec.rb
|
@@ -459,6 +463,7 @@ test_files:
|
|
459
463
|
- spec/motion/motion/core_motion_spec.rb
|
460
464
|
- spec/motion/network-indicator/network_indicator_spec.rb
|
461
465
|
- spec/motion/reactor/deferrable_spec.rb
|
466
|
+
- spec/motion/reactor/dependent_deferrable_spec.rb
|
462
467
|
- spec/motion/reactor/eventable_spec.rb
|
463
468
|
- spec/motion/reactor/thread_aware_deferrable_spec.rb
|
464
469
|
- spec/motion/reactor_spec.rb
|