celluloid-io 0.15.0 → 0.16.0.pre

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: 7054267bfa2e212426bcac0f1c76f3f33e36c9f6
4
- data.tar.gz: eac6073ef151b759661a56ddaffc46238099220b
3
+ metadata.gz: 8ef8df712ab13d7a2adca88bc42781b256074996
4
+ data.tar.gz: edb9143049e62e5484f17ea870539a55af137ec7
5
5
  SHA512:
6
- metadata.gz: c24b46c7b0463ae27d31f464c3c21f48630591062470170fc1c11b30cc6728fab0946ef828fb1ec9b3547fac5280e338c6e77e7f3286eff67dcf3afeb25986a9
7
- data.tar.gz: 92d995f93dc0368a278c803c52d08e4c399624b83a56a654b240b76771b186ecbee54c4a92a0d5038648ecf9f1ff6926faa063a07abce3392e756e505492c68d
6
+ metadata.gz: f5965bae29ff210224fd7293f22a209e8582bd2c25bc2abbd83753609d473b90b910bc23b965ae5f945851898e113ae06bf31112f6525a3742e1ff3655ac7b40
7
+ data.tar.gz: 93eee2a93b600f5e5a9851e6678c22049dd5dc2b844440bb68fb6ade354287158e6aeba5e78b136317856ac83b162fe195b65ea2c9da57d56b4f2c2721838b26
data/.travis.yml CHANGED
@@ -2,16 +2,18 @@ script: rake ci
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
+ - 2.1.0
5
6
  - ruby-head
6
- - jruby-19mode
7
- - rbx-19mode
7
+ - jruby
8
8
  - jruby-head
9
+ - rbx
9
10
 
10
11
  matrix:
11
12
  allow_failures:
12
13
  - rvm: ruby-head
14
+ - rvm: jruby
13
15
  - rvm: jruby-head
14
- - rvm: rbx-19mode
16
+ - rvm: rbx
15
17
 
16
18
  notifications:
17
19
  irc: "irc.freenode.org#celluloid"
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ HEAD
2
+ ----
3
+ * Celluloid::IO.copy_stream support (uses a background thread)
4
+
1
5
  0.15.0 (2013-09-04)
2
6
  -------------------
3
7
  * Improved DNS resolver with less NIH and more Ruby stdlib goodness
data/celluloid-io.gemspec CHANGED
@@ -16,8 +16,8 @@ Gem::Specification.new do |gem|
16
16
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
17
  gem.require_paths = ["lib"]
18
18
 
19
- gem.add_dependency 'celluloid', '>= 0.15.0'
20
- gem.add_dependency 'nio4r', '>= 0.5.0'
19
+ gem.add_dependency 'celluloid', '>= 0.16.0.pre'
20
+ gem.add_dependency 'nio4r', '>= 1.0.0'
21
21
 
22
22
  gem.add_development_dependency 'rake'
23
23
  gem.add_development_dependency 'rspec'
@@ -16,12 +16,9 @@ module Celluloid
16
16
  # See IO#sync for full details.
17
17
  attr_accessor :sync
18
18
 
19
- # Default size to read from or write to the stream for buffer operations
20
- BLOCK_SIZE = 1024*16
21
-
22
19
  def initialize
23
20
  @eof = false
24
- @sync = true # FIXME: hax
21
+ @sync = true
25
22
  @read_buffer = ''.force_encoding(Encoding::ASCII_8BIT)
26
23
  @write_buffer = ''.force_encoding(Encoding::ASCII_8BIT)
27
24
 
@@ -344,7 +341,6 @@ module Celluloid
344
341
  def do_write(s)
345
342
  @write_buffer << s
346
343
  @write_buffer.force_encoding(Encoding::BINARY)
347
- @sync ||= false
348
344
 
349
345
  if @sync or @write_buffer.size > BLOCK_SIZE or idx = @write_buffer.rindex($/)
350
346
  remain = idx ? idx + $/.size : @write_buffer.length
@@ -3,10 +3,10 @@ module Celluloid
3
3
  # UDPSockets with combined blocking and evented support
4
4
  class UDPSocket
5
5
  extend Forwardable
6
- def_delegators :@socket, :bind, :send, :recvfrom_nonblock, :close, :closed?
6
+ def_delegators :@socket, :bind, :connect, :send, :recvfrom_nonblock, :close, :closed?
7
7
 
8
- def initialize
9
- @socket = ::UDPSocket.new
8
+ def initialize(address_family = ::Socket::AF_INET)
9
+ @socket = ::UDPSocket.new(address_family)
10
10
  end
11
11
 
12
12
  # Wait until the socket is readable
@@ -1,5 +1,5 @@
1
1
  module Celluloid
2
2
  module IO
