libuv 0.11.5 → 0.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4e11f7fcf587f1e694af11c237d10a82c769d47
4
- data.tar.gz: e46f16bebd08eafedf2405ba99138f83ce7d2dd0
3
+ metadata.gz: 190fdb960608a90e2d9d0bebf759428bd21e70bc
4
+ data.tar.gz: 086bc85b1f680d3a3dd60636096033bc41c04005
5
5
  SHA512:
6
- metadata.gz: 31f35fd8db2074335806a81de50071d56c0671d0166a340ea5b13e52e936085ea739c1e0c6c13a2d62f56b98986937afdb07bf0dbca8d430c1f17ecdcd9dfa7a
7
- data.tar.gz: 1ee9b1f2352ea42170bd0cda515c172be8c8aaa06c444763de54c50648868e4d2ec27508321ea9fbb1315acdbd5a7d17750faa024bd99796f932fd642bf67d23
6
+ metadata.gz: 9ba875bf5e8d40cac433c1c0bb399babbc7831dbd48e927a9c0fb7be29acea09060357bbf2ff6104f8bab3905469d95ce330e3943fbfb664eb6d695a532009bb
7
+ data.tar.gz: dd2b2fea2a67280417d4c6fe2ade106b752dd89b2850c05bde1f9eb00b6f26614ad09219b4cff129b2c892a84f3e924479c3f2d71ba1e4e4f19672f6ae605ccd
@@ -13,9 +13,11 @@ file 'ext/libuv/build' do
13
13
  end
14
14
 
15
15
  file 'ext/libuv/build/gyp' => 'ext/libuv/build' do
16
+ result = true
16
17
  if not File.directory?('ext/libuv/build/gyp')
17
- system "svn", "export", "-r1214", "http://gyp.googlecode.com/svn/trunk", "ext/libuv/build/gyp"
18
+ result = system "svn", "export", "-r1214", "http://gyp.googlecode.com/svn/trunk", "ext/libuv/build/gyp"
18
19
  end
20
+ raise 'unable to download gyp' unless result
19
21
  end
20
22
 
21
23
  CLEAN.include('ext/libuv/build/gyp')
@@ -3,6 +3,10 @@ module Libuv
3
3
  include Assertions, Resource, Listener, FsChecks
4
4
 
5
5
 
6
+ EOF = "0\r\n\r\n".freeze
7
+ CRLF = "\r\n".freeze
8
+
9
+
6
10
  attr_reader :fileno, :closed
7
11
 
8
12
 
@@ -102,10 +106,84 @@ module Libuv
102
106
  @chown_deferred.promise
103
107
  end
104
108
 
109
+ def send_file(stream, type = :raw, chunk_size = 4096)
110
+ @transmit_failure ||= method(:transmit_failure)
111
+ @transmit_data ||= method(:transmit_data)
112
+ @start_transmit ||= method(:start_transmit)
113
+ @next_chunk ||= method(:next_chunk)
114
+
115
+ @sending_file = @loop.defer
116
+ @file_stream = stream
117
+ @file_stream_type = type
118
+ @file_chunk_size = chunk_size
119
+ @file_chunk_count = 0
120
+
121
+ stat.then @start_transmit, @transmit_failure
122
+
123
+ @sending_file.promise.finally &method(:clean_up_send)
124
+ end
125
+
105
126
 
106
127
  private
107
128
 
108
129
 
