Class: Godot
- Inherits:
-
Object
- Object
- Godot
- Defined in:
- lib/godot.rb,
lib/godot/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
- #interval ⇒ Object
-
#port ⇒ Object
readonly
Returns the value of attribute port.
- #timeout ⇒ Object
Class Method Summary collapse
- .match(host, port, pattern, path = "", options = "-ks") ⇒ Object
- .match!(host, port, pattern, path = "", options = "-ks") ⇒ Object
- .wait(host, port) ⇒ Object
- .wait!(host, port) ⇒ Object
Instance Method Summary collapse
-
#initialize(host, port) ⇒ Godot
constructor
A new instance of Godot.
- #match(pattern, path = "", options = "-ks") ⇒ Object
- #match!(pattern, path = "", options = "-ks") ⇒ Object
- #wait ⇒ Object
- #wait! ⇒ Object
Constructor Details
#initialize(host, port) ⇒ Godot
Returns a new instance of Godot.
24 25 26 27 |
# File 'lib/godot.rb', line 24 def initialize(host, port) @host = host @port = port end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/godot.rb', line 5 def host @host end |
#interval ⇒ Object
29 30 31 |
# File 'lib/godot.rb', line 29 def interval @interval || 1 end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
5 6 7 |
# File 'lib/godot.rb', line 5 def port @port end |
#timeout ⇒ Object
33 34 35 |
# File 'lib/godot.rb', line 33 def timeout @timeout || 10 end |
Class Method Details
.match(host, port, pattern, path = "", options = "-ks") ⇒ Object
20 21 22 |
# File 'lib/godot.rb', line 20 def self.match(host, port, pattern, path = "", = "-ks") new(host, port).match(pattern, path, ) end |
.match!(host, port, pattern, path = "", options = "-ks") ⇒ Object
16 17 18 |
# File 'lib/godot.rb', line 16 def self.match!(host, port, pattern, path = "", = "-ks") new(host, port).match!(pattern, path, ) end |
.wait(host, port) ⇒ Object
12 13 14 |
# File 'lib/godot.rb', line 12 def self.wait(host, port) new(host, port).wait end |
.wait!(host, port) ⇒ Object
8 9 10 |
# File 'lib/godot.rb', line 8 def self.wait!(host, port) new(host, port).wait! end |
Instance Method Details
#match(pattern, path = "", options = "-ks") ⇒ Object
64 65 66 67 68 69 |
# File 'lib/godot.rb', line 64 def match(pattern, path = "", = "-ks") match!(pattern, ) true rescue Timeout::Error false end |
#match!(pattern, path = "", options = "-ks") ⇒ Object
58 59 60 61 62 |
# File 'lib/godot.rb', line 58 def match!(pattern, path = "", = "-ks") Timeout.timeout(timeout) do sleep interval until `curl #{} http://#{host}:#{port}/#{path}` =~ pattern end end |
#wait ⇒ Object
51 52 53 54 55 56 |
# File 'lib/godot.rb', line 51 def wait wait! true rescue Timeout::Error false end |
#wait! ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/godot.rb', line 37 def wait! Timeout.timeout(timeout) do socket = nil until socket begin Timeout.timeout(interval) do socket = TCPSocket.open(host, port) end rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT, Timeout::Error, Errno::EHOSTUNREACH end end end end |