Class: Chef::SolrQuery::QueryTransform

Inherits:
Object
  • Object
show all
Defined in:
lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/search/parser.rb,
lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/query_transform.rb

Constant Summary collapse

@@base_path =
File.expand_path(File.dirname(__FILE__))
@@parser =
LuceneParser.new

Class Method Summary collapse

Class Method Details

.base_pathObject



26
27
28
# File 'lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/search/parser.rb', line 26

def self.base_path
  class_variable_get(:@@base_path)
end

.parse(data) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/query_transform.rb', line 35

def self.parse(data)
  tree = @@parser.parse(data)
  msg = "Parse error at offset: #{@@parser.index}\n"
  msg += "Reason: #{@@parser.failure_reason}"
  raise Chef::Exceptions::QueryParseError, msg if tree.nil?
  self.clean_tree(tree)
  tree.to_array
end

.transform(data) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/query_transform.rb', line 44

def self.transform(data)
  return "*:*" if data == "*:*"
  tree = @@parser.parse(data)
  msg = "Parse error at offset: #{@@parser.index}\n"
  msg += "Reason: #{@@parser.failure_reason}"
  raise Chef::Exceptions::QueryParseError, msg if tree.nil?
  self.clean_tree(tree)
  tree.transform
end