130
+ ##
131
+ # File transmit functions -------------
132
+ def start_transmit(stats)
133
+ @file_stream_total = stats[:st_size]
134
+ next_chunk
135
+ end
136
+
137
+ def transmit_data(data)
138
+ @file_chunk_count += 1
139
+ if @file_stream_type == :http
140
+ resp = ''
141
+ resp << data.bytesize.to_s(16) << CRLF
142
+ resp << data
143
+ resp << CRLF
144
+ data = resp
145
+ end
146
+ @file_stream.write(data).then @next_chunk, @transmit_failure
147
+ nil
148
+ end
149
+
150
+ def next_chunk(*args)
151
+ next_size = @file_chunk_size
152
+ next_offset = @file_chunk_size * @file_chunk_count
153
+
154
+ if next_offset >= @file_stream_total
155
+ if @file_stream_type == :http
156
+ @file_stream.write(EOF.dup).then(proc {
157
+ @sending_file.resolve(@file_stream_total)
158
+ }, @transmit_failure)
159
+ else
160
+ @sending_file.resolve(@file_stream_total)
161
+ end
162
+ else
163
+ if next_offset + next_size > @file_stream_total
164
+ next_size = @file_stream_total - next_offset
165
+ end
166
+ read(next_size, next_offset).then(@transmit_data, @transmit_failure)
167
+ end
168
+ nil
169
+ end
170
+
171
+ def transmit_failure(reason)
172
+ @sending_file.reject(reason)
173
+ end
174
+
175
+ def clean_up_send
176
+ @sending_file = nil
177
+ @file_stream = nil
178
+ @file_stream_type = nil
179
+ @file_chunk_size = nil
180
+ @file_chunk_count = nil
181
+ @file_stream_total = nil
182
+ end
183
+ # -------------------------------------
184
+ ##
185
+
186
+
109
187
  def on_open(req)
110
188
  if post_check(req, @defer)
111
189
  @fileno = req[:result]
@@ -6,6 +6,7 @@ module Libuv
6
6
 
7
7
 
8
8
  LOOPS = ThreadSafe::Cache.new
9
+ CRITICAL = Mutex.new
9
10
 
10
11
 
11
12
  module ClassMethods
@@ -13,7 +14,10 @@ module Libuv
13
14
  #
14
15
  # @return [::Libuv::Loop]
15
16
  def default
16
- return @default ||= create(::Libuv::Ext.default_loop)
17
+ return @default unless @default.nil?
18
+ CRITICAL.synchronize {
19
+ return @default ||= create(::Libuv::Ext.default_loop)
20
+ }
17
21
  end
18
22
 
19
23
  # Create new Libuv loop
@@ -47,38 +51,55 @@ module Libuv
47
51
 
48
52
  # Create an async call for scheduling work from other threads
49
53
  @run_queue = Queue.new
50
- @queue_proc = proc do
51
- # ensure we only execute what was required for this tick
52
- length = @run_queue.length
53
- length.times do
54
- begin
55
- run = @run_queue.pop true # pop non-block
56
- run.call
57
- rescue Exception => e
58
- @loop.log :error, :next_tick_cb, e
59
- end
60
- end
61
- end
62
- @process_queue = Async.new(@loop, @queue_proc)
54
+ @process_queue = Async.new @loop, method(:process_queue_cb)
63
55
 
64
56
  # Create a next tick timer
65
- @next_tick = @loop.timer do
66
- @next_tick_scheduled = false
67
- @queue_proc.call
68
- end
57
+ @next_tick = @loop.timer method(:next_tick_cb)
69
58
 
70
59
  # Create an async call for ending the loop
71
- @stop_loop = Async.new @loop do
72
- LOOPS.delete(@reactor_thread)
73
- @reactor_thread = nil
74
- @process_queue.close
75
- @stop_loop.close
76
- @next_tick.close
77
-
78
- ::Libuv::Ext.stop(@pointer)
60
+ @stop_loop = Async.new @loop, method(:stop_cb)
61
+ end
62
+
63
+
64
+ protected
65
+
66
+
67
+ def stop_cb
68
+ LOOPS.delete(@reactor_thread)
69
+ @reactor_thread = nil
70
+ @process_queue.close
71
+ @stop_loop.close
72
+ @next_tick.close
73
+
74
+ ::Libuv::Ext.stop(@pointer)
75
+ end
76
+
77
+ def next_tick_cb
78
+ @next_tick_scheduled = false
79
+ process_queue_cb
80
+ end
81
+
82
+ def process_queue_cb
83
+ # ensure we only execute what was required for this tick
84
+ length = @run_queue.length
85
+ length.times do
86
+ process_item
87
+ end
88
+ end
89
+
90
+ def process_item
91
+ begin
92
+ run = @run_queue.pop true # pop non-block
93
+ run.call
94
+ rescue Exception => e
95
+ @loop.log :error, :next_tick_cb, e
79
96
  end
