sanford-protocol 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,4 +1 @@
1
1
  require "bundler/gem_tasks"
2
-
3
- require "assert/rake_tasks"
4
- Assert::RakeTasks.install
@@ -63,7 +63,7 @@ module Sanford::Protocol
63
63
  end
64
64
 
65
65
  def read(number_of_bytes)
66
- tcp_socket.recv(number_of_bytes)
66
+ recv(number_of_bytes)
67
67
  end
68
68
 
69
69
  def write(*binary_strings)
@@ -71,12 +71,24 @@ module Sanford::Protocol
71
71
  end
72
72
 
73
73
  def peek(number_of_bytes = 1)
74
- tcp_socket.recv(number_of_bytes, ::Socket::MSG_PEEK)
74
+ recv(number_of_bytes, ::Socket::MSG_PEEK)
75
75
  end
76
76
 
77
77
  def close
78
78
  tcp_socket.close rescue false
79
79
  end
80
+
81
+ protected
82
+
83
+ def recv(number_of_bytes, *flags)
84
+ value = ""
85
+ while value.bytesize < number_of_bytes
86
+ data = tcp_socket.recv(number_of_bytes - value.bytesize, *flags)
87
+ !data.empty? ? value += data : break
88
+ end
89
+ value
90
+ end
91
+
80
92
  end
81
93
 
82
94
  class TimeoutError < RuntimeError
@@ -1,5 +1,5 @@
1
1
  module Sanford
2
2
  module Protocol
3
- GEM_VERSION = "0.5.3"
3
+ GEM_VERSION = "0.5.4"
4
4
  end
5
5
  end
@@ -19,6 +19,6 @@ Gem::Specification.new do |gem|
19
19
 
20
20
  gem.add_dependency("bson", ["~>1.7"])
21
21
 
22
- gem.add_development_dependency("assert", ["~> 1.0"])
22
+ gem.add_development_dependency("assert", ["~> 2.0"])
23
23
  gem.add_development_dependency("assert-mocha", ["~> 1.0"])
24
24
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sanford-protocol
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 3
10
- version: 0.5.3
9
+ - 4
10
+ version: 0.5.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Collin Redding
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2013-02-05 00:00:00 Z
19
+ date: 2013-03-04 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  prerelease: false
@@ -40,11 +40,11 @@ dependencies:
40
40
  requirements:
41
41
  - - ~>
42
42
  - !ruby/object:Gem::Version
43
- hash: 15
43
+ hash: 3
44
44
  segments:
45
- - 1
45
+ - 2
46
46
  - 0
47
- version: "1.0"
47
+ version: "2.0"
48
48
  requirement: *id002
49
49
  name: assert
50
50
  type: :development