rack-mux 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/rack/mux.rb +17 -15
  2. data/spec/spec_helper.rb +1 -0
  3. metadata +6 -6
data/lib/rack/mux.rb CHANGED
@@ -2,7 +2,7 @@ require 'rack'
2
2
 
3
3
  module Rack
4
4
  class Mux
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
  HEADER = 'X-Mux-Uri'
7
7
 
8
8
  def initialize(app, options = {})
@@ -20,7 +20,7 @@ module Rack
20
20
 
21
21
  def rackup
22
22
  Thread.new(server_options) do |options|
23
- Server.start(server_options)
23
+ Server.start(options)
24
24
  end
25
25
 
26
26
  wait_for_server
@@ -39,24 +39,26 @@ module Rack
39
39
  end
40
40
 
41
41
  def find_port
42
- port = rand(64510) + 1025
43
-
44
- begin
45
- TCPSocket.new(@host, port)
46
- retry
47
- rescue Errno::ECONNREFUSED
48
- return port
42
+ loop do
43
+ port = rand(64510) + 1025
44
+ begin
45
+ TCPSocket.new(@host, port)
46
+ rescue Errno::ECONNREFUSED
47
+ return port
48
+ end
49
49
  end
50
50
  end
51
51
 
52
52
  def wait_for_server
53
53
  Timeout::timeout(30) do
54
- begin
55
- return TCPSocket.new(@host, @port)
56
- rescue Errno::ECONNREFUSED
57
- retry
58
- rescue => e
59
- raise Error, e.message
54
+ loop do
55
+ begin
56
+ return TCPSocket.new(@host, @port)
57
+ rescue Errno::ECONNREFUSED
58
+ sleep 1
59
+ rescue => e
60
+ raise Error, e.message
61
+ end
60
62
  end
61
63
  end
62
64
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
 
3
+ require 'timeout'
3
4
  require 'rack/mux'
4
5
  require 'rack/client'
5
6
  require 'json'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-mux
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease: false
4
+ hash: 31
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ben Burkert
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-24 00:00:00 -07:00
18
+ date: 2011-04-28 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  requirements: []
164
164
 
165
165
  rubyforge_project:
166
- rubygems_version: 1.3.7
166
+ rubygems_version: 1.6.2
167
167
  signing_key:
168
168
  specification_version: 3
169
169
  summary: Multiplex multiple rack servers to the same app.