godot 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,7 @@
1
1
  rvm:
2
2
  - 1.9.3
3
3
  - 1.9.2
4
+ - 1.8.7
4
5
  - jruby-19mode
5
6
  - rbx-19mode
6
- - ruby-head
7
- - jruby-head
8
7
  script: script/ci.sh
@@ -3,7 +3,7 @@ require "socket"
3
3
 
4
4
  class Godot
5
5
  attr_reader :host, :port
6
- attr_writer :interval, :timeout
6
+ attr_accessor :trace, :interval, :timeout
7
7
 
8
8
  def self.wait!(host, port)
9
9
  new(host, port).wait!
@@ -21,31 +21,29 @@ class Godot
21
21
  new(host, port).match(pattern, path, options)
22
22
  end
23
23
 
24
- def initialize(host, port)
24
+ def initialize(host, port, options = {})
25
25
  @host = host
26
26
  @port = port
27
- end
28
-
29
- def interval
30
- @interval || 1
31
- end
32
-
33
- def timeout
34
- @timeout || 10
27
+ @interval = options[:interval] || 1
28
+ @trace = options[:trace] || false
29
+ @timeout = options[:timeout] || 10
35
30
  end
36
31
 
37
32
  def wait!
33
+ socket = nil
38
34
  Timeout.timeout(timeout) do
39
- socket = nil
40
35
  until socket
41
36
  begin
42
37
  Timeout.timeout(interval) do
43
38
  socket = TCPSocket.open(host, port)
44
39
  end
45
- rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT, Timeout::Error, Errno::EHOSTUNREACH
40
+ rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT, Timeout::Error, Errno::EHOSTUNREACH, Errno::EHOSTDOWN
41
+ $stderr.putc "." if trace
46
42
  end
47
43
  end
48
44
  end
45
+ ensure
46
+ socket.close if socket
49
47
  end
50
48
 
51
49
  def wait
@@ -62,7 +60,7 @@ class Godot
62
60
  end
63
61
 
64
62
  def match(pattern, path = "", options = "-ks")
65
- match!(pattern, options)
63
+ match!(pattern, path, options)
66
64
  true
67
65
  rescue Timeout::Error
68
66
  false
@@ -1,3 +1,3 @@
1
1
  class Godot
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
File without changes
@@ -2,7 +2,7 @@ shared_context "without a server", :target => false do
2
2
  let(:godot) { Godot.new("localhost", 1) }
3
3
 
4
4
  before do
5
- godot.stub(:timeout).and_return(0.1)
6
- godot.stub(:interval).and_return(0.01)
5
+ godot.stub(:timeout).and_return(1)
6
+ godot.stub(:interval).and_return(1)
7
7
  end
8
- end
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: godot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-28 00:00:00.000000000 Z
13
+ date: 2012-11-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec