uv-rays 2.4.0 → 2.4.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: a54cf48a95b6b5741a9fc2b6d7958f31bb95f967
4
- data.tar.gz: 8d03f743d6112dd2de00f60cb62db1735ec3b69e
3
+ metadata.gz: f56a60649d5cb855bd637812369d0750f1d60f40
4
+ data.tar.gz: 4b335f621a8a693f68ccea5d91ae0411a66f7d5c
5
5
  SHA512:
6
- metadata.gz: 7dc9088e375515895366078388804e9853f4e38653ba362861fc8ea5856d6232a8f83fd0070134f5d1e5549dbf3983b31eecf8da6afb4cf95e26a4bc08e53f0c
7
- data.tar.gz: 0ea0dd82810514209115682293d096ceea550e5ebfacc2082dd63a74b9ab204665c962f6ae513dd07f0aa5fe514897af67c0c58438d0f0096608471857164366
6
+ metadata.gz: 1c5fc97e6d88a8ca1b5829862500c2a02bb760941a1d50fe2234b62a6bd922c604d9e921126a7b438b2650f549a855e2fd92435d9a60bdd3a0ddafb7f64d9d05
7
+ data.tar.gz: 58ee15889926060f749fbf13cba99ad12a34e50c62f2d7a3b8a6bdc1b166cf57c3e0fbe1912527896180fe8948024a989099942b11e02179ac0b8ca4620b783c
@@ -74,11 +74,11 @@ module Faraday
74
74
 
75
75
  def perform_request(env, opts)
76
76
  conn = ::UV::HttpEndpoint.new(env[:url].to_s, opts.merge!(@connection_options))
77
- resp = co conn.request(env[:method].to_s.downcase.to_sym,
77
+ resp = conn.request(env[:method].to_s.downcase.to_sym,
78
78
  headers: env[:request_headers],
79
79
  path: "/#{env[:url].to_s.split('/', 4)[-1]}",
80
80
  keepalive: false,
81
- body: read_body(env))
81
+ body: read_body(env)).value
82
82
 
83
83
  save_response(env, resp.status.to_i, resp.body, resp) #, resp.reason_phrase)
84
84
  nil
@@ -63,7 +63,7 @@ class HTTPI::Adapter::Libuv < HTTPI::Adapter::Base
63
63
  end
64
64
 
65
65
  # Use co-routines to make non-blocking requests
66
- response = co @client.request(method, req)
66
+ response = @client.request(method, req).value
67
67
  ::HTTPI::Response.new(response.status, response, response.body)
68
68
  end
69
69
  end
@@ -5,8 +5,8 @@ require 'ipaddress' # IP Address parser
5
5
  module UV
6
6
  def self.try_connect(tcp, handler, server, port)
7
7
  if IPAddress.valid? server
8
- tcp.finally handler.method(:on_close)
9
- tcp.progress handler.method(:on_read)
8
+ tcp.finally { handler.on_close }
9
+ tcp.progress { |*data| handler.on_read(*data) }
10
10
  tcp.connect server, port do
11
11
  tcp.enable_nodelay
12
12
  tcp.start_tls(handler.using_tls) if handler.using_tls
@@ -109,8 +109,8 @@ module UV
109
109
 
110
110
  @reactor = tcp.reactor
111
111
  @transport = tcp
112
- @transport.finally method(:on_close)
113
- @transport.progress method(:on_read)
112
+ @transport.finally { on_close }
113
+ @transport.progress { |*data| on_read(*data) }
114
114
  end
115
115
 
116
116
  def use_tls(args = {})
@@ -164,7 +164,7 @@ module UV
164
164
 
165
165
  @reactor = reactor
166
166
  @transport = @reactor.udp
167
- @transport.progress method(:on_read)
167
+ @transport.progress { |*args| on_read(*args) }
168
168
 
169
169
  if not server.nil?
170
170
  server = '127.0.0.1' if server == 'localhost'
@@ -150,22 +150,22 @@ module UV
150
150
 
151
151
  if body
152
152
  request_header << body
153
- transport.write(request_header).catch @error
153
+ transport.write(request_header).catch &@error
154
154
  elsif file
155
- transport.write(request_header).catch @error
155
+ transport.write(request_header).catch &@error
156
156
 
157
157
  # Send file
158
158
  fileRef = @reactor.file file, File::RDONLY do
159
159
  # File is open and available for reading
160
160
  pSend = fileRef.send_file(transport, using: :raw, wait: :promise)
161
- pSend.catch @error
161
+ pSend.catch &@error
162
162
  pSend.finally do
163
163
  fileRef.close
164
164
  end
165
165
  end
166
- fileRef.catch @error
166
+ fileRef.catch &@error
167
167
  else
168
- transport.write(request_header).catch @error
168
+ transport.write(request_header).catch &@error
169
169
  end
170
170
  end
171
171
 
@@ -177,9 +177,7 @@ module UV
177
177
  @headers_callback.call(head) if @headers_callback
178
178
  end
179
179
 
180
-
181
-
182
- def on_headers(callback, &blk)
180
+ def on_headers(&callback)
183
181
  @headers_callback = callback
184
182
  end
185
183
 
@@ -182,7 +182,6 @@ module UV
182
182
  @scheduled = []
183
183
  @next = nil # Next schedule time
184
184
  @timer = nil # Reference to the timer
185
- @timer_callback = method(:on_timer)
186
185
 
187
186
  # Not really required when used correctly
188
187
  @critical = Mutex.new
@@ -211,14 +210,10 @@ module UV
211
210
  # @param time [String] a human readable string representing the time period. 3w2d4h1m2s for example.
212
211
  # @param callback [Proc] a block or method to execute when the event triggers
213
212
  # @return [::UV::Repeat]
214
- def every(time, callback = nil, &block)
215
- callback ||= block
213
+ def every(time)
216
214
  ms = Scheduler.parse_in(time)
217
215
  event = Repeat.new(self, ms)
218
-
219
- if callback.respond_to? :call
220
- event.progress callback
221
- end
216
+ event.progress &Proc.new if block_given?
222
217
  schedule(event)
223
218
  event
224
219
  end
@@ -228,14 +223,10 @@ module UV
228
223
  # @param time [String] a human readable string representing the time period. 3w2d4h1m2s for example.
229
224
  # @param callback [Proc] a block or method to execute when the event triggers
230
225
  # @return [::UV::OneShot]
231
- def in(time, callback = nil, &block)
232
- callback ||= block
226
+ def in(time)
233
227
  ms = @reactor.now + Scheduler.parse_in(time)
234
228
  event = OneShot.new(self, ms)
235
-
236
- if callback.respond_to? :call
237
- event.progress callback
238
- end
229
+ event.progress &Proc.new if block_given?
239
230
  schedule(event)
240
231
  event
241
232
  end
@@ -245,14 +236,10 @@ module UV
245
236
  # @param time [String, Time] a representation of a date and time that can be parsed
246
237
  # @param callback [Proc] a block or method to execute when the event triggers
247
238
  # @return [::UV::OneShot]
248
- def at(time, callback = nil, &block)
249
- callback ||= block
239
+ def at(time)
250
240
  ms = Scheduler.parse_at(time) - @time_diff
251
241
  event = OneShot.new(self, ms)
252
-
253
- if callback.respond_to? :call
254
- event.progress callback
255
- end
242
+ event.progress &Proc.new if block_given?
256
243
  schedule(event)
257
244
  event
258
245
  end
@@ -262,14 +249,10 @@ module UV
262
249
  # @param schedule [String] a standard CRON job line.
263
250
  # @param callback [Proc] a block or method to execute when the event triggers
264
251
  # @return [::UV::Repeat]
265
- def cron(schedule, callback = nil, timezone: nil, &block)
266
- callback ||= block
252
+ def cron(schedule, timezone: nil)
267
253
  ms = Scheduler.parse_cron(schedule, timezone: timezone)
268
254
  event = Repeat.new(self, ms)
269
-
270
- if callback.respond_to? :call
271
- event.progress callback
272
- end
255
+ event.progress &Proc.new if block_given?
273
256
  schedule(event)
274
257
  event
275
258
  end
@@ -391,7 +374,7 @@ module UV
391
374
 
392
375
  # Provide some assurances on timer failure
393
376
  def new_timer
394
- @timer = @reactor.timer @timer_callback
377
+ @timer = @reactor.timer { on_timer }
395
378
  @timer.finally do
396
379
  new_timer
397
380
  unless @next.nil?
@@ -18,7 +18,7 @@ module UV
18
18
  server = '127.0.0.1' if server == 'localhost'
19
19
  if IPAddress.valid? server
20
20
  @server = server
21
- bind(server, port, method(:new_connection))
21
+ bind(server, port) { |client| new_connection(client) }
22
22
  listen(1024)
23
23
  else
24
24
  raise ArgumentError, "Invalid server address #{server}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UV
4
- VERSION = '2.4.0'
4
+ VERSION = '2.4.1'
5
5
  end
@@ -257,7 +257,7 @@ describe UV::HttpEndpoint do
257
257
  objs = WeakRef.new(server)
258
258
 
259
259
  request = server.get(:path => '/whatwhat')
260
- request.catch(@request_failure)
260
+ request.catch(&@request_failure)
261
261
  request.finally {
262
262
  tcp.close
263
263
  @timeout.stop
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uv-rays
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen von Takach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-27 00:00:00.000000000 Z
11
+ date: 2017-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libuv