ichannel 4.0.0 → 4.1.0
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.
- data/lib/ichannel/version.rb +1 -1
- data/lib/ichannel.rb +11 -3
- data/test/ichannel_class_test.rb +17 -0
- metadata +4 -4
data/lib/ichannel/version.rb
CHANGED
data/lib/ichannel.rb
CHANGED
@@ -70,7 +70,7 @@ class IChannel
|
|
70
70
|
end
|
71
71
|
_, writable, _ = IO.select nil, [@writer], nil, timeout
|
72
72
|
if writable
|
73
|
-
writable[0].
|
73
|
+
writable[0].syswrite @serializer.dump(object)
|
74
74
|
else
|
75
75
|
raise IOError, 'The channel cannot be written to.'
|
76
76
|
end
|
@@ -116,7 +116,7 @@ class IChannel
|
|
116
116
|
end
|
117
117
|
readable, _ = IO.select [@reader], nil, nil, timeout
|
118
118
|
if readable
|
119
|
-
msg
|
119
|
+
msg = readable[0].sysread 1024
|
120
120
|
@serializer.load msg
|
121
121
|
else
|
122
122
|
raise IOError, 'The channel cannot be read from.'
|
@@ -126,7 +126,7 @@ class IChannel
|
|
126
126
|
|
127
127
|
#
|
128
128
|
# @return [Boolean]
|
129
|
-
# Returns true
|
129
|
+
# Returns true when the channel is empty (nothing to read).
|
130
130
|
#
|
131
131
|
def empty?
|
132
132
|
if @reader.closed?
|
@@ -135,4 +135,12 @@ class IChannel
|
|
135
135
|
! IO.select [@reader], nil, nil, 0.1
|
136
136
|
end
|
137
137
|
end
|
138
|
+
|
139
|
+
#
|
140
|
+
# @return [Boolean]
|
141
|
+
# Returns true when the channel is readable.
|
142
|
+
#
|
143
|
+
def readable?
|
144
|
+
! empty?
|
145
|
+
end
|
138
146
|
end
|
data/test/ichannel_class_test.rb
CHANGED
@@ -60,4 +60,21 @@ class IChannelTest < Test::Unit::TestCase
|
|
60
60
|
@channel.close
|
61
61
|
assert @channel.empty?
|
62
62
|
end
|
63
|
+
|
64
|
+
def test_readable_on_populated_channel
|
65
|
+
@channel.put %w(a)
|
66
|
+
@channel.put %w(b)
|
67
|
+
assert @channel.readable?
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_readable_on_empty_channel
|
71
|
+
@channel.put %w(42)
|
72
|
+
@channel.get # discard
|
73
|
+
refute @channel.readable?
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_readable_on_closed_channel
|
77
|
+
@channel.close
|
78
|
+
refute @channel.readable?
|
79
|
+
end
|
63
80
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ichannel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-30 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! "A modern and easy-to-use interprocess communication \n primitive."
|
15
15
|
email:
|
@@ -45,7 +45,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
45
45
|
version: '0'
|
46
46
|
segments:
|
47
47
|
- 0
|
48
|
-
hash:
|
48
|
+
hash: -2586476710676895974
|
49
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
@@ -54,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
54
|
version: '0'
|
55
55
|
segments:
|
56
56
|
- 0
|
57
|
-
hash:
|
57
|
+
hash: -2586476710676895974
|
58
58
|
requirements: []
|
59
59
|
rubyforge_project:
|
60
60
|
rubygems_version: 1.8.23
|