ichannel 7.1.0 → 8.0.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/.travis.yml CHANGED
@@ -2,14 +2,13 @@ rvm:
2
2
  - 1.9.2
3
3
  - 1.9.3
4
4
  - 2.0.0
5
- # - ruby-head
6
5
  - rbx-19mode
7
- # - jruby-19mode
6
+ # - ruby-head
8
7
 
9
8
  env:
10
- - SERIALIZER=YAML
11
- - SERIALIZER=Marshal
12
- - SERIALIZER=JSON
9
+ - REDIS=1 SERIALIZER=YAML
10
+ - REDIS=1 SERIALIZER=Marshal
11
+ - REDIS=1 SERIALIZER=JSON
13
12
 
14
13
  services:
15
14
  - redis-server
data/ChangeLog.txt CHANGED
@@ -1,3 +1,15 @@
1
+ == v8.0.0
2
+ - Redis#write! does not time out.
3
+ A write to redis is not wrapped in Timeout.timeout() anymore
4
+ and cannot be timed out. The timeout argument is a no-op.
5
+
6
+ - Add IChannel::TimeoutError
7
+ Redis#get!, UNIXSocket#get!, UNIXSocket#write! raise
8
+ IChannel::TimeoutError instead of Timeout::Error.
9
+
10
+ - Remove all use of timeout.rb from lib/
11
+ 'timeout' from the standard library is retired from ichannel.
12
+
1
13
  == v7.1.0
2
14
  - Redis#last_msg, UNIXSocket#last_msg return last read value
3
15
  after a channel has been closed.
data/Gemfile CHANGED
@@ -6,5 +6,8 @@ group :development do
6
6
  gem "yard"
7
7
  gem "foreman"
8
8
  end
9
+ group :test do
10
+ gem "colorize"
11
+ end
9
12
  gem "redis"
10
13
  gemspec
data/README.md CHANGED
@@ -101,15 +101,6 @@ _supported_
101
101
 
102
102
  * CRuby (1.9+)
103
103
  * Rubinius (1.9+)
104
- * JRuby (1.9+ - some tests skipped)
105
- JRuby is supported and passes the test suite but it skips any
106
- tests(three/four) that invoke Kernel#fork. The other tests pass
107
- on jruby, and those tests cover unix sockets/redis.
108
-
109
- _unsupported_
110
-
111
- * Any 1.8 implementation
112
- * MacRuby
113
104
 
114
105
  __INSTALL__
115
106
 
@@ -59,27 +59,22 @@ class IChannel::Redis
59
59
  # Add an object to the channel.
60
60
  #
61
61
  # @param [Object] object
62
- # The object to add to the channel.
62
+ # An object to add.
63
63
  #
64
64
  # @param [Fixnum] timeout
65
- # The amount of time to wait for the write to complete.
65
+ # This argument is a no-op for a write to a redis channel.
66
66
  #
67
67
  # @raise [IOError]
68
68
  # When the channel is closed.
69
69
  #
70
- # @raise [Timeout::Error]
71
- # When the write does not complete in time.
72
- #
73
70
  # @return [void]
74
71
  #
75
72
  def write!(object, timeout = 0.1)
76
73
  if closed?
77
74
  raise IOError, 'The channel cannot be written to (closed)'
78
75
  end
79
- Timeout.timeout(timeout) do
80
- dump = @serializer.dump object
81
- @redis.lpush @key, dump
82
- end
76
+ dump = @serializer.dump object
77
+ @redis.lpush @key, dump
83
78
  end
84
79
  alias_method :put!, :write!
85
80
 
@@ -99,12 +94,12 @@ class IChannel::Redis
99
94
 
100
95
  #
101
96
  # @param [Fixnum] timeout
102
- # The number of seconds (as an Integer) to wait before a time out will occur.
97
+ # The number of seconds (as an Integer) to wait for a read.
103
98
  #
104
99
  # @raise [IOError]
105
100
  # When the channel is closed or empty.
106
101
  #
107
- # @raise [Timeout::Error]
102
+ # @raise [IChannel::TimeoutError]
108
103
  # When _timeout_ seconds pass and the read has not completed.
109
104
  #
110
105
  # @return [Object]
@@ -118,7 +113,7 @@ class IChannel::Redis
118
113
  if payload
119
114
  @last_msg = @serializer.load(payload)
120
115
  else
121
- raise Timeout::Error, "timeout on read after #{timeout} seconds"
116
+ raise IChannel::TimeoutError, "timeout on read after #{timeout} seconds"
122
117
  end
123
118
  end
124
119
  alias_method :get!, :recv!
@@ -47,7 +47,7 @@ module IChannel
47
47
  # When the channel is closed.
48
48
  #
49
49
  # @param [Object] object
50
- # An object to add to the channel.
50
+ # An object to add.
51
51
  #
52
52
  def write(object)
53
53
  write!(object, nil)
@@ -57,20 +57,17 @@ module IChannel
57
57
  #