80
97
  end
81
98
 
99
+
100
+ public
101
+
102
+
82
103
  def handle; @pointer; end
83
104
 
84
105
  # Run the actual event loop. This method will block until the loop is stopped.
@@ -106,6 +127,13 @@ module Libuv
106
127
  end
107
128
 
108
129
 
130
+ # Provides a promise notifier for receiving un-handled exceptions
131
+ #
132
+ # @return [::Libuv::Q::Promise]
133
+ def notifier
134
+ @loop_notify.promise
135
+ end
136
+
109
137
  # Creates a deferred result object for where the result of an operation may only be returned
110
138
  # at some point in the future or is being processed on a different thread (thread safe)
111
139
  #
@@ -19,11 +19,14 @@ module Libuv
19
19
  if post_check(req, @stat_deferred)
20
20
  uv_stat = req[:stat]
21
21
  uv_members = uv_stat.members
22
- values = UvStat.members.map { |k| uv_members.include?(k) ? uv_stat[k] : nil }
23
- uv_stat = UvStat.new(*values)
22
+
23
+ stats = {}
24
+ uv_members.each do |key|
25
+ stats[key] = uv_stat[key]
26
+ end
24
27
 
25
28
  cleanup(req)
26
- @stat_deferred.resolve(uv_stat)
29
+ @stat_deferred.resolve(stats)
27
30
  end
28
31
  @stat_deferred = nil
29
32
  end
@@ -1,3 +1,3 @@
1
1
  module Libuv
2
- VERSION = '0.11.5'
2
+ VERSION = '0.11.7'
3
3
  end
@@ -54,7 +54,7 @@ describe Libuv::Async do
54
54
  end
55
55
  }
56
56
 
57
- @general_failure.should == []
58
- (@count < 7 && @count > 3).should == true
57
+ expect(@general_failure).to eq([])
58
+ expect(@count < 7 && @count > 3).to eq(true)
59
59
  end
60
60
  end
@@ -5,6 +5,6 @@ describe ::Libuv do
5
5
  it "Should return the number of CPU cores on the platform" do
6
6
  count = Libuv.cpu_count
7
7
 
8
- (count != nil && count > 0).should == true
8
+ expect(count != nil && count > 0).to eq(true)
9
9
  end
10
10
  end
@@ -30,7 +30,7 @@ describe Libuv::Q do
30
30
  end
31
31
  }
32
32
 
33
- @log.should == [:foo]
33
+ expect(@log).to eq([:foo])
34
34
  end
35
35
 
36
36
 
@@ -52,7 +52,7 @@ describe Libuv::Q do
52
52
  end
53
53
  end
54
54
  }
55
- @log.should == [:foo, :foo]
55
+ expect(@log).to eq([:foo, :foo])
56
56
  end
57
57
 
58
58
 
@@ -73,7 +73,7 @@ describe Libuv::Q do
73
73
  @loop.stop
74
74
  end
75
75
  }
76
- @log.should == [:first, :second]
76
+ expect(@log).to eq([:first, :second])
77
77
  end
78
78
 
79
79
 
@@ -81,7 +81,7 @@ describe Libuv::Q do
81
81
  @loop.run {
82
82
  @promise.then nil, @default_fail do |result|
83
83
  @log << result
84
- @log.should == [:foo]
84
+ expect(@log).to eq([:foo])
85
85
  @deferred.resolve(:bar)
86
86
  end
87
87
 
@@ -101,7 +101,7 @@ describe Libuv::Q do
101
101
  end
102
102
  end
103
103
  }
104
- @log.should == [:foo]
104
+ expect(@log).to eq([:foo])
105
105
  end
106
106
 
107
107
 
@@ -116,7 +116,7 @@ describe Libuv::Q do
116
116
  @deferred.resolve(deferred2.promise)
117
117
  deferred2.resolve(:foo)
118
118
  }
119
- @log.should == [:foo]
119
+ expect(@log).to eq([:foo])
120
120
  end
