protoplasm-blocking-client 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,28 +27,29 @@ module Protoplasm
27
27
  cmd = self.class._types.request_class.new(self.class._types.request_type_field => type.type, type.field => cmd_class.type.new(*args))
28
28
  cmd.encode(s)
29
29
  socket = _socket
30
- socket.write([0, s.size].pack("CQ"))
30
+ socket.write([Types::Request::NORMAL, s.size].pack("CQ"))
31
31
  socket.write s
32
32
  socket.flush
33
33
  fetch_objects = true
34
34
  obj = nil
35
35
  while fetch_objects
36
- response_code = socket.readpartial(1).unpack("C").first
36
+ response_byte = socket.read(1)
37
+ response_code = response_byte.unpack("C").first
37
38
  case response_code
38
39
  when Types::Response::NORMAL
39
40
  fetch_objects = !type.void?
40
41
  if fetch_objects
41
- len_buf = ''
42
- socket.readpartial(8 - len_buf.size, len_buf) while len_buf.size != 8
42
+ len_buf = socket.read(8)
43
43
  len = len_buf.unpack("Q").first
44
- buf = ''
45
- socket.readpartial(len - buf.size, buf) until buf.size == len
46
- obj = type.response_class.decode(buf)
44
+ data = socket.read(len)
45
+ obj = type.response_class.decode(data)
47
46
  yield obj if block_given?
48
47
  end
49
48
  fetch_objects = false unless type.streaming?
50
49
  when Types::Response::STOP_STREAMING
51
50
  fetch_objects = false
51
+ else
52
+ raise "Control byte is #{response_byte.inspect}, code is #{response_code.inspect}"
52
53
  end
53
54
  end
54
55
  obj
@@ -74,7 +74,8 @@ module Protoplasm
74
74
  obj = type.response_class.new(*args)
75
75
  s = ''
76
76
  obj.encode(s)
77
- send_data [Types::Response::NORMAL, s.size].pack("CQ")
77
+ send_data [Types::Response::NORMAL].pack("C")
78
+ send_data [s.size].pack("Q")
78
79
  send_data s
79
80
  end
80
81
  end
@@ -1,3 +1,3 @@
1
1
  module Protoplasm
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protoplasm-blocking-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-02 00:00:00.000000000Z
12
+ date: 2012-01-04 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: beefcake
16
- requirement: &70220530750460 !ruby/object:Gem::Requirement
16
+ requirement: &70224617142360 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.3.7
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70220530750460
24
+ version_requirements: *70224617142360
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70220530749180 !ruby/object:Gem::Requirement
27
+ requirement: &70224617141940 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70220530749180
35
+ version_requirements: *70224617141940
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: minitest
38
- requirement: &70220530747560 !ruby/object:Gem::Requirement
38
+ requirement: &70224617141400 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 2.6.1
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70220530747560
46
+ version_requirements: *70224617141400
47
47
  description: A blocking client for a Protoplasm server.
48
48
  email:
49
49
  - joshbuddy@gmail.com
@@ -78,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
78
  version: '0'
79
79
  segments:
80
80
  - 0
81
- hash: -2334729353408279597
81
+ hash: 4090923455675816360
82
82
  required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  version: '0'
88
88
  segments:
89
89
  - 0
90
- hash: -2334729353408279597
90
+ hash: 4090923455675816360
91
91
  requirements: []
92
92
  rubyforge_project: protoplasm-blocking-client
93
93
  rubygems_version: 1.8.10