examples/ruby-percolator/ruby-percolator.rb
def matches?(text)
    @stdin.puts text
    # lmgrep works like this:
    # - if an input doesn't match any query then there is an empty line writen to stdout
    # - if there is a match then some JSON output is returned
    # The percolation is timeout bound.
    # If it times-out, stop the percolator and
    # - throw an exception
    # - log the output
    # - create an issue here https://github.com/dainiusjocas/lucene-grep/issues
    output = Timeout::timeout(@timeout) {
      @stdout.gets
    }
    # If we got any non-blank output then the text matches some query
    ! output.strip.empty?
  rescue Timeout::Error
    puts "Percolation failed on '#{text}'"
    raise "Percolation timed-out!!!"
  end
# Returns true if matches, false otherwise
Returns true if matches, false otherwise
Returns true if matches false otherwise
def matches?(text)
    @stdin.puts text
    output = Timeout::timeout(@timeout) {
      @stdout.gets
    }
    ! output.strip.empty?
  rescue Timeout::Error
    puts "Percolation failed on '#{text}'"
    raise "Percolation timed-out!!!"
  end
def matches? ( text ) @stdin . puts text output = Timeout :: timeout ( @timeout ) { @stdout . gets } ! output . strip . empty? rescue Timeout :: Error puts "Percolation failed on '#{text}'" raise "Percolation timed-out!!!" end
Returns true if matches, false otherwise
Returns true if matches false otherwise
# lmgrep works like this: # - if an input doesn't match any query then there is an empty line writen to stdout # - if there is a match then some JSON output is returned # The percolation is timeout bound. # If it times-out, stop the percolator and # - throw an exception # - log the output # - create an issue here https://github.com/dainiusjocas/lucene-grep/issues # If we got any non-blank output then the text matches some query
text