121
121
 
122
122
 
@@ -138,7 +138,7 @@ describe Libuv::Q do
138
138
  end
139
139
  }
140
140
 
141
- @log.should == [:outer, :inner]
141
+ expect(@log).to eq([:outer, :inner])
142
142
  end
143
143
 
144
144
 
@@ -158,7 +158,7 @@ describe Libuv::Q do
158
158
  end
159
159
  }
160
160
 
161
- @log.should == ['Hello Robin Hood', 'Hello Robin Hood?']
161
+ expect(@log).to eq(['Hello Robin Hood', 'Hello Robin Hood?'])
162
162
  end
163
163
 
164
164
  end
@@ -181,7 +181,7 @@ describe Libuv::Q do
181
181
  @loop.stop
182
182
  end
183
183
  }
184
- @log.should == [:first, :second]
184
+ expect(@log).to eq([:first, :second])
185
185
  end
186
186
 
187
187
 
@@ -208,7 +208,7 @@ describe Libuv::Q do
208
208
  end
209
209
  end
210
210
  }
211
- @log.should == [:baz]
211
+ expect(@log).to eq([:baz])
212
212
  end
213
213
 
214
214
 
@@ -224,7 +224,7 @@ describe Libuv::Q do
224
224
  end
225
225
  }
226
226
 
227
- @log.should == [true]
227
+ expect(@log).to eq([true])
228
228
  end
229
229
 
230
230
  end
@@ -248,7 +248,7 @@ describe Libuv::Q do
248
248
  end
249
249
  }
250
250
 
251
- @log.should == [:first, :second]
251
+ expect(@log).to eq([:first, :second])
252
252
  end
253
253
 
254
254
  it "should do nothing if a promise was previously resolved" do
@@ -276,7 +276,7 @@ describe Libuv::Q do
276
276
  end
277
277
  }
278
278
 
279
- @log.should == []
279
+ expect(@log).to eq([])
280
280
  end
281
281
 
282
282
  it "should do nothing if a promise was previously rejected" do
@@ -304,7 +304,7 @@ describe Libuv::Q do
304
304
  end
305
305
  }
306
306
 
307
- @log.should == []
307
+ expect(@log).to eq([])
308
308
  end
309
309
 
310
310
 
@@ -322,7 +322,7 @@ describe Libuv::Q do
322
322
  end
323
323
  }
324
324
 
325
- @log.should == [true]
325
+ expect(@log).to eq([true])
326
326
  end
327
327
 
328
328
 
@@ -342,7 +342,7 @@ describe Libuv::Q do
342
342
  @loop.stop # Stop will run through the next tick before stopping
343
343
  }
344
344
 
345
- @log.should == [0, :first, :second]
345
+ expect(@log).to eq([0, :first, :second])
346
346
  end
347
347
 
348
348
  it "should ignore notifications sent out in the same turn before listener registration" do
@@ -362,7 +362,7 @@ describe Libuv::Q do
362
362
  end
363
363
  }
364
364
 
365
- @log.should == []
365
+ expect(@log).to eq([])
366
366
  end
367
367
  end
368
368
 
@@ -384,7 +384,7 @@ describe Libuv::Q do
384
384
  end
385
385
  }
386
386
 
387
- @log.should == [:foo]
387
+ expect(@log).to eq([:foo])
388
388
  end
389
389
 
390
390
 
@@ -401,7 +401,7 @@ describe Libuv::Q do
401
401
  end
402
402
  }
403
403
 
404
- @log.should == []
404
+ expect(@log).to eq([])
405
405
  end
406
406
 
407
407
 
@@ -418,7 +418,7 @@ describe Libuv::Q do
418
418
  end
419
419
  }
420
420
 
421
- @log.should == [:foo]
421
+ expect(@log).to eq([:foo])
422
422
  end
423
423
 
424
424
 
@@ -435,7 +435,7 @@ describe Libuv::Q do
435
435
  end
436
436
  }
437
437
 
438
- @log.should == []
438
+ expect(@log).to eq([])
439
439
  end
440
440
 
441
441
 
@@ -465,7 +465,7 @@ describe Libuv::Q do
465
465
  end
466
466
  }
467
467
 
468
- @log.should == [:foo, :foo, :foo, :foo]
468
+ expect(@log).to eq([:foo, :foo, :foo, :foo])
469
469
  end
470
470
 
471
471
 
@@ -504,7 +504,7 @@ describe Libuv::Q do
504
504
  end
505
505
  }
506
506
 
507
- @log.should == [:foo, :foo, :foo, :foo]
507
+ expect(@log).to eq([:foo, :foo, :foo, :foo])
508
508
  end
509
509
 
510
510
 
@@ -534,7 +534,7 @@ describe Libuv::Q do
534
534
  end
535
535
  }
536
536
 
537
- @log.should == [:foo, :foo, :foo, :foo]
537
+ expect(@log).to eq([:foo, :foo, :foo, :foo])
538
538
  end
539
539
 
540
540
 
@@ -573,7 +573,7 @@ describe Libuv::Q do
573
573
  end
574
574
  }
575
575
 
576
- @log.should == [:foo, :bar, 'baz', 'bob', :done]
576
+ expect(@log).to eq([:foo, :bar, 'baz', 'bob', :done])
577
577
  end
578
578
 
579
579
 
@@ -619,7 +619,7 @@ describe Libuv::Q do
619
619
  end
620
620
  }
621
621
 
622
- @log.should == [:foo, :bar, :bar, :bar, :done]
622
+ expect(@log).to eq([:foo, :bar, :bar, :bar, :done])
623
623
  end
624
624
 
625
625
 
@@ -664,7 +664,7 @@ describe Libuv::Q do
664
664
  end
665
665
  }
666
666
 
667
- @log.should == [:foo, :bar, :q_progress_cb]
667
+ expect(@log).to eq([:foo, :bar, :q_progress_cb])
668
668
  end
669
669
 
670
670
 
@@ -681,7 +681,7 @@ describe Libuv::Q do
681
681
  end
682
682
  }
683
683
 
684
- @log.should == [:foo]
684
+ expect(@log).to eq([:foo])
685
685
  end
686
686
 
687
687
 
@@ -705,7 +705,7 @@ describe Libuv::Q do
705
705
  end
706
706
  }
707
707
 
708
- @log.should == [:finally]
708
+ expect(@log).to eq([:finally])
709
709
  end
710
710
 
711
711
  it "should fulfill with the original value" do
@@ -727,7 +727,7 @@ describe Libuv::Q do
727
727
  end
728
728
  }
729
729
 
730
- @log.should == [:finally, :foo]
730
+ expect(@log).to eq([:finally, :foo])
731
731
  end
732
732
 
733
733
  it "should fulfill with the original value (larger test)" do
@@ -775,7 +775,7 @@ describe Libuv::Q do
775
775
  end
776
776
  }
777
777
 
778
- @log.should == [:foo, :finally, :foo, :change, :finally, :change]
778
+ expect(@log).to eq([:foo, :finally, :foo, :change, :finally, :change])
779
779
  end
780
780
 
781
781
  describe "when the callback throws an exception" do
@@ -797,7 +797,7 @@ describe Libuv::Q do
797
797
  end
798
798
  }
799
799
 
800
- @log.should == [:finally, true]
800
+ expect(@log).to eq([:finally, true])
801
801
  end
802
802
  end
803
803
 
@@ -832,7 +832,7 @@ describe Libuv::Q do
832
832
  end
833
833
  }
834
834
 
835
- @log.should == [:finally, :resolving, :foo]
835
+ expect(@log).to eq([:finally, :resolving, :foo])
836
836
  end
837
837
 
838
838
 
@@ -866,7 +866,7 @@ describe Libuv::Q do
866
866
  end
867
867
  }
868
868
 
869
- @log.should == [:finally, :rejecting, :rejected]
869
+ expect(@log).to eq([:finally, :rejecting, :rejected])
870
870
  end
871
871
  end
872
872
 
@@ -895,7 +895,7 @@ describe Libuv::Q do
895
895
  end
896
896
  }
897
897
 
