linda-socket.io-client 0.0.1 → 0.0.2

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: e3c7170093820f427432f0e0fde6a7cb8b953135
4
- data.tar.gz: ffebba39185ec9212284c3699e56f6cb626ac46c
3
+ metadata.gz: d741bf7229adf24256bfe5324bc159c1d12952d4
4
+ data.tar.gz: 186ecdea6c5ba6f92383ddfc0f650cd70fb78561
5
5
  SHA512:
6
- metadata.gz: 9de7901d6a8a53a8cb2124c0533312b7722a0277b23eda0feaa09adf3220b22280558cc5945072ffa312df82c10e2635c0f0a38e65b93f27e55911b0c2236afb
7
- data.tar.gz: b54f421433a1fcbf44c3ea5b33b60120277a8d26ec5a7b8e0730d52c0ca85179c139e5a7a98d30a78add5343cd2fa2dcacd721afa699228bfd299e43e1faa849
6
+ metadata.gz: 039f123acc35ea769fbad3f0cfb7c5ea95f711f3c96a901bf9008496801e1bc16a3efe0fc2ed387ee81783d7e6824c71e36e25dfb125096dc03728dd3d04cddc
7
+ data.tar.gz: e08278e32f67cb982f755c53cdd96ece5ac1bda9d6d17eab536744a0c7d63a67f9ccd5445044a2d45ebb36085d4b0e876c943070f51ec50f0eaa35ed5b4261f2
data/.travis.yml CHANGED
@@ -4,6 +4,5 @@ node_js:
4
4
  rvm:
5
5
  - 1.9.3
6
6
  - 2.0.0
7
- - jruby-head
8
7
  before_script:
9
8
  - npm install
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- linda-socket.io-client (0.0.1)
4
+ linda-socket.io-client (0.0.2)
5
5
  event_emitter
6
+ hashie
6
7
  json
7
8
  socket.io-client-simple (>= 0.0.3)
8
9
 
@@ -10,6 +11,7 @@ GEM
10
11
  remote: https://rubygems.org/
11
12
  specs:
12
13
  event_emitter (0.2.5)
14
+ hashie (2.0.5)
13
15
  httparty (0.12.0)
14
16
  json (~> 1.8)
15
17
  multi_xml (>= 0.5.2)
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.0.2 2014-1-24
2
+
3
+ * wrap return value of TupleSpace#read/take/watch by Hashie::Mash #2
4
+
1
5
  === 0.0.1 2014-1-21
2
6
 
3
7
  * first release
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  - Ruby client for [linda-socket.io](https://github.com/node-linda/linda-socket.io)
4
4
 
5
- [![Travis-CI build status](https://travis-ci.org/node-linda/linda-socket.io-client-ruby.png)](https://travis-ci.org/node-linda/linda-socket.io-client-ruby)
5
+ [![Travis-CI build status](https://travis-ci.org/node-linda/linda-socket.io-client-ruby.png?branch=master)](https://travis-ci.org/node-linda/linda-socket.io-client-ruby)
6
6
 
7
7
 
8
8
  ## Installation
@@ -25,8 +25,7 @@ linda.io.on :connect do
25
25
 
26
26
  ts.watch type: "chat" do |err, tuple|
27
27
  next if err
28
- msg = tuple["data"]["msg"]
29
- puts "> #{msg}"
28
+ puts "> #{tuple.data.msg} (from:#{tuple.from})"
30
29
  end
31
30
  end
32
31
 
@@ -6,6 +6,9 @@ module Linda
6
6
  ::Linda::SocketIO::Client::Client.new(url_or_io)
7
7
  end
8
8
 
9
+ class Tuple < ::Hashie::Mash
10
+ end
11
+
9
12
  class Client
10
13
 
11
14
  attr_reader :io
@@ -47,7 +50,9 @@ module Linda
47
50
  return unless block_given?
48
51
  id = create_callback_id
49
52
  name = "__linda_take_#{id}"
50
- io_cid = @linda.io.once name, &block
53
+ io_cid = @linda.io.once name do |err, tuple|
54
+ block.call err, Tuple.new(tuple)
55
+ end
51
56
  @linda.io.emit '__linda_take', {:tuplespace => @name, :tuple => tuple, :id => id}
52
57
  return id
53
58
  end
@@ -56,7 +61,9 @@ module Linda
56
61
  return unless block_given?
57
62
  id = create_callback_id
58
63
  name = "__linda_read_#{id}"
59
- io_cid = @linda.io.once name, &block
64
+ io_cid = @linda.io.once name do |err, tuple|
65
+ block.call err, Tuple.new(tuple)
66
+ end
60
67
  @linda.io.emit '__linda_read', {:tuplespace => @name, :tuple => tuple, :id => id}
61
68
  return id
62
69
  end
@@ -65,7 +72,9 @@ module Linda
65
72
  return unless block_given?
66
73
  id = create_watch_callback_id tuple
67
74
  name = "__linda_watch_#{id}"
68
- io_cid = @linda.io.on name, &block
75
+ io_cid = @linda.io.on name do |err, tuple|
76
+ block.call err, Tuple.new(tuple)
77
+ end
69
78
  @linda.io.emit '__linda_watch', {:tuplespace => @name, :tuple => tuple, :id => id}
70
79
  return id
71
80
  end
@@ -1,7 +1,7 @@
1
1
  module Linda
2
2
  module SocketIO
3
3
  module Client
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
6
6
  end
7
7
  end
@@ -1,11 +1,12 @@
1
- require "linda-socket.io-client/version"
2
- require "linda-socket.io-client/error"
3
- require "linda-socket.io-client/client"
4
-
5
1
  require 'json'
2
+ require 'hashie'
6
3
  require 'event_emitter'
7
4
  require 'socket.io-client-simple'
8
5
 
6
+ require "linda-socket.io-client/version"
7
+ require "linda-socket.io-client/error"
8
+ require "linda-socket.io-client/client"
9
+
9
10
  module Linda
10
11
  module SocketIO
11
12
  module Client
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "minitest"
24
24
 
25
25
  spec.add_dependency "json"
26
+ spec.add_dependency "hashie"
26
27
  spec.add_dependency "event_emitter"
27
28
  spec.add_dependency "socket.io-client-simple", '>= 0.0.3'
28
29
  end
data/samples/sample.rb CHANGED
@@ -9,8 +9,8 @@ linda.io.on :connect do
9
9
  puts "connect!! #{linda.url}"
10
10
 
11
11
  ts.watch type: "chat" do |err, tuple|
12
- msg = tuple["data"]["msg"]
13
- puts "> #{msg}"
12
+ next if err
13
+ puts "> #{tuple.data.msg} (from:#{tuple.from})"
14
14
  end
15
15
  end
16
16
 
data/test/test_linda.rb CHANGED
@@ -37,7 +37,7 @@ class TestLindaClient < MiniTest::Test
37
37
  ts = client.tuplespace("test_write_watch")
38
38
  ts.watch foo: "bar" do |err, tuple|
39
39
  next if err
40
- results.push tuple["data"]
40
+ results.push tuple.data
41
41
  end
42
42
  ts.write a: "b", name: "shokai"
43
43
  ts.write write_data
@@ -56,11 +56,11 @@ class TestLindaClient < MiniTest::Test
56
56
  ts = client.tuplespace("test_read")
57
57
  ts.read foo: "bar" do |err, tuple|
58
58
  next if err
59
- results.push tuple["data"]
59
+ results.push tuple.data
60
60
  end
61
61
  ts.read foo: "bar" do |err, tuple|
62
62
  next if err
63
- results.push tuple["data"]
63
+ results.push tuple.data
64
64
  end
65
65
  ts.write a: "b", name: "shokai"
66
66
  ts.write write_data
@@ -79,11 +79,11 @@ class TestLindaClient < MiniTest::Test
79
79
  ts = client.tuplespace("test_take")
80
80
  ts.take foo: "bar" do |err, tuple|
81
81
  next if err
82
- results.push tuple["data"]
82
+ results.push tuple.data
83
83
  end
84
84
  ts.take foo: "bar" do |err, tuple|
85
85
  next if err
86
- results.push tuple["data"]
86
+ results.push tuple.data
87
87
  end
88
88
  ts.write a: "b", name: "shokai"
89
89
  ts.write write_data
@@ -102,7 +102,7 @@ class TestLindaClient < MiniTest::Test
102
102
  ts = client.tuplespace("test_watch_cancel")
103
103
  id = ts.watch foo: "bar" do |err, tuple|
104
104
  next if err
105
- results.push tuple["data"]
105
+ results.push tuple.data
106
106
  end
107
107
  ts.cancel id
108
108
  ts.write write_data
@@ -120,7 +120,7 @@ class TestLindaClient < MiniTest::Test
120
120
  ts = client.tuplespace("test_read_cancel")
121
121
  cid = ts.read foo: "bar" do |err, tuple|
122
122
  next if err
123
- results.push tuple["data"]
123
+ results.push tuple.data
124
124
  end
125
125
  ts.cancel cid
126
126
  ts.write write_data
@@ -139,7 +139,7 @@ class TestLindaClient < MiniTest::Test
139
139
  ts = client.tuplespace("test_take_cancel")
140
140
  cid = ts.take foo: "bar" do |err, tuple|
141
141
  next if err
142
- results.push tuple["data"]
142
+ results.push tuple.data
143
143
  end
144
144
  ts.cancel cid
145
145
  ts.write write_data
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linda-socket.io-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sho Hashimoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-20 00:00:00.000000000 Z
11
+ date: 2014-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: hashie
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'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: event_emitter
71
85
  requirement: !ruby/object:Gem::Requirement