Class: Gitlab::Search::Query

Inherits:
SimpleDelegator
  • Object
show all
Includes:
EncodingHelper
Defined in:
lib/gitlab/search/query.rb

Constant Summary collapse

QUOTES_REGEXP =
%r{\A"|"\Z}
TOKEN_WITH_QUOTES_REGEXP =
%r{\s(?=(?:[^"]|"[^"]*")*$)}

Constants included from EncodingHelper

EncodingHelper::BOM_UTF8, EncodingHelper::ENCODING_CONFIDENCE_THRESHOLD, EncodingHelper::ESCAPED_CHARS, EncodingHelper::UNICODE_REPLACEMENT_CHARACTER

Instance Method Summary collapse

Methods included from EncodingHelper

#binary_io, #detect_binary?, #detect_encoding, #detect_libgit2_binary?, #encode!, #encode_binary, #encode_utf8, #encode_utf8_no_detect, #encode_utf8_with_escaping!, #encode_utf8_with_replacement_character, #strip_bom, #unquote_path

Constructor Details

#initialize(query, filter_opts = {}, &block) ⇒ Query

Returns a new instance of Query.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/gitlab/search/query.rb', line 11

def initialize(query, filter_opts = {}, &block)
  @raw_query = query.dup
  @filters = []
  @filter_options = { default_parser: :downcase.to_proc }.merge(filter_opts)

  self.instance_eval(&block) if block

  @query = Gitlab::Search::ParsedQuery.new(*extract_filters)
  # set the ParsedQuery as our default delegator thanks to SimpleDelegator
  super(@query)
end