Class: WaitForSolr
- Inherits:
-
Struct
- Object
- Struct
- WaitForSolr
- Defined in:
- lib/wait_for_solr.rb
Instance Attribute Summary collapse
-
#port ⇒ Object
Returns the value of attribute port.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#port ⇒ Object
Returns the value of attribute port
3 4 5 |
# File 'lib/wait_for_solr.rb', line 3 def port @port end |
#timeout ⇒ Object
Returns the value of attribute timeout
3 4 5 |
# File 'lib/wait_for_solr.rb', line 3 def timeout @timeout end |
Class Method Details
.on(port, timeout, &block) ⇒ Object
4 5 6 |
# File 'lib/wait_for_solr.rb', line 4 def self.on port, timeout, &block new(port, timeout).wait &block end |
.running_on?(port) ⇒ Boolean
8 9 10 |
# File 'lib/wait_for_solr.rb', line 8 def self.running_on? port new(port).responding? end |
Instance Method Details
#responding? ⇒ Boolean
21 22 23 |
# File 'lib/wait_for_solr.rb', line 21 def responding? system %(curl -o /dev/null "http://localhost:#{port}/solr" > /dev/null 2>&1) end |
#wait(&block) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/wait_for_solr.rb', line 12 def wait &block Timeout::timeout timeout do until responding? do block.call sleep 1 end end end |