Class: WaitForSolr

Inherits:
Struct
  • Object
show all
Defined in:
lib/wait_for_solr.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#portObject

Returns the value of attribute port

Returns:

  • (Object)

    the current value of port



5
6
7
# File 'lib/wait_for_solr.rb', line 5

def port
  @port
end

#timeoutObject

Returns the value of attribute timeout

Returns:

  • (Object)

    the current value of timeout



5
6
7
# File 'lib/wait_for_solr.rb', line 5

def timeout
  @timeout
end

Class Method Details

.on(port, timeout, &block) ⇒ Object



6
7
8
# File 'lib/wait_for_solr.rb', line 6

def self.on(port, timeout, &block)
  new(port, timeout).wait &block
end

.running_on?(port) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/wait_for_solr.rb', line 10

def self.running_on?(port)
  new(port).responding?
end

Instance Method Details

#responding?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/wait_for_solr.rb', line 23

def responding?
  system %(curl -o /dev/null "http://localhost:#{port}/solr" > /dev/null 2>&1)
end

#waitObject



14
15
16
17
18
19
20
21
# File 'lib/wait_for_solr.rb', line 14

def wait
  Timeout.timeout timeout do
    until responding?
      yield
      sleep 1
    end
  end
end