async-io 1.2.0 → 1.2.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: 5debc255f53c70939e2e84ebe18178b1b9fe73db
4
- data.tar.gz: c0b4a2a8b43454b97317c3dd46476cacb8dcf010
3
+ metadata.gz: c21728ab9008e3a380403814866827866f69cfa5
4
+ data.tar.gz: 9459dcb16dc458acf1724865b12a53dccf548dc5
5
5
  SHA512:
6
- metadata.gz: da03e21632e9889d111919b083572c5eba488358ca3c3379e23b0ed6d487c4c1d8b2a9846766b0f047bb5e00aba23fea5ebe6ee3d720f651c234d0addd72b3cb
7
- data.tar.gz: 6ddcdb0d5bd129818a9cb638510b9008ab55488d9439ec1c43493cae09727e79fadf6ada416ae386a560fc6527351f99d3fb66c00f0e2c942b45556afc8d73be
6
+ metadata.gz: 60deebccccfc2885880c6a226b8f7637ec1234894efc92cc125e04778555a65f69e4dac73547c0e11de360c575830258fb32093353109bd08fe6cc351d404b6d
7
+ data.tar.gz: 43de7fec9b8046f1b6fbb7be981671879d2f2ad7479d791a651b1aad82301edb834a64de0d7d66e4059f8111f2bc8b899970ff8f17c26da55e00806f04546fcb
@@ -24,11 +24,3 @@ require_relative "io/generic"
24
24
  require_relative "io/socket"
25
25
  require_relative "io/endpoint"
26
26
  require_relative "io/version"
27
-
28
- module Async
29
- module IO
30
- def self.try_convert(io)
31
- Generic::WRAPPERS[io.class].wrap(io)
32
- end
33
- end
34
- end
@@ -61,8 +61,12 @@ module Async
61
61
  yield self.send(*specification)
62
62
  elsif specification.is_a? String
63
63
  yield self.parse(specification)
64
+ elsif specification.is_a? ::BasicSocket
65
+ yield SocketEndpoint.new(specification)
66
+ elsif specification.is_a? Generic
67
+ yield Endpoint.new(specification)
64
68
  else
65
- yield self.new(specification)
69
+ raise ArgumentError.new("Not sure how to convert #{specification} to endpoint!")
66
70
  end
67
71
  end
68
72
  end
@@ -72,6 +76,10 @@ module Async
72
76
  super(specification, options)
73
77
  end
74
78
 
79
+ def address
80
+ specification.local_address
81
+ end
82
+
75
83
  def to_sockaddr
76
84
  address.to_sockaddr
77
85
  end
@@ -94,9 +102,9 @@ module Async
94
102
  address.protocol
95
103
  end
96
104
 
97
- # def bind
98
- # yield specification
99
- # end
105
+ def bind
106
+ yield specification
107
+ end
100
108
 
101
109
  def accept(&block)
102
110
  backlog = self.options.fetch(:backlog, Socket::SOMAXCONN)
@@ -107,9 +115,9 @@ module Async
107
115
  end
108
116
  end
109
117
 
110
- # def connect
111
- # yield specification
112
- # end
118
+ def connect
119
+ yield specification
120
+ end
113
121
  end
114
122
 
115
123
  # This class will open and close the socket automatically.
@@ -127,14 +135,14 @@ module Async
127
135
  end
128
136
  end
129
137
 
130
- # This class doesn't exert ownership over the specified socket.
138
+ # This class doesn't exert ownership over the specified socket, wraps a native ::IO.
131
139
  class SocketEndpoint < Endpoint
132
140
  def address
133
141
  specification.local_address
134
142
  end
135
143
 
136
144
  def bind(&block)
137
- yield Socket.new(specification, **options)
145
+ yield Socket.new(specification)
138
146
  end
139
147
 
140
148
  def connect(&block)
@@ -23,6 +23,11 @@ require 'forwardable'
23
23
 
24
24
  module Async
25
25
  module IO
26
+ # Convert a Ruby ::IO object to a wrapped instance:
27
+ def self.try_convert(io, &block)
28
+ Generic::WRAPPERS[io.class].wrap(io, &block)
29
+ end
30
+
26
31
  # Represents an asynchronous IO within a reactor.
27
32
  class Generic < Wrapper
28
33
  extend Forwardable
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module IO
23
- VERSION = "1.2.0"
23
+ VERSION = "1.2.1"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-io
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-03 00:00:00.000000000 Z
11
+ date: 2018-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async