/usr/lib/ruby/vendor_ruby/chef_zero/solr/query/term.rb is in chef-zero 4.5.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | require 'chef_zero/solr/query/regexpable_query'
module ChefZero
module Solr
module Query
class Term < RegexpableQuery
def initialize(term)
# Get rid of escape characters, turn * and ? into .* and . for regex, and
# escape everything that needs escaping
literal_string = ""
regexp_string = ""
index = 0
while index < term.length
if term[index] == '*'
regexp_string << "#{WORD_CHARACTER}*"
literal_string = nil
index += 1
elsif term[index] == '?'
regexp_string << WORD_CHARACTER
literal_string = nil
index += 1
elsif term[index] == '~'
raise "~ unsupported"
else
if term[index] == '\\'
index = index+1
if index >= term.length
raise "Backslash at end of string '#{term}'"
end
end
literal_string << term[index] if literal_string
regexp_string << Regexp.escape(term[index])
index += 1
end
end
super(regexp_string, literal_string)
end
def to_s
"Term(#{regexp_string})"
end
end
end
end
end
|