3
- VERSION = "0.15.0"
3
+ VERSION = "0.16.0.pre"
4
4
  end
5
5
  end
data/lib/celluloid/io.rb CHANGED
@@ -18,6 +18,9 @@ require 'celluloid/io/ssl_socket'
18
18
  module Celluloid
19
19
  # Actors with evented IO support
20
20
  module IO
21
+ # Default size to read from or write to the stream for buffer operations
22
+ BLOCK_SIZE = 1024 * 16
23
+
21
24
  def self.included(klass)
22
25
  klass.send :include, Celluloid
23
26
  klass.mailbox_class Celluloid::IO::Mailbox
@@ -27,6 +30,21 @@ module Celluloid
27
30
  actor = Thread.current[:celluloid_actor]
28
31
  actor && actor.mailbox.is_a?(Celluloid::IO::Mailbox)
29
32
  end
33
+
34
+ def self.try_convert(src)
35
+ ::IO.try_convert(src)
36
+ end
37
+
38
+ def self.copy_stream(src, dst, copy_length = nil, src_offset = nil)
39
+ raise NotImplementedError, "length/offset not supported" if copy_length || src_offset
40
+
41
+ src, dst = try_convert(src), try_convert(dst)
42
+
43
+ # FIXME: this always goes through the reactor, and can block on file I/O
44
+ while data = src.read(BLOCK_SIZE)
45
+ dst << data
46
+ end
47
+ end
30
48
 
31
49
  def wait_readable(io)
32
50
  io = io.to_io
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Celluloid::IO do
4
+ context "copy_stream" do
5
+ let(:host) { "127.0.0.1" }
6
+ let(:port) { 23456 }
7
+
8
+ it "copies streams from Celluloid::IO sockets" do
9
+ server = described_class::TCPServer.new(host, port)
10
+ client = ::TCPSocket.new(host, port)
11
+ peer = server.accept
12
+ expect(peer).to be_a described_class::TCPSocket
13
+
14
+ my_own_bits = File.read(__FILE__)
15
+ file = File.open(__FILE__, 'r')
16
+
17
+ described_class.copy_stream(file, peer)
18
+ expect(client.read(file.stat.size)).to eq my_own_bits
19
+ end
20
+ end
21
+ end
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: celluloid-io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.16.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-04 00:00:00.000000000 Z
11
+ date: 2014-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.15.0
19
+ version: 0.16.0.pre
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.15.0
26
+ version: 0.16.0.pre
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nio4r
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.5.0
33
+ version: 1.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.5.0
40
+ version: 1.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: benchmark_suite
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: guard-rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rb-fsevent
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: 0.9.1
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.9.1
111
111
  description: Evented IO for Celluloid actors
@@ -115,10 +115,10 @@ executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
- - .coveralls.yml
119
- - .gitignore
120
- - .rspec
121
- - .travis.yml
118
+ - ".coveralls.yml"
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".travis.yml"
122
122
  - CHANGES.md
123
123
  - Gemfile
124
124
  - Guardfile
@@ -156,6 +156,7 @@ files:
156
156
  - spec/celluloid/io/udp_socket_spec.rb
157
157
  - spec/celluloid/io/unix_server_spec.rb
158
158
  - spec/celluloid/io/unix_socket_spec.rb
159
+ - spec/celluloid/io_spec.rb
159
160
  - spec/fixtures/client.crt
160
161
  - spec/fixtures/client.key
161
162
  - spec/fixtures/server.crt
@@ -173,17 +174,17 @@ require_paths:
173
174
  - lib
174
175
  required_ruby_version: !ruby/object:Gem::Requirement
175
176
  requirements:
176
- - - '>='
177
+ - - ">="
177
178
  - !ruby/object:Gem::Version
178
179
  version: '0'
179
180
  required_rubygems_version: !ruby/object:Gem::Requirement
180
181
  requirements:
181
- - - '>='
182
+ - - ">"
182
183
  - !ruby/object:Gem::Version
183
- version: '0'
184
+ version: 1.3.1
184
185
  requirements: []
185
186
  rubyforge_project:
186
- rubygems_version: 2.0.3
187
+ rubygems_version: 2.2.0
187
188
  signing_key:
188
189
  specification_version: 4
189
190
  summary: Celluloid::IO allows you to monitor multiple IO objects within a Celluloid
@@ -199,6 +200,7 @@ test_files:
199
200
  - spec/celluloid/io/udp_socket_spec.rb
200
201
  - spec/celluloid/io/unix_server_spec.rb
201
202
  - spec/celluloid/io/unix_socket_spec.rb
203
+ - spec/celluloid/io_spec.rb
202
204
  - spec/fixtures/client.crt
203
205
  - spec/fixtures/client.key
204
206
  - spec/fixtures/server.crt