delayer-deferred 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17fb3ffd22cfc243b60926a084efa91b6f9dee15
4
- data.tar.gz: f73bcf244106e7699719884d36d374d52be94080
3
+ metadata.gz: 37e4d01b997cbcc9e878f5743755883123843d4f
4
+ data.tar.gz: f43c013e223a6f30da88a500237fbb1920473e26
5
5
  SHA512:
6
- metadata.gz: ac64243c4a9440c32086bb99a94de79339b57f2aca5c57f2f068249d7adc9ac09736c09d7e8ccca220acbc52157c843eba3be63fe8577b1cd1e21b6f0cdbbc86
7
- data.tar.gz: 7ec556c87dad8a807a1d9e2318678f3f5fd95dd5accab5c18228194902ac4cc22b85eae1d39cb913f28cffda006bc22751b72306938ee82453be65b9cb918293
6
+ metadata.gz: e53e3785d68e9c69431742d81efaa936ee80a93cf726c0c42f022732e120cbb7b5a08036743081b780e9548d7fbe4d797b1688c2a4ec68fd8a4e0a072770a860
7
+ data.tar.gz: dd6d334922b6e999fd2f2eb90fc3fccd656d038d76cfa10b6742961246c1feaca452862837a57c8a3dc33d2ed4257df38fbc401f15e5a40f505f8b8fdab53c6f
data/.gitignore CHANGED
@@ -12,4 +12,5 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
- /vendor/
15
+ /vendor/
16
+ /Guardfile
@@ -26,4 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "rake", "~> 10.0"
27
27
  spec.add_development_dependency "minitest", "~> 5.7"
28
28
  spec.add_development_dependency "ruby-prof"
29
+ spec.add_development_dependency 'guard'
30
+ spec.add_development_dependency 'guard-shell'
31
+ spec.add_development_dependency 'guard-rake'
29
32
  end
@@ -51,12 +51,13 @@ module Delayer::Deferred
51
51
  end
52
52
 
53
53
  def self.fiber(&block)
54
- @_fiber ||= Fiber.new do |b|
55
- loop do
56
- b = Fiber.yield(b.())
57
- end
54
+ @_fiber ||= _gen_new_fiber
55
+ begin
56
+ result = @_fiber.resume(block)
57
+ rescue FiberError
58
+ @_fiber = _gen_new_fiber
59
+ result = @_fiber.resume(block)
58
60
  end
59
- result = @_fiber.resume(block)
60
61
  if result.is_a?(Delayer::Deferred::ResultContainer)
61
62
  result
62
63
  else
@@ -65,5 +66,13 @@ module Delayer::Deferred
65
66
  return result, _fiber
66
67
  end
67
68
  end
69
+
70
+ def self._gen_new_fiber
71
+ Fiber.new do |b|
72
+ loop do
73
+ b = Fiber.yield(b.())
74
+ end
75
+ end
76
+ end
68
77
  end
69
78
  end
@@ -40,7 +40,7 @@ module Delayer::Deferred
40
40
  # Kernel#systemを呼び出して、コマンドが成功たら成功するDeferredを返す。
41
41
  # 失敗した場合、trap{}ブロックには $? の値(Process::Status)か、例外が発生した場合それが渡される
42
42
  # ==== Args
43
- # [*args] Kernel#system の引数
43
+ # [*args] Kernel#spawn の引数
44
44
  # ==== Return
45
45
  # Deferred
46
46
  def system(*args)
@@ -50,7 +50,7 @@ module Delayer::Deferred
50
50
  if status && status.success?
51
51
  status
52
52
  else
53
- raise ForeignCommandAborted.new("command aborted: #{args.join(' ')}", process: $?) end
53
+ raise ForeignCommandAborted.new("command aborted: #{args.join(' ')}", process: status) end
54
54
  }
55
55
  end
56
56
  end
@@ -1,5 +1,5 @@
1
1
  module Delayer
2
2
  module Deferred
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
@@ -213,6 +213,47 @@ describe(Delayer::Deferred) do
213
213
  end
214
214
  end
215
215
 
216
+ describe 'recursive delayer' do
217
+ it 'Deferred#next call in Deferred.next' do
218
+ delayer = Delayer.generate_class
219
+ buf = []
220
+ erra = errb = errc = nil
221
+ eval_all_events(delayer) do
222
+ delayer.Deferred.next{
223
+ buf << 'begin A'
224
+ delayer.run
225
+ buf << 'end A'
226
+ }.trap{|err|
227
+ erra = err
228
+ }
229
+ delayer.Deferred.next{
230
+ buf << 'begin B'
231
+ delayer.run
232
+ buf << 'end B'
233
+ }.trap{|err|
234
+ errb = err
235
+ }
236
+ delayer.Deferred.next{
237
+ buf << 'begin C'
238
+ delayer.run
239
+ buf << 'end C'
240
+ }.trap{|err|
241
+ errc = err
242
+ }
243
+
244
+ end
245
+ refute erra
246
+ refute errb
247
+ refute errc
248
+ assert_includes buf, 'begin A'
249
+ assert_includes buf, 'end A'
250
+ assert_includes buf, 'begin B'
251
+ assert_includes buf, 'end B'
252
+ assert_includes buf, 'begin C'
253
+ assert_includes buf, 'end C'
254
+ end
255
+ end
256
+
216
257
  describe "Deferredable#system" do
217
258
  it "command successed" do
218
259
  succeed = failure = false
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: 1.1.0
4
+ version: 1.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: 2017-03-08 00:00:00.000000000 Z
11
+ date: 2017-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: delayer
@@ -86,6 +86,48 @@ dependencies:
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: guard
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: guard-shell
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: guard-rake
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
89
131
  description: Deferred for Delayer.
90
132
  email:
91
133
  - toshi.alternative@gmail.com