58
58
  # Add an object to the channel.
59
59
  #
60
- # Unlike {#write}, which waits indefinitely until the channel becomes writable,
61
- # this method will raise an IOError when _timeout_ seconds elapse and
62
- # the channel remains unwritable.
63
- #
64
60
  # @param
65
61
  # (see IChannel#write)
66
62
  #
67
63
  # @param [Numeric] timeout
68
64
  # The number of seconds to wait for the channel to become writable.
69
65
  #
70
- # @raise (see IChannel#write)
66
+ # @raise
67
+ # (see IChannel#write)
71
68
  #
72
69
  # @raise [IOError]
73
- # When _timeout_ seconds elapse & the channel remains unwritable.
70
+ # When _timeout_ seconds elapse and the channel cannot be written to.
74
71
  #
75
72
  def write!(object, timeout = 0.1)
76
73
  if @writer.closed?
@@ -127,7 +124,7 @@ module IChannel
127
124
  # @raise [IOError]
128
125
  # (see IChannel#recv)
129
126
  #
130
- # @raise [Timeout::Error]
127
+ # @raise [IChannel::TimeoutError]
131
128
  # When _timeout_ seconds elapse & the channel remains unreadable.
132
129
  #
133
130
  # @return [Object]
@@ -142,7 +139,7 @@ module IChannel
142
139
  msg = readable[0].readline(SEP).chomp SEP
143
140
  @last_msg = @serializer.load msg
144
141
  else
145
- raise Timeout::Error, 'Time out on read (waited for %s second(s))' % [timeout]
142
+ raise IChannel::TimeoutError, 'Time out on read (waited for %s second(s))' % [timeout]
146
143
  end
147
144
  end
148
145
  alias_method :get!, :recv!
@@ -1,3 +1,3 @@
1
1
  module IChannel
2
- VERSION = "7.1.0"
2
+ VERSION = "8.0.0"
3
3
  end
data/lib/ichannel.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module IChannel
2
- require "timeout"
2
+ TimeoutError = Class.new(StandardError)
3
3
  require_relative "ichannel/unix_socket"
4
4
 
5
5
  #
@@ -1,6 +1,14 @@
1
1
  require_relative 'setup'
2
- class IChannelRedisTest < Test::Unit::TestCase
3
- # This includes the tests all channels should pass(redis or unix
2
+ if ENV["REDIS"] != "1"
3
+ require "colorize"
4
+ warn "[WARNING] redis tests ignored. set REDIS=1 to test with redis.".red
5
+ testcase = Object
6
+ else
7
+ testcase = Test::Unit::TestCase
8
+ end
9
+
10
+ class IChannelRedisTest < testcase
11
+ # This includes the tests all channels should pass(redis and unix
4
12
  # socket). Any tests specific to redis can go in this class.
5
13
  include UniformIChannelTest
6
14
 
@@ -14,10 +22,4 @@ class IChannelRedisTest < Test::Unit::TestCase
14
22
  @channel.instance_variable_get(:@redis).del(key)
15
23
  @channel.close
16
24
  end
17
-
18
- def test_timeout_on_get
19
- assert_raises Timeout::Error do
20
- @channel.get! 1
21
- end
22
- end
23
25
  end
@@ -1,6 +1,6 @@
1
1
  require_relative "setup"
2
2
  class IChannelTest < Test::Unit::TestCase
3
- # This includes the tests all channels should pass(redis or unix
3
+ # This includes the tests all channels should pass(redis and unix
4
4
  # socket). Any tests specific to a unit socket can go in this class.
5
5
  include UniformIChannelTest
6
6
 
data/test/setup.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  require "bundler"
2
2
  Bundler.require :default
3
- require_relative '../lib/ichannel'
3
+ require 'ichannel'
4
4
  require 'yaml'
5
5
  require 'json'
6
+ require 'timeout'
6
7
  require 'test/unit'
7
8
  require_relative "uniform_ichannel_test"
@@ -29,8 +29,8 @@ module UniformIChannelTest
29
29
  end
30
30
 
31
31
  def test_timeout_on_get
32
- assert_raises Timeout::Error do
33
- @channel.get! 0.1
32
+ assert_raises IChannel::TimeoutError do
33
+ @channel.get! 1
34
34
  end
35
35
  end
36
36
 
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: 7.1.0
4
+ version: 8.0.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: 2013-08-07 00:00:00.000000000 Z
12
+ date: 2013-08-15 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: interprocess communication channel
15
15
  email:
@@ -52,7 +52,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
52
  version: '0'
53
53
  segments:
54
54
  - 0
55
- hash: 3208859644147126315
55
+ hash: 3456216786864862770
56
56
  required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  version: '0'
62
62
  segments:
63
63
  - 0
64
- hash: 3208859644147126315
64
+ hash: 3456216786864862770
65
65
  requirements: []
66
66
  rubyforge_project:
67
67
  rubygems_version: 1.8.23