Sha256: 2e029a1681838c492eaf991878dd45a83902c95f2623530e71e8891d4da6be7e

Contents?: true

Size: 743 Bytes

Versions: 6

Compression:

Stored size: 743 Bytes

Contents

# A module that contains (1) string related methods
# @deprecated remove this module when we remove the method (duh)
module RSolr::Char
  
  # backslash everything
  # that isn't a word character
  # @deprecated - this is incorrect Solr escaping
  def escape value
    warn "[DEPRECATION] `RSolr.escape` is deprecated (and incorrect).  Use `RSolr.solr_escape` instead."
    value.gsub(/(\W)/, '\\\\\1')
  end
  
  # LUCENE_CHAR_RX = /([\+\-\!\(\)\[\]\^\"\~\*\?\:\\]+)/
  # LUCENE_WORD_RX = /(OR|AND|NOT)/
  # 
  # # More specific/lucene escape sequence
  # def lucene_escape string
  #   delim = " "
  #   string.gsub(LUCENE_CHAR_RX, '\\\\\1').split(delim).map { |v|
  #     v.gsub(LUCENE_WORD_RX, '\\\\\1')
  #   }.join(delim)
  # end
  
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/rsolr-1.1.2/lib/rsolr/char.rb
rsolr-1.1.2 lib/rsolr/char.rb
rsolr-1.1.1 lib/rsolr/char.rb
rsolr-1.1.1.pre2 lib/rsolr/char.rb
rsolr-1.1.1.pre1 lib/rsolr/char.rb
rsolr-1.0.13 lib/rsolr/char.rb