Sha256: 09d331173723fd55fcf93e84fc8ab047db6660bd2ccc8d7429fb9a64d24c1ad4

Contents?: true

Size: 453 Bytes

Versions: 13

Compression:

Stored size: 453 Bytes

Contents

require "timeout"

class WaitForSolr < Struct.new(:port, :timeout)
  def self.on port, timeout, &block
    new(port, timeout).wait &block
  end

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

  def wait &block
    Timeout::timeout timeout do
      until responding? do
        block.call
        sleep 1
      end
    end
  end

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

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
calagator-1.0.0 lib/wait_for_solr.rb
grokus-1.0.0.9 lib/wait_for_solr.rb
grokus-1.0.0.8 lib/wait_for_solr.rb
grokus-1.0.0.7 lib/wait_for_solr.rb
grokus-1.0.0.6 lib/wait_for_solr.rb
grokus-1.0.0.5 lib/wait_for_solr.rb
grokus-1.0.0.3 lib/wait_for_solr.rb
grokus-1.0.0.2 lib/wait_for_solr.rb
grokus-1.0.0.1 lib/wait_for_solr.rb
calagator-1.0.0.rc3 lib/wait_for_solr.rb
calagator-1.0.0.rc2 lib/wait_for_solr.rb
calagator-1.0.0.rc1 lib/wait_for_solr.rb
calagator-0.0.1.pre1 lib/wait_for_solr.rb