linda-socket.io-client 0.0.1
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 +7 -0
- data/.gitignore +23 -0
- data/.travis.yml +9 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +37 -0
- data/History.txt +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +59 -0
- data/Rakefile +8 -0
- data/lib/linda-socket.io-client/client.rb +91 -0
- data/lib/linda-socket.io-client/error.rb +8 -0
- data/lib/linda-socket.io-client/version.rb +7 -0
- data/lib/linda-socket.io-client.rb +14 -0
- data/linda-socket.io-client.gemspec +28 -0
- data/package.json +24 -0
- data/samples/linda_server.coffee +26 -0
- data/samples/sample.rb +25 -0
- data/test/server.rb +18 -0
- data/test/test_helper.rb +8 -0
- data/test/test_linda.rb +152 -0
- metadata +150 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e3c7170093820f427432f0e0fde6a7cb8b953135
|
4
|
+
data.tar.gz: ffebba39185ec9212284c3699e56f6cb626ac46c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9de7901d6a8a53a8cb2124c0533312b7722a0277b23eda0feaa09adf3220b22280558cc5945072ffa312df82c10e2635c0f0a38e65b93f27e55911b0c2236afb
|
7
|
+
data.tar.gz: b54f421433a1fcbf44c3ea5b33b60120277a8d26ec5a7b8e0730d52c0ca85179c139e5a7a98d30a78add5343cd2fa2dcacd721afa699228bfd299e43e1faa849
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*~
|
2
|
+
*#*
|
3
|
+
.DS_Store
|
4
|
+
*.gem
|
5
|
+
*.rbc
|
6
|
+
*.log
|
7
|
+
.bundle
|
8
|
+
.config
|
9
|
+
.yardoc
|
10
|
+
.ruby-version
|
11
|
+
InstalledFiles
|
12
|
+
_yardoc
|
13
|
+
coverage
|
14
|
+
doc/
|
15
|
+
lib/bundler/man
|
16
|
+
pkg
|
17
|
+
rdoc
|
18
|
+
spec/reports
|
19
|
+
test/tmp
|
20
|
+
test/version_tmp
|
21
|
+
tmp
|
22
|
+
vendor
|
23
|
+
node_modules
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
linda-socket.io-client (0.0.1)
|
5
|
+
event_emitter
|
6
|
+
json
|
7
|
+
socket.io-client-simple (>= 0.0.3)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
event_emitter (0.2.5)
|
13
|
+
httparty (0.12.0)
|
14
|
+
json (~> 1.8)
|
15
|
+
multi_xml (>= 0.5.2)
|
16
|
+
json (1.8.1)
|
17
|
+
minitest (5.2.1)
|
18
|
+
multi_xml (0.5.5)
|
19
|
+
rake (10.1.1)
|
20
|
+
socket.io-client-simple (0.0.4)
|
21
|
+
event_emitter
|
22
|
+
httparty
|
23
|
+
json
|
24
|
+
websocket-client-simple (>= 0.0.6)
|
25
|
+
websocket (1.1.2)
|
26
|
+
websocket-client-simple (0.0.6)
|
27
|
+
event_emitter
|
28
|
+
websocket
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
bundler (~> 1.3)
|
35
|
+
linda-socket.io-client!
|
36
|
+
minitest
|
37
|
+
rake
|
data/History.txt
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Sho Hashimoto
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Linda::SocketIO::Client
|
2
|
+
|
3
|
+
- Ruby client for [linda-socket.io](https://github.com/node-linda/linda-socket.io)
|
4
|
+
|
5
|
+
[](https://travis-ci.org/node-linda/linda-socket.io-client-ruby)
|
6
|
+
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
% gem install linda-socket.io-client
|
11
|
+
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
[samples/sample.rb](https://github.com/node-linda/linda-socket.io-client-ruby/blob/master/samples/sample.rb)
|
16
|
+
```ruby
|
17
|
+
require 'rubygems'
|
18
|
+
require 'linda-socket.io-client'
|
19
|
+
|
20
|
+
linda = Linda::SocketIO::Client.connect 'http://node-linda-base.herokuapp.com'
|
21
|
+
ts = linda.tuplespace('test')
|
22
|
+
|
23
|
+
linda.io.on :connect do
|
24
|
+
puts "connect!! #{linda.url}"
|
25
|
+
|
26
|
+
ts.watch type: "chat" do |err, tuple|
|
27
|
+
next if err
|
28
|
+
msg = tuple["data"]["msg"]
|
29
|
+
puts "> #{msg}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
linda.io.on :disconnect do
|
34
|
+
puts "disconnect"
|
35
|
+
end
|
36
|
+
|
37
|
+
while line = STDIN.gets
|
38
|
+
line.strip!
|
39
|
+
next if line.empty?
|
40
|
+
ts.write(type: "chat", msg: line, at: Time.now)
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
|
45
|
+
## Test
|
46
|
+
|
47
|
+
% gem install bundler
|
48
|
+
% bundle install
|
49
|
+
% npm install
|
50
|
+
% bundle exec rake test
|
51
|
+
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
1. Fork it
|
56
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
57
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
58
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
59
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
module Linda
|
2
|
+
module SocketIO
|
3
|
+
module Client
|
4
|
+
|
5
|
+
def self.connect(url_or_io)
|
6
|
+
::Linda::SocketIO::Client::Client.new(url_or_io)
|
7
|
+
end
|
8
|
+
|
9
|
+
class Client
|
10
|
+
|
11
|
+
attr_reader :io
|
12
|
+
|
13
|
+
def initialize(url_or_io)
|
14
|
+
if url_or_io.kind_of? String
|
15
|
+
@io = ::SocketIO::Client::Simple.connect url_or_io
|
16
|
+
elsif url_or_io.kind_of? ::SocketIO::Client::Simple::Client
|
17
|
+
@io = url_or_io
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def tuplespace(name)
|
22
|
+
TupleSpace.new(self, name.to_s)
|
23
|
+
end
|
24
|
+
|
25
|
+
def url
|
26
|
+
@io.url
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
class TupleSpace
|
32
|
+
|
33
|
+
attr_reader :name
|
34
|
+
|
35
|
+
def initialize(linda, name)
|
36
|
+
@name = name
|
37
|
+
@linda = linda
|
38
|
+
@watch_callback_ids = {}
|
39
|
+
end
|
40
|
+
|
41
|
+
def write(tuple, opts={})
|
42
|
+
data = {:tuplespace => @name, :tuple => tuple, :options => opts}
|
43
|
+
@linda.io.emit '__linda_write', data
|
44
|
+
end
|
45
|
+
|
46
|
+
def take(tuple, &block)
|
47
|
+
return unless block_given?
|
48
|
+
id = create_callback_id
|
49
|
+
name = "__linda_take_#{id}"
|
50
|
+
io_cid = @linda.io.once name, &block
|
51
|
+
@linda.io.emit '__linda_take', {:tuplespace => @name, :tuple => tuple, :id => id}
|
52
|
+
return id
|
53
|
+
end
|
54
|
+
|
55
|
+
def read(tuple, &block)
|
56
|
+
return unless block_given?
|
57
|
+
id = create_callback_id
|
58
|
+
name = "__linda_read_#{id}"
|
59
|
+
io_cid = @linda.io.once name, &block
|
60
|
+
@linda.io.emit '__linda_read', {:tuplespace => @name, :tuple => tuple, :id => id}
|
61
|
+
return id
|
62
|
+
end
|
63
|
+
|
64
|
+
def watch(tuple, &block)
|
65
|
+
return unless block_given?
|
66
|
+
id = create_watch_callback_id tuple
|
67
|
+
name = "__linda_watch_#{id}"
|
68
|
+
io_cid = @linda.io.on name, &block
|
69
|
+
@linda.io.emit '__linda_watch', {:tuplespace => @name, :tuple => tuple, :id => id}
|
70
|
+
return id
|
71
|
+
end
|
72
|
+
|
73
|
+
def cancel(id)
|
74
|
+
@linda.io.emit '__linda_cancel', {:tuplespace => @name, :id => id}
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
def create_callback_id
|
79
|
+
"#{Time.now.to_i}_#{rand 10000}"
|
80
|
+
end
|
81
|
+
|
82
|
+
def create_watch_callback_id(tuple)
|
83
|
+
key = tuple.to_json
|
84
|
+
return @watch_callback_ids[key] ||= create_callback_id
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "linda-socket.io-client/version"
|
2
|
+
require "linda-socket.io-client/error"
|
3
|
+
require "linda-socket.io-client/client"
|
4
|
+
|
5
|
+
require 'json'
|
6
|
+
require 'event_emitter'
|
7
|
+
require 'socket.io-client-simple'
|
8
|
+
|
9
|
+
module Linda
|
10
|
+
module SocketIO
|
11
|
+
module Client
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'linda-socket.io-client/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "linda-socket.io-client"
|
8
|
+
spec.version = Linda::SocketIO::Client::VERSION
|
9
|
+
spec.authors = ["Sho Hashimoto"]
|
10
|
+
spec.email = ["hashimoto@shokai.org"]
|
11
|
+
spec.description = %q{linda-socket.io client for Ruby}
|
12
|
+
spec.summary = spec.description
|
13
|
+
spec.homepage = "https://github.com/node-linda/linda-socket.io-client-ruby"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "minitest"
|
24
|
+
|
25
|
+
spec.add_dependency "json"
|
26
|
+
spec.add_dependency "event_emitter"
|
27
|
+
spec.add_dependency "socket.io-client-simple", '>= 0.0.3'
|
28
|
+
end
|
data/package.json
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"name": "linda-socket.io-client-ruby",
|
3
|
+
"description": "Ruby client for linda-socket.io",
|
4
|
+
"private": true,
|
5
|
+
"author": "Sho Hashimoto <hashimoto@shokai.org>",
|
6
|
+
"license": "MIT",
|
7
|
+
"homepage": "https://github.com/node-linda/linda-socket.io-client-ruby",
|
8
|
+
"dependencies": {
|
9
|
+
"socket.io": "~0.9.16",
|
10
|
+
"linda-socket.io": "~0.1.5",
|
11
|
+
"coffee-script": "~1.6.3"
|
12
|
+
},
|
13
|
+
"devDependencies": {},
|
14
|
+
"scripts": {
|
15
|
+
"start": "./node_modules/coffee-script/bin/coffee samples/linda_server.coffee"
|
16
|
+
},
|
17
|
+
"repository": {
|
18
|
+
"type": "git",
|
19
|
+
"url": "git://github.com/node-linda/linda-socket.io-client-ruby.git"
|
20
|
+
},
|
21
|
+
"bugs": {
|
22
|
+
"url": "https://github.com/node-linda/linda-socket.io-client-ruby/issues"
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env coffee
|
2
|
+
## see https://github.com/node-linda/linda-socket.io
|
3
|
+
|
4
|
+
http = require 'http'
|
5
|
+
|
6
|
+
app = http.createServer()
|
7
|
+
io = require('socket.io').listen(app)
|
8
|
+
io.configure 'development', ->
|
9
|
+
## io.set 'log level', 2
|
10
|
+
|
11
|
+
linda = require('linda-socket.io').Linda.listen(io: io, server: app)
|
12
|
+
|
13
|
+
linda.on 'write', (data) ->
|
14
|
+
console.log "write tuple - #{JSON.stringify data}"
|
15
|
+
|
16
|
+
linda.on 'watch', (data) ->
|
17
|
+
console.log "watch tuple - #{JSON.stringify data}"
|
18
|
+
|
19
|
+
port = (process.env.PORT || 3000) - 0
|
20
|
+
app.listen port
|
21
|
+
console.log "server start - port:#{port}"
|
22
|
+
|
23
|
+
if process.env.EXIT_AT?
|
24
|
+
setTimeout ->
|
25
|
+
process.exit()
|
26
|
+
, process.env.EXIT_AT-0
|
data/samples/sample.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
$:.unshift File.expand_path '../lib', File.dirname(__FILE__)
|
2
|
+
require 'rubygems'
|
3
|
+
require 'linda-socket.io-client'
|
4
|
+
|
5
|
+
linda = Linda::SocketIO::Client.connect 'http://localhost:3000'
|
6
|
+
ts = linda.tuplespace('test')
|
7
|
+
|
8
|
+
linda.io.on :connect do
|
9
|
+
puts "connect!! #{linda.url}"
|
10
|
+
|
11
|
+
ts.watch type: "chat" do |err, tuple|
|
12
|
+
msg = tuple["data"]["msg"]
|
13
|
+
puts "> #{msg}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
linda.io.on :disconnect do
|
18
|
+
puts "disconnect"
|
19
|
+
end
|
20
|
+
|
21
|
+
while line = STDIN.gets
|
22
|
+
line.strip!
|
23
|
+
next if line.empty?
|
24
|
+
ts.write(type: "chat", msg: line, at: Time.now)
|
25
|
+
end
|
data/test/server.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
class TestServer
|
2
|
+
|
3
|
+
def self.port
|
4
|
+
(ENV['PORT'] || 13000).to_i
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.start(exit_at=5000)
|
8
|
+
system "PORT=#{port} EXIT_AT=#{exit_at} npm start > /dev/null &"
|
9
|
+
sleep 1
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.url
|
13
|
+
"http://localhost:#{port}"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
TestServer.start
|
data/test/test_helper.rb
ADDED
data/test/test_linda.rb
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
require File.expand_path 'test_helper', File.dirname(__FILE__)
|
2
|
+
|
3
|
+
class TestLindaClient < MiniTest::Test
|
4
|
+
|
5
|
+
def create_client
|
6
|
+
socket = SocketIO::Client::Simple.connect TestServer.url
|
7
|
+
Linda::SocketIO::Client.connect socket
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_connect
|
11
|
+
linda = Linda::SocketIO::Client.connect TestServer.url
|
12
|
+
result = false
|
13
|
+
linda.io.on :connect do
|
14
|
+
result = true
|
15
|
+
end
|
16
|
+
sleep 0.5
|
17
|
+
assert result
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_socketio_client_wrap
|
21
|
+
socket = SocketIO::Client::Simple.connect TestServer.url
|
22
|
+
linda = Linda::SocketIO::Client.connect socket
|
23
|
+
result = false
|
24
|
+
linda.io.on :connect do
|
25
|
+
result = true
|
26
|
+
end
|
27
|
+
sleep 0.5
|
28
|
+
assert result
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_write_watch
|
32
|
+
results = []
|
33
|
+
client = create_client
|
34
|
+
write_data = {"foo" => "bar", "at" => Time.now.to_s}
|
35
|
+
|
36
|
+
client.io.on :connect do
|
37
|
+
ts = client.tuplespace("test_write_watch")
|
38
|
+
ts.watch foo: "bar" do |err, tuple|
|
39
|
+
next if err
|
40
|
+
results.push tuple["data"]
|
41
|
+
end
|
42
|
+
ts.write a: "b", name: "shokai"
|
43
|
+
ts.write write_data
|
44
|
+
ts.write foo: "foo", name: "ymrl"
|
45
|
+
end
|
46
|
+
sleep 0.5
|
47
|
+
assert_equal results, [write_data]
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_read_before_write
|
51
|
+
results = []
|
52
|
+
client = create_client
|
53
|
+
write_data = {"foo" => "bar", "at" => Time.now.to_s}
|
54
|
+
|
55
|
+
client.io.on :connect do
|
56
|
+
ts = client.tuplespace("test_read")
|
57
|
+
ts.read foo: "bar" do |err, tuple|
|
58
|
+
next if err
|
59
|
+
results.push tuple["data"]
|
60
|
+
end
|
61
|
+
ts.read foo: "bar" do |err, tuple|
|
62
|
+
next if err
|
63
|
+
results.push tuple["data"]
|
64
|
+
end
|
65
|
+
ts.write a: "b", name: "shokai"
|
66
|
+
ts.write write_data
|
67
|
+
ts.write foo: "foo", name: "ymrl"
|
68
|
+
end
|
69
|
+
sleep 0.5
|
70
|
+
assert_equal results, [write_data, write_data]
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_take_before_write
|
74
|
+
results = []
|
75
|
+
client = create_client
|
76
|
+
write_data = {"foo" => "bar", "at" => Time.now.to_s}
|
77
|
+
|
78
|
+
client.io.on :connect do
|
79
|
+
ts = client.tuplespace("test_take")
|
80
|
+
ts.take foo: "bar" do |err, tuple|
|
81
|
+
next if err
|
82
|
+
results.push tuple["data"]
|
83
|
+
end
|
84
|
+
ts.take foo: "bar" do |err, tuple|
|
85
|
+
next if err
|
86
|
+
results.push tuple["data"]
|
87
|
+
end
|
88
|
+
ts.write a: "b", name: "shokai"
|
89
|
+
ts.write write_data
|
90
|
+
ts.write foo: "foo", name: "ymrl"
|
91
|
+
end
|
92
|
+
sleep 0.5
|
93
|
+
assert_equal results, [write_data]
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_watch_cancel
|
97
|
+
results = []
|
98
|
+
client = create_client
|
99
|
+
write_data = {"foo" => "bar", "at" => Time.now}
|
100
|
+
|
101
|
+
client.io.on :connect do
|
102
|
+
ts = client.tuplespace("test_watch_cancel")
|
103
|
+
id = ts.watch foo: "bar" do |err, tuple|
|
104
|
+
next if err
|
105
|
+
results.push tuple["data"]
|
106
|
+
end
|
107
|
+
ts.cancel id
|
108
|
+
ts.write write_data
|
109
|
+
end
|
110
|
+
sleep 0.5
|
111
|
+
assert_equal results, []
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_read_cancel
|
115
|
+
results = []
|
116
|
+
client = create_client
|
117
|
+
write_data = {"foo" => "bar", "at" => Time.now}
|
118
|
+
|
119
|
+
client.io.on :connect do
|
120
|
+
ts = client.tuplespace("test_read_cancel")
|
121
|
+
cid = ts.read foo: "bar" do |err, tuple|
|
122
|
+
next if err
|
123
|
+
results.push tuple["data"]
|
124
|
+
end
|
125
|
+
ts.cancel cid
|
126
|
+
ts.write write_data
|
127
|
+
end
|
128
|
+
sleep 0.5
|
129
|
+
assert_equal results, []
|
130
|
+
assert_equal client.io.__events.select{|e|e[:type].to_s =~ /read/}.size, 0
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_take_cancel
|
134
|
+
results = []
|
135
|
+
client = create_client
|
136
|
+
write_data = {"foo" => "bar", "at" => Time.now}
|
137
|
+
|
138
|
+
client.io.on :connect do
|
139
|
+
ts = client.tuplespace("test_take_cancel")
|
140
|
+
cid = ts.take foo: "bar" do |err, tuple|
|
141
|
+
next if err
|
142
|
+
results.push tuple["data"]
|
143
|
+
end
|
144
|
+
ts.cancel cid
|
145
|
+
ts.write write_data
|
146
|
+
end
|
147
|
+
sleep 0.5
|
148
|
+
assert_equal results, []
|
149
|
+
assert_equal client.io.__events.select{|e|e[:type].to_s =~ /take/}.size, 0
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: linda-socket.io-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sho Hashimoto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: event_emitter
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: socket.io-client-simple
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.0.3
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.0.3
|
97
|
+
description: linda-socket.io client for Ruby
|
98
|
+
email:
|
99
|
+
- hashimoto@shokai.org
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- .travis.yml
|
106
|
+
- Gemfile
|
107
|
+
- Gemfile.lock
|
108
|
+
- History.txt
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- lib/linda-socket.io-client.rb
|
113
|
+
- lib/linda-socket.io-client/client.rb
|
114
|
+
- lib/linda-socket.io-client/error.rb
|
115
|
+
- lib/linda-socket.io-client/version.rb
|
116
|
+
- linda-socket.io-client.gemspec
|
117
|
+
- package.json
|
118
|
+
- samples/linda_server.coffee
|
119
|
+
- samples/sample.rb
|
120
|
+
- test/server.rb
|
121
|
+
- test/test_helper.rb
|
122
|
+
- test/test_linda.rb
|
123
|
+
homepage: https://github.com/node-linda/linda-socket.io-client-ruby
|
124
|
+
licenses:
|
125
|
+
- MIT
|
126
|
+
metadata: {}
|
127
|
+
post_install_message:
|
128
|
+
rdoc_options: []
|
129
|
+
require_paths:
|
130
|
+
- lib
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - '>='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - '>='
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
requirements: []
|
142
|
+
rubyforge_project:
|
143
|
+
rubygems_version: 2.0.14
|
144
|
+
signing_key:
|
145
|
+
specification_version: 4
|
146
|
+
summary: linda-socket.io client for Ruby
|
147
|
+
test_files:
|
148
|
+
- test/server.rb
|
149
|
+
- test/test_helper.rb
|
150
|
+
- test/test_linda.rb
|