898
- @log.should == ['not gonna happen']
898
+ expect(@log).to eq(['not gonna happen'])
899
899
  end
900
900
 
901
901
 
@@ -916,7 +916,7 @@ describe Libuv::Q do
916
916
  end
917
917
  }
918
918
 
919
- @log.should == ['not gonna happen']
919
+ expect(@log).to eq(['not gonna happen'])
920
920
  end
921
921
 
922
922
  end
@@ -936,7 +936,7 @@ describe Libuv::Q do
936
936
  end
937
937
  }
938
938
 
939
- @log.should == [[]]
939
+ expect(@log).to eq([[]])
940
940
  end
941
941
 
942
942
  it "should take an array of promises and return a promise for an array of results" do
@@ -954,7 +954,7 @@ describe Libuv::Q do
954
954
  @loop.work { deferred1.resolve(:bar) }
955
955
  }
956
956
 
957
- @log.should == [:foo, :bar, :baz]
957
+ expect(@log).to eq([:foo, :bar, :baz])
958
958
  end
959
959
 
960
960
 
@@ -972,7 +972,7 @@ describe Libuv::Q do
972
972
  @loop.work { deferred2.reject(:baz) }
973
973
  }
974
974
 
975
- @log.should == [:baz]
975
+ expect(@log).to eq([:baz])
976
976
  end
977
977
 
978
978
  end
@@ -38,8 +38,8 @@ describe Libuv::Dns do
38
38
  }
39
39
  }
40
40
 
41
- @general_failure.should == []
42
- @result.should == '127.0.0.1'
41
+ expect(@general_failure).to eq([])
42
+ expect(@result).to eq('127.0.0.1')
43
43
  end
44
44
 
45
45
  it "should resolve localhost using IP6", :network => true do
@@ -61,8 +61,8 @@ describe Libuv::Dns do
61
61
  }
62
62
  }
63
63
 
64
- @general_failure.should == []
65
- @result.should == '::1'
64
+ expect(@general_failure).to eq([])
65
+ expect(@result).to eq('::1')
66
66
  end
67
67
 
68
68
  it "should resolve loop back" do
@@ -84,7 +84,7 @@ describe Libuv::Dns do
84
84
  }
85
85
  }
86
86
 
87
- @general_failure.should == []
88
- @result.should == '127.0.0.1'
87
+ expect(@general_failure).to eq([])
88
+ expect(@result).to eq('127.0.0.1')
89
89
  end
90
90
  end
@@ -48,8 +48,8 @@ describe Libuv::Filesystem do
48
48
  end
49
49
  }
50
50
 
51
- @general_failure.should == []
52
- (@log.length > 0).should == true
51
+ expect(@general_failure).to eq([])
52
+ expect((@log.length > 0)).to eq(true)
53
53
  end
54
54
  end
55
55
 
@@ -75,8 +75,8 @@ describe Libuv::Filesystem do
75
75
  end
76
76
  }
77
77
 
78
- @general_failure.should == []
79
- @log.should == :success
78
+ expect(@general_failure).to eq([])
79
+ expect(@log).to eq(:success)
80
80
  end
81
81
 
82
82
  it "should read from a file" do
@@ -98,8 +98,8 @@ describe Libuv::Filesystem do
98
98
  end
99
99
  }
100
100
 
101
- @general_failure.should == []
102
- @log.should == 'write some data to a file'
101
+ expect(@general_failure).to eq([])
102
+ expect(@log).to eq('write some data to a file')
103
103
  end
104
104
 
105
105
  it "should delete a file" do
@@ -117,8 +117,134 @@ describe Libuv::Filesystem do
117
117
  end
118
118
  }
119
119
 
120
- @general_failure.should == []
121
- @log.should == :success
120
+ expect(@general_failure).to eq([])
121
+ expect(@log).to eq(:success)
122
+ end
123
+ end
124
+
125
+ describe 'file streaming' do
126
+ it "should send a file over a stream", :network => true do
127
+ @loop.run { |logger|
128
+ logger.progress &@logger
129
+
130
+ @server = @loop.tcp
131
+ @client = @loop.tcp
132
+
133
+ @server.bind('127.0.0.1', 34570) do |server|
134
+ server.accept do |client|
135
+ client.progress do |data|
136
+ file = @loop.file('.rspec', File::RDONLY)
137
+ file.progress do
138
+ file.send_file(client).then(proc {
139
+ file.close
140
+ client.close
141
+ }, proc { |error|
142
+ @general_failure << error
143
+ })
144
+ end
145
+ file.catch do |error|
146
+ @general_failure << error.inspect
147
+ file.close
148
+ client.close
149
+ end
150
+ end
151
+ client.start_read
152
+ client.finally do
153
+ @server.close
154
+ @loop.stop
155
+ end
156
+ end
157
+ end
158
+ # catch errors
159
+ @server.catch do |reason|
160
+ @general_failure << reason.inspect
161
+ @loop.stop
162
+ end
163
+ # start listening
164
+ @server.listen(5)
165
+
166
+
167
+ # connect client to server
168
+ @client.connect('127.0.0.1', 34570) do |client|
169
+ client.progress do |data|
170
+ @log << data
171
+ end
172
+
173
+ @client.start_read
174
+ @client.write('send file')
175
+ end
176
+ # catch errors
177
+ @client.catch do |reason|
178
+ @general_failure << reason.inspect
179
+ @server.close
180
+ @loop.stop
181
+ end
182
+ }
183
+
184
+ expect(@general_failure).to eq([])
185
+ expect(@log).to eq(["--format progress\n"])
186
+ end
187
+
188
+ it "should send a file as a HTTP chunked response", :network => true do
189
+ @loop.run { |logger|
190
+ logger.progress &@logger
191
+
192
+ @server = @loop.tcp
193
+ @client = @loop.tcp
194
+
195
+ @server.bind('127.0.0.1', 34568) do |server|
196
+ server.accept do |client|
197
+ client.progress do |data|
198
+ file = @loop.file('.rspec', File::RDONLY)
199
+ file.progress do
200
+ file.send_file(client, :http).then(proc {
201
+ file.close
202
+ client.close
203
+ }, proc { |error|
204
+ @general_failure << error
205
+ })
206
+ end
207
+ file.catch do |error|
208
+ @general_failure << error.inspect
209
+ file.close
210
+ client.close
211
+ end
212
+ end
213
+ client.start_read
214
+ client.finally do
215
+ @server.close
216
+ @loop.stop
217
+ end
218
+ end
219
+ end
220
+ # catch errors
221
+ @server.catch do |reason|
222
+ @general_failure << reason.inspect
223
+ @loop.stop
224
+ end
225
+ # start listening
226
+ @server.listen(5)
227
+
228
+
229
+ # connect client to server
230
+ @client.connect('127.0.0.1', 34568) do |client|
231
+ client.progress do |data|
232
+ @log << data
233
+ end
234
+
235
+ @client.start_read
236
+ @client.write('send file')
237
+ end
238
+ # catch errors
239
+ @client.catch do |reason|
240
+ @general_failure << reason.inspect
241
+ @server.close
242
+ @loop.stop
243
+ end
244
+ }
245
+
246
+ expect(@general_failure).to eq([])
247
+ expect(@log).to eq(["12\r\n--format progress\n\r\n", "0\r\n\r\n"])
122
248
  end
123
249
  end
124
250
  end
@@ -50,7 +50,7 @@ describe Libuv::Idle do
50
50
  stopper.start(1000, 0)
51
51
  }
52
52
 
53
- @general_failure.should == []
54
- (@idle_calls > 0).should == true
53
+ expect(@general_failure).to eq([])
54
+ expect((@idle_calls > 0)).to eq(true)
55
55
  end
56
56
  end
@@ -96,8 +96,8 @@ describe Libuv::Pipe do
96
96
  end
97
97
  }
98
98
 
99
- @general_failure.should == []
100
- @log.should == ['ping', 'pong']
99
+ expect(@general_failure).to eq([])
100
+ expect(@log).to eq(['ping', 'pong'])
101
101
  end
102
102
  end
103
103
 
@@ -153,8 +153,8 @@ describe Libuv::Pipe do
153
153
  timeout.start(1000)
154
154
  }
155
155
 
156
- @general_failure.should == []
157
- @log.should == 'workload'
156
+ expect(@general_failure).to eq([])
157
+ expect(@log).to eq('workload')
158
158
  end
159
159
  end
160
160
  end
@@ -87,8 +87,8 @@ describe Libuv::TCP do
87
87
  end
88
88
  }
89
89
 
90
- @general_failure.should == []
91
- @log.should == ['ping', 'pong']
90
+ expect(@general_failure).to eq([])
91
+ expect(@log).to eq(['ping', 'pong'])
92
92
  end
93
93
  end
94
94
 
@@ -196,8 +196,8 @@ describe Libuv::TCP do
196
196
  end
197
197
  }
198
198
 
199
- @general_failure.should == []
200
- @log.should == ['ping', 'pong']
199
+ expect(@general_failure).to eq([])
200
+ expect(@log).to eq(['ping', 'pong'])
201
201
  end
202
202
 
203
203
  describe 'basic TLS client and server' do
@@ -259,8 +259,8 @@ describe Libuv::TCP do
259
259
  end
260
260
  }
261
261
 
262
- @general_failure.should == []
263
- @log.should == ['ping', 'pong']
262
+ expect(@general_failure).to eq([])
263
+ expect(@log).to eq(['ping', 'pong'])
264
264
  end
265
265
  end
266
266
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libuv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.5
4
+ version: 0.11.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bulat Shakirzyanov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-02 00:00:00.000000000 Z
12
+ date: 2013-12-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -186,6 +186,7 @@ files:
186
186
  - ext/libuv/include/uv-unix.h
187
187
  - ext/libuv/include/uv-win.h
188
188
  - ext/libuv/include/uv.h
189
+ - ext/libuv/libuv.pc.in
189
190
  - ext/libuv/m4/.gitignore
190
191
  - ext/libuv/m4/dtrace.m4
191
192
  - ext/libuv/samples/.gitignore
@@ -334,12 +335,15 @@ files:
334
335
  - ext/libuv/test/test-getsockname.c
335
336
  - ext/libuv/test/test-hrtime.c
336
337
  - ext/libuv/test/test-idle.c
338
+ - ext/libuv/test/test-ip4-addr.c
337
339
  - ext/libuv/test/test-ip6-addr.c
338
340
  - ext/libuv/test/test-ipc-send-recv.c
339
341
  - ext/libuv/test/test-ipc.c
340
342
  - ext/libuv/test/test-list.h
343
+ - ext/libuv/test/test-loop-alive.c
341
344
  - ext/libuv/test/test-loop-handles.c
342
345
  - ext/libuv/test/test-loop-stop.c
346
+ - ext/libuv/test/test-loop-time.c
343
347
  - ext/libuv/test/test-multiple-listen.c
344
348
  - ext/libuv/test/test-mutexes.c
345
349
  - ext/libuv/test/test-osx-select.c
@@ -347,6 +351,7 @@ files:
347
351
  - ext/libuv/test/test-ping-pong.c
348
352
  - ext/libuv/test/test-pipe-bind-error.c
349
353
  - ext/libuv/test/test-pipe-connect-error.c
354
+ - ext/libuv/test/test-pipe-server-close.c
350
355
  - ext/libuv/test/test-platform-output.c
351
356
  - ext/libuv/test/test-poll-close.c
352
357
  - ext/libuv/test/test-poll.c
@@ -374,6 +379,7 @@ files:
374
379
  - ext/libuv/test/test-tcp-open.c
375
380
  - ext/libuv/test/test-tcp-read-stop.c
376
381
  - ext/libuv/test/test-tcp-shutdown-after-write.c
382
+ - ext/libuv/test/test-tcp-try-write.c
377
383
  - ext/libuv/test/test-tcp-unexpected-read.c
378
384
  - ext/libuv/test/test-tcp-write-to-half-open-connection.c
379
385
  - ext/libuv/test/test-tcp-writealot.c