boss-protocol 1.4.2 → 1.4.3

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: b396f11246208a61e308b3aacbd4f4f9ccb23e32
4
- data.tar.gz: c6ec201f8e6c42f079660614c58e8185f9a8f486
3
+ metadata.gz: 5874e8e0bafe28f14f96860d9e91ea38d0ab1783
4
+ data.tar.gz: ba1ce2c78a5f90e304f1e9bdc4fe7d3c4617df4e
5
5
  SHA512:
6
- metadata.gz: a0b5291588eac732637fe136d454e9e0ac486a00a18d1a0055ea0934b89d4d9f143574248d95d8328ea2edcb908ff8e7b077ef1509d11d9890d26afcaa63fe34
7
- data.tar.gz: 175de9dc48ad4f4f8404f171c693a74ea63aad4a5b8ef1e6946719c38edd8d6d976503c60e469f8ac8c09b3aeb77a656f8075f8c9a7f793e29c042a3b98bc71b
6
+ metadata.gz: 1f6d6ca3de1a97e307cafd2aef68e983d21e62d4b237849ebc181d1e83200c845d83d6ab64f1f3eb2f829eb79a0cf93e91e933f507e72ba9dcf31985ee56936c
7
+ data.tar.gz: 21bbd5e2bff93811da4eac812bcf01c0103a4b95f28a85c7e361731e422f6f87f840b52bf0d858ce08fee289212d4abbef5efb622202e3671c3ffa7f7fd6c4b2
@@ -1,3 +1,3 @@
1
1
  module Boss
2
- VERSION = "1.4.2"
2
+ VERSION = "1.4.3"
3
3
  end
data/lib/boss-protocol.rb CHANGED
@@ -311,7 +311,7 @@ module Boss
311
311
  ##
312
312
  # write single byte
313
313
  def wbyte(b)
314
- @io.putc(b.chr)
314
+ @io << b.chr
315
315
  end
316
316
 
317
317
  def wdouble val
@@ -338,6 +338,17 @@ module Boss
338
338
  @stream_mode = false
339
339
  end
340
340
 
341
+ ##
342
+ # Load the object (object tree) from the stream. Note that if there
343
+ # is more than one object in the stream that are stored with the same
344
+ # Formatter instance, they will share same cache and references,
345
+ # see Boss.Formatter.put for details.
346
+ # Note that nil is a valid restored object. Check eof? or catch
347
+ # EOFError, or use Boss.Parser.each to read all objects from the stream
348
+ def read
349
+ get
350
+ end
351
+
341
352
  ##
342
353
  # Load the object (object tree) from the stream. Note that if there
343
354
  # is more than one object in the stream that are stored with the same
data/spec/boss_spec.rb CHANGED
@@ -5,6 +5,37 @@ require 'json'
5
5
  require 'zlib'
6
6
  require 'base64'
7
7
  require 'boss-protocol'
8
+ require 'socket'
9
+
10
+ class SocketStream
11
+
12
+ def initialize socket
13
+ @socket = socket
14
+ end
15
+
16
+ def read length=1
17
+ # data = ''
18
+ # while data.length < length
19
+ # data << @socket.recv(length - data.length, Socket::MSG_WAITALL)
20
+ # end
21
+ # data
22
+ @socket.read length
23
+ end
24
+
25
+ def write data
26
+ @socket.write data
27
+ end
28
+
29
+ def eof?
30
+ @socket.eof?
31
+ end
32
+
33
+ def << data
34
+ write data
35
+ end
36
+
37
+ end
38
+
8
39
 
9
40
  describe 'Boss' do
10
41
 
@@ -231,6 +262,41 @@ describe 'Boss' do
231
262
  b.should == c
232
263
  c.should == d
233
264
  end
265
+
266
+ it 'run interoperable' do
267
+ s1, s2 = Socket.pair(:UNIX, :STREAM, 0)
268
+
269
+ out = SocketStream.new(s1)
270
+ ins = Boss::Parser.new SocketStream.new(s2)
271
+
272
+ last = nil
273
+ t = Thread.start {
274
+ ins.each { |obj|
275
+ obj == nil and break
276
+ last= obj
277
+ }
278
+ }
279
+
280
+ out << Boss.dump( { :cmd => "foo", :args => [], :kwargs => {}, :serial => 0 })
281
+ out << Boss.dump({ :ref => 0, :error => { "class" => "ArgumentError", "text" => "wrong number of arguments (given 0, expected 2)" }, :serial => 0 })
282
+ out << Boss.dump( { :cmd => "foo", :args => [10, 20], :kwargs => {}, :serial => 1 })
283
+ out << Boss.dump( { :ref => 1, :result => "Foo: 30, none", :serial => 1 })
284
+ out << Boss.dump( { :cmd => "foo", :args => [5, 6], :kwargs => { :optional => "yes!" }, :serial => 2 })
285
+ out << Boss.dump( { :ref => 2, :result => "Foo: 11, yes!", :serial => 2 })
286
+ out << Boss.dump( { :cmd => "a", :args => [], :kwargs => {}, :serial => 3 } )
287
+ out << Boss.dump( { :ref => 3, :result => 5, :serial => 3 } )
288
+
289
+ out << Boss.dump( { :cmd => "b", :args => [], :kwargs => {}, :serial => 4 } )
290
+ out << Boss.dump( { :ref => 4, :result => 6, :serial => 4 } )
291
+ out << Boss.dump( { :cmd => "get_hash", :args => [], :kwargs => {}, :serial => 5 } )
292
+ out << Boss.dump( { :ref => 5, :result => { "foo" => "bar", "bardd" => "buzz", "last" => "item", "bar" => "test" }, :serial => 5 } )
293
+
294
+ out << Boss.dump(nil)
295
+ t.join
296
+
297
+ last['ref'].should == 5
298
+ last['result']['foo'].should == 'bar'
299
+ end
234
300
 
235
301
  def round_check(ob)
236
302
  ob.should == Boss.load(Boss.dump(ob))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boss-protocol
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